| Package | vegas.models.arrays |
| Class | public class PageableArrayModelObject |
| Inheritance | PageableArrayModelObject CoreModelObject CoreModel CoreEventDispatcher Object |
Array model with a 'page by page' iterator.
| Property | Defined By | ||
|---|---|---|---|
![]() | channel : String [read-only]
Indicates the channel of this dispatcher if this instance is global. | CoreEventDispatcher | |
| count : uint
Determinates the count of items in a page of this model. | PageableArrayModelObject | ||
| currentPage : Number
Indicates the current page selected in the model. | PageableArrayModelObject | ||
![]() | id : *
Returns the id of this IModelObject. | CoreModel | |
| pageCount : Number [read-only]
Indicates the numbers of page with the current model. | PageableArrayModelObject | ||
![]() | security : Boolean = true
This property defined if the setCurrentVO method can accept the same vo in argument as the current one. | CoreModelObject | |
| Method | Defined By | ||
|---|---|---|---|
PageableArrayModelObject(global:Boolean = true, channel:String = null, id:* = null)
Creates a new PageableArrayModelObject instance. | PageableArrayModelObject | ||
![]() | addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0.0, useWeakReference:Boolean = false):void
Allows the registration of event listeners on the event target. | CoreEventDispatcher | |
clear():void [override]
Clear the model. | PageableArrayModelObject | ||
![]() |
Returns and creates a new empty ModelObjectEvent. | CoreModelObject | |
![]() | dispatchEvent(event:Event):Boolean
Dispatches an event into the event flow. | CoreEventDispatcher | |
firstPage():void
Seek the iterator in the first page of this object. | PageableArrayModelObject | ||
![]() |
Returns the current ValueObject selected in this model. | CoreModelObject | |
![]() |
Returns the internal system.events.EventDispatcher reference. | CoreEventDispatcher | |
![]() | getEventTypeBEFORE_CHANGE():String
Returns the event name use in the setCurrentVO method before is changed. | CoreModelObject | |
![]() | getEventTypeCHANGE():String
Returns the event name use in the setVO method. | CoreModelObject | |
![]() | getEventTypeCLEAR():String
Returns the event name use in the clear method. | CoreModelObject | |
getEventTypeINIT():String
Returns the event name use in the notifyInit method. | PageableArrayModelObject | ||
getEventTypeUPDATE():String
Returns the event name use in the notifyUpdate method. | PageableArrayModelObject | ||
getVO(id:*):ValueObject
Returns the ValueObject defined by the id passed in argument register in the model. | PageableArrayModelObject | ||
![]() | hasEventListener(type:String):Boolean
Checks whether the EventDispatcher object has any listeners registered for a specific type of event. | CoreEventDispatcher | |
hasNext():Boolean
Returns true if the list has a next page. | PageableArrayModelObject | ||
hasPrevious():Boolean
Returns true if the list has a previous page. | PageableArrayModelObject | ||
init(datas:Array, autoClear:Boolean = true, autoRefresh:Boolean = true):void
Fill and initialize the model with an Array of ValueObject. | PageableArrayModelObject | ||
![]() | initEventType():void
This method is invoked in the constructor of the class to initialize all events. | CoreModelObject | |
![]() | isGlobal():Boolean
Indicates if the dispatcher use a global event flow. | CoreEventDispatcher | |
![]() | isLocked():Boolean
Returns true if the object is locked. | CoreEventDispatcher | |
Returns a PageByPageIterator of this model. | PageableArrayModelObject | ||
lastPage():void
Seek the iterator in the last page of this object. | PageableArrayModelObject | ||
![]() | lock():void
Locks the object. | CoreEventDispatcher | |
next():*
Show the next page of the model. | PageableArrayModelObject | ||
![]() | notifyBeforeChange(vo:ValueObject):void
Notify a ModelObjectEvent before the current ValueObject selected in the model is changed. | CoreModelObject | |
![]() | notifyChange(vo:ValueObject):void
Notify a ModelObjectEvent when a ValueObject change in the model. | CoreModelObject | |
![]() | notifyClear():void
Notify a ModelObjectEvent when the model is cleared. | CoreModelObject | |
notifyInit():void
Notify an Event object when the model is initialized. | PageableArrayModelObject | ||
notifyUpdate(value:*):*
Notify an Event when a ValueObject is inserted in the model. | PageableArrayModelObject | ||
pageOf(vo:ValueObject):uint
Finds and indicates the page number of the specified value object register in the model. | PageableArrayModelObject | ||
previous():*
Show in the previous page in the list or previous screen. | PageableArrayModelObject | ||
refresh():void
Refresh the model. | PageableArrayModelObject | ||
![]() | registerEventListener(type:String, listener:*, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Allows the registration of event listeners on the event target (Function or EventListener). | CoreEventDispatcher | |
![]() | removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object. | CoreEventDispatcher | |
reset():void
Resets the key pointer of the iterator. | PageableArrayModelObject | ||
run(... arguments):void [override]
Run the model when is initialize. | PageableArrayModelObject | ||
setCount(n:uint, noRender:Boolean = false):void
Set the count of items in a page of this model. | PageableArrayModelObject | ||
![]() | setCurrentVO(vo:ValueObject):void
Sets the current ValueObject selected in this model. | CoreModelObject | |
![]() | setEventDispatcher(dispatcher:EventDispatcher):void
Sets the internal EventDispatcher reference. | CoreEventDispatcher | |
![]() | setEventTypeBEFORE_CHANGE(type:String):void
Returns the event name use in the setCurrentVO method before is changed. | CoreModelObject | |
![]() | setEventTypeCHANGE(type:String):void
Returns the event name use in the setVO method. | CoreModelObject | |
![]() | setEventTypeCLEAR(type:String):void
Returns the event name use in the clear method. | CoreModelObject | |
setEventTypeINIT(type:String):void
Sets the event name use in the notifyInit method. | PageableArrayModelObject | ||
setEventTypeUPDATE(type:String):void
Sets the event name use in the notifyUpdate method. | PageableArrayModelObject | ||
![]() | setGlobal(flag:Boolean = false, channel:String = null):void
Sets if the instance use a global system.events.EventDispatcher to dispatch this events, if the flag value is false the instance use a local EventDispatcher. | CoreEventDispatcher | |
size():uint
Returns the number of ValueObject in this model. | PageableArrayModelObject | ||
![]() | supports(value:*):Boolean
Returns true if the IValidator object validate the value. | CoreModelObject | |
toArray():Array
Returns the Array representation of all vos in this model. | PageableArrayModelObject | ||
![]() | unlock():void
Unlocks the display. | CoreEventDispatcher | |
![]() | unregisterEventListener(type:String, listener:*, useCapture:Boolean = false):void
Removes a listener (Function or EventListener object) from the EventDispatcher object. | CoreEventDispatcher | |
![]() | validate(value:*):void
Evaluates the specified value and throw a TypeError object if the value is not valid. | CoreModelObject | |
![]() | willTrigger(type:String):Boolean
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type. | CoreEventDispatcher | |
| count | property |
count:uintDeterminates the count of items in a page of this model.
public function get count():uint public function set count(value:uint):void| currentPage | property |
currentPage:NumberIndicates the current page selected in the model.
public function get currentPage():Number public function set currentPage(value:Number):void| pageCount | property |
pageCount:Number [read-only] Indicates the numbers of page with the current model.
public function get pageCount():Number| PageableArrayModelObject | () | Constructor |
public function PageableArrayModelObject(global:Boolean = true, channel:String = null, id:* = null)Creates a new PageableArrayModelObject instance.
Parametersglobal:Boolean (default = true) — the flag to use a global event flow or a local event flow (default true).
| |
channel:String (default = null) — the name of the global event flow if the global argument is true.
| |
id:* (default = null) — the id of this model.
|
| clear | () | method |
override public function clear():voidClear the model.
| firstPage | () | method |
public function firstPage():voidSeek the iterator in the first page of this object.
| getEventTypeINIT | () | method |
public function getEventTypeINIT():String
Returns the event name use in the notifyInit method.
String — the event name use in the notifyInit method.
|
| getEventTypeUPDATE | () | method |
public function getEventTypeUPDATE():String
Returns the event name use in the notifyUpdate method.
String — the event name use in the notifyUpdate method.
|
| getVO | () | method |
public function getVO(id:*):ValueObjectReturns the ValueObject defined by the id passed in argument register in the model.
Parameters
id:* |
ValueObject — the ValueObject defined by the id passed in argument register in the model.
|
| hasNext | () | method |
public function hasNext():Boolean
Returns true if the list has a next page.
Boolean — true if the list has a next page.
|
| hasPrevious | () | method |
public function hasPrevious():Boolean
Returns true if the list has a previous page.
Boolean — true if the list has a previous page.
|
| init | () | method |
public function init(datas:Array, autoClear:Boolean = true, autoRefresh:Boolean = true):voidFill and initialize the model with an Array of ValueObject.
Parameters
datas:Array — The array of all value objects to insert in the model.
| |
autoClear:Boolean (default = true) — (optional) If this argument is true the clear method is invoked when the initialization begin.
| |
autoRefresh:Boolean (default = true) — (optional) If this argument is true the model is running when this initialization is finished.
|
| iterator | () | method |
public function iterator():IteratorReturns a PageByPageIterator of this model.
ReturnsIterator — a PageByPageIterator of this model.
|
| lastPage | () | method |
public function lastPage():voidSeek the iterator in the last page of this object.
| next | () | method |
public function next():*Show the next page of the model.
Returns* |
| notifyInit | () | method |
public function notifyInit():void
Notify an Event object when the model is initialized.
| notifyUpdate | () | method |
public function notifyUpdate(value:*):*
Notify an Event when a ValueObject is inserted in the model.
If the model countVO value is > 1 notify an ArrayEvent else if the coutVO value is 1 notify a ModelObjectEvent.
Parameters
value:* |
* |
| pageOf | () | method |
public function pageOf(vo:ValueObject):uintFinds and indicates the page number of the specified value object register in the model. If the passed-in value object is not found 0 is returned.
Parameters
vo:ValueObject |
uint |
| previous | () | method |
public function previous():*Show in the previous page in the list or previous screen.
Returns* |
| refresh | () | method |
public function refresh():voidRefresh the model.
| reset | () | method |
public function reset():voidResets the key pointer of the iterator.
| run | () | method |
override public function run(... arguments):voidRun the model when is initialize. This method don't work if the model is locked.
Parameters
... arguments |
See also
| setCount | () | method |
public function setCount(n:uint, noRender:Boolean = false):voidSet the count of items in a page of this model.
Parameters
n:uint — The count value of items in this model. This value must be >=1.
| |
noRender:Boolean (default = false) — Indicates if the method call the run method if this argumement is false (default is false).
|
| setEventTypeINIT | () | method |
public function setEventTypeINIT(type:String):void
Sets the event name use in the notifyInit method.
Parameters
type:String |
| setEventTypeUPDATE | () | method |
public function setEventTypeUPDATE(type:String):void
Sets the event name use in the notifyUpdate method.
Parameters
type:String |
| size | () | method |
public function size():uint
Returns the number of ValueObject in this model.
uint — the number of ValueObject in this model.
|
| toArray | () | method |
public function toArray():ArrayReturns the Array representation of all vos in this model.
ReturnsArray — the Array representation of all vos in this model.
|
import vegas.events.ModelObjectEvent ;
import vegas.models.arrays.PageableArrayModelObject ;
import vegas.vo.SimpleValueObject ;
import system.events.ArrayEvent ;
var init:Function = function( e:Event ):void
{
trace( "init" ) ;
}
var update:Function = function( e:Event ):void
{
switch( true )
{
case e is ArrayEvent :
{
trace( e + " : " + (e as ArrayEvent).array ) ;
break ;
}
case e is ModelObjectEvent :
{
trace( e + " : " + (e as ModelObjectEvent).getVO() ) ;
break ;
}
default :
{
trace( e + " : unknow type of event.") ;
}
}
}
var model:PageableArrayModelObject = new PageableArrayModelObject() ;
model.count = 2 ;
model.addEventListener( Event.INIT , init ) ;
model.addEventListener( ModelObjectEvent.UPDATE_VO , update ) ;
var datas:Array = [] ;
var count:uint = 20 ;
for ( var i:uint = 0 ; i<count ; i++ )
{
datas.push( new SimpleValueObject( { id:i } ) ) ;
}
model.init( datas ) ;
var onKeyDown:Function = function( e:KeyboardEvent ):void
{
var code:uint = e.keyCode ;
switch( code )
{
case Keyboard.LEFT :
{
if ( model.hasPrevious() == false )
{
model.lastPage() ;
}
else
{
model.previous() ;
}
break ;
}
case Keyboard.RIGHT :
{
if ( model.hasNext() == false )
{
model.firstPage() ;
}
else
{
model.next() ;
}
break ;
}
case Keyboard.SPACE :
{
model.setCount( 4 , true ) ; // change the count value but not auto restart the update process of the model.
}
}
}
stage.addEventListener( KeyboardEvent.KEY_DOWN , onKeyDown ) ;
trace( "Press Keyboard.LEFT and Keyboard.RIGHT keys to test this model" ) ;
trace( "Press Keyboard.SPACE to use a page with 4 items inside (change count of items)." ) ;
model.currentPage = 2 ; // go to the page 2