| Package | com.soma.view |
| Class | public class Page |
| Inheritance | Page flash.display.MovieClip |
| Implements | IPage |
| Subclasses | PageExternal |
Author: Romuald Quantin - www.soundstep.com
Information:
Blog page - SomaUI
How does it work - Soma Protest
Project Host - Google Code
Documentation - Soma ASDOC
Class version: 2.0
Actionscript version: 3.0
Copyright:
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied.
See the License for the specific language governing rights and
limitations under the License.
The Original Code is Soma.
The Initial Developer of the Original Code is Romuald Quantin.
Initial Developer are Copyright (C) 2008-2009 Soundstep. All Rights Reserved.
Usage:
The Page view class must be extended to create your own page.
Create a new page
1. Create a page node in the XML Site Definition.
<page id="mypage_id" type="MyPage" urlfriendly="my-page">
<title><![CDATA[My Page]]></title>
</page>
package com.project.pages {
import com.soma.interfaces.IPage;
import com.soma.view.Page;
import com.soma.events.PageEvent;
public class MyPage extends Page implements IPage {
public function MyPage() {
addEventListener(PageEvent.INITIALIZED, initialized, false, 0, true);
}
private function initialized(e:PageEvent = null):void {
removeEventListener(PageEvent.INITIALIZED, initialized, false);
// initialization complete, build page elements.
}
override public function transitionIn():void {
// show my page and call: super.transitionIn
Tweener.addTween(this, {time:1, _autoAlpha:1, onComplete:super.transitionIn});
}
override public function transitionInComplete():void {
// end of the transition to show the page
super.transitionInComplete();
}
override public function transitionOut():void {
// hide my page and call: super.transitionOut
Tweener.addTween(this, {time:1, _autoAlpha:0, onComplete:super.transitionOut});
}
override public function transitionOutComplete():void {
// end of the transition to hide the page, the page is about to be removed
// use a dispose function to destroy elements and listeners, then call super.transitionOutComplete
dispose();
super.transitionOutComplete();
}
}
}
Soma.getInstance().registerClass(MyPage);
addEventListener(addEventListener(PageEvent.CONTENT_PARSED, contentParsedHandler);
addEventListener(addEventListener(PageEvent.CONTENT_COMPLETE, contentCompleteHandler);
override public function transitionIn():void {
// show my page and call: super.transitionIn
Tweener.addTween(this, {time:1, _autoAlpha:1, onComplete:super.transitionIn});
}
override public function transitionInComplete():void {
// end of the transition to show the page
super.transitionInComplete();
}
override public function transitionOut():void {
// hide my page and call: super.transitionOut
Tweener.addTween(this, {time:1, _autoAlpha:0, onComplete:super.transitionOut});
}
override public function transitionOutComplete():void {
// end of the transition to hide the page, the page is about to be removed
// use a dispose function to destroy elements and listeners, then call super.transitionOutComplete
dispose();
super.transitionOutComplete();
}
Soma.getInstance().addEventListener(PageEvent.STARTED, pageHandler);
private function pageHandler(event:PageEvent):void {
// every time the PageManager is about to show (and remove) a page this handler will be called.
var currentPage:Page = Soma.getInstance().page.currentPage;
var nextPageID:String = event.id;
// here I stop the PageManager to change the page:
if (nextPageID == "PageIDIdontWantToSee") event.preventDefault();
}
See also
| Property | Defined by | ||
|---|---|---|---|
| assets : Array [read-only] Get an array containing the assets created by the NodeParser instance (all assets that are DisplayObject subclasses, you wont find XML in this array)
| Page | ||
| baseUI : BaseUI
BaseUI instance for layout purpose.
| Page | ||
| content : XML content node (XML) of the page, it is use by the NodeParser instance.
| Page | ||
| depth : int depth of the page (depth attribute in the page node).
| Page | ||
| hasExternalContent : Boolean [read-only]
Whether or external assets have been found (pictures for example, assets that have to be loaded).
| Page | ||
| id : String id of page (attribute id of the page node).
| Page | ||
| loader : SomaLoader
SomaLoader instance used by the NodeParser instance to load external assets.
| Page | ||
| loaderContext : LoaderContext LoaderContext instance of the SomaLoader instance of the page (null by default).
| Page | ||
| pageXML : XML page node (XML) of this page.
| Page | ||
| parser : NodeParser
NodeParser instance that will be used to create and load the assets found in the content node.
| Page | ||
| parserTarget : DisplayObjectContainer the target where the assets will be added to the display list (the page itself is the default but you can specify another container).
| Page | ||
| type : String type of the page (type attribute in the page node).
| Page | ||
| willBeRemoved : Boolean Whether or not the page is about to be removed by the PageManager.
| Page | ||
| Method | Defined by | ||
|---|---|---|---|
|
Page()
Creates a Page instance (this class should always be extended).
| Page | ||
|
getAssetByID(id:String):DisplayObject
Get an asset created and/or loaded by the NodeParser instance using the id attribute of its XML node.
| Page | ||
|
info():String
Get a String describing the page.
| Page | ||
|
transitionIn():void
Method that should be overridden, beginning of the showing process.
| Page | ||
|
transitionInComplete():void
Method that should be overridden, end of the showing process.
| Page | ||
|
transitionOut():void
Method that should be overridden, beginning of the hiding process.
| Page | ||
|
transitionOutComplete():void
Method that should be overridden, end of the hiding process.
| Page | ||
| assets | property |
assets:Array [read-only]Get an array containing the assets created by the NodeParser instance (all assets that are DisplayObject subclasses, you wont find XML in this array)
Implementation public function get assets():Array
| baseUI | property |
baseUI:BaseUI [read-write]BaseUI instance for layout purpose.
Implementation public function get baseUI():BaseUI
public function set baseUI(value:BaseUI):void
| content | property |
content:XML [read-write]content node (XML) of the page, it is use by the NodeParser instance.
Implementation public function get content():XML
public function set content(value:XML):void
| depth | property |
depth:int [read-write]depth of the page (depth attribute in the page node).
Implementation public function get depth():int
public function set depth(value:int):void
| hasExternalContent | property |
hasExternalContent:Boolean [read-only]Whether or external assets have been found (pictures for example, assets that have to be loaded).
Implementation public function get hasExternalContent():Boolean
| id | property |
id:String [read-write]id of page (attribute id of the page node).
Implementation public function get id():String
public function set id(value:String):void
| loader | property |
loader:SomaLoader [read-write]SomaLoader instance used by the NodeParser instance to load external assets. Set by default to the global loader (Soma.getInstance().loader).
Implementation public function get loader():SomaLoader
public function set loader(value:SomaLoader):void
| loaderContext | property |
loaderContext:LoaderContext [read-write]LoaderContext instance of the SomaLoader instance of the page (null by default).
Implementation public function get loaderContext():LoaderContext
public function set loaderContext(value:LoaderContext):void
| pageXML | property |
pageXML:XML [read-write]page node (XML) of this page.
Implementation public function get pageXML():XML
public function set pageXML(value:XML):void
| parser | property |
parser:NodeParser [read-write]NodeParser instance that will be used to create and load the assets found in the content node.
Implementation public function get parser():NodeParser
public function set parser(value:NodeParser):void
| parserTarget | property |
parserTarget:DisplayObjectContainer [read-write]the target where the assets will be added to the display list (the page itself is the default but you can specify another container).
Implementation public function get parserTarget():DisplayObjectContainer
public function set parserTarget(value:DisplayObjectContainer):void
| type | property |
type:String [read-write]type of the page (type attribute in the page node).
Implementation public function get type():String
public function set type(value:String):void
| willBeRemoved | property |
willBeRemoved:Boolean [read-write]Whether or not the page is about to be removed by the PageManager.
Implementation public function get willBeRemoved():Boolean
public function set willBeRemoved(value:Boolean):void
| Page | () | constructor |
public function Page()Creates a Page instance (this class should always be extended).
| getAssetByID | () | method |
public function getAssetByID(id:String):DisplayObjectGet an asset created and/or loaded by the NodeParser instance using the id attribute of its XML node.
Parametersid:String — Attribute id of the XML asset node.
|
DisplayObject — A DisplayObject.
|
| info | () | method |
public function info():StringGet a String describing the page.
ReturnsString — A String.
|
| transitionIn | () | method |
public function transitionIn():voidMethod that should be overridden, beginning of the showing process. Show your page elements here and call super.transitionIn when the page is displayed.
override public function transitionIn():void {
// show my page and/or my page elements, and call: super.transitionIn
Tweener.addTween(this, {time:1, _autoAlpha:1, onComplete:super.transitionIn});
}
| transitionInComplete | () | method |
public function transitionInComplete():voidMethod that should be overridden, end of the showing process. You must call super.transitionInComplete.
override public function transitionInComplete():void {
// end of the transition to show the page, at this moment the page is fully displayed
myMethodAferShowingThePage();
super.transitionInComplete();
}
| transitionOut | () | method |
public function transitionOut():voidMethod that should be overridden, beginning of the hiding process. Hide your page elements here and call super.transitionOut when the page is hidden.
override public function transitionOut():void {
// hide my page and/or my page elements, and call: super.transitionOut
Tweener.addTween(this, {time:1, _autoAlpha:0, onComplete:super.transitionOut});
}
| transitionOutComplete | () | method |
public function transitionOutComplete():voidMethod that should be overridden, end of the hiding process. You must call super.transitionInComplete (to allow the PageManager to remove the page and continue its process if you are using pages with depths).
override public function transitionOutComplete():void {
// end of the transition to hide the page, the page is about to be removed
// use a dispose function to destroy elements and listeners, then call super.transitionOutComplete
dispose();
super.transitionOutComplete();
}