Loop (AS 3.0) V. 2.0 Documentation
Properties
| Name | Type | Description |
| content | Object | Defines displayed content. 1.description:String 2.path:Mixed 3.type:String – "image" "instance" 4.data - Miscellaneous property Example import com.afcomponents.events.LoopEvent; // Wait for Loop to initialize function onLoopInit(event:Event) { // Add Loop items myLoop.addItem({path:"img_0.jpg", description:"IMAGE 0", data:"data", type:"image"}); myLoop.addItem({path:"img_1.jpg", description:"IMAGE 1", data:"data", type:"image"}); myLoop.addItem({path:"img_2.jpg", description:"IMAGE 2", data:"data", type:"image"}); myLoop.addItem({path:"img_3.jpg", description:"IMAGE 3", data:"data", type:"image"}); myLoop.addItem({path:"img_4.jpg", description:"IMAGE 4", data:"data", type:"image"}); myLoop.addItem({path:"img_5.jpg", description:"IMAGE 5", data:"data", type:"image"}); myLoop.addItem({path:"img_6.jpg", description:"IMAGE 6", data:"data", type:"image"}); myLoop.addItem({path:"img_7.jpg", description:"IMAGE 7", data:"data", type:"image"}); } myLoop.addEventListener(LoopEvent.INITIALIZE, onLoopInit); |
| contentXML | String | Path to content XML file or RSS 2.0 image feed. XML File Format <content> <item> <description>Image 1</description> <path>image.jpg</path> <data>url.html</data> <type>image</type> </item> </content> Example myLoop.contentXML = "file.xml"; Note: You can use a custom node in your XML and it becomes of property of the item. Custom Node XML Example <content> <item> <description>Image 1</description> <path>image.jpg</path> <data>url.html</data> <name>MyCustomNode</name> </item> </content> trace(myLoop.getSelectedItem().name); |
| contentStyle | Object | Property defines image size. Please note that width and height parameters override maintainAspectRatio and scaleContent properties. 1. width:Number 2. height:Number 3. maintainAspectRatio:Boolean 4. scaleContent:Boolean 5. padding:Number – horizontal padding 6. autoSize:Boolean Example myLoop.contentStyle = {width:100, height:150, maintainAspectRatio:true, scaleContent:true, padding:10, autoSize: false}; |
| itemContainerDefaultStyle | Object | Defines the default item container shape style. 1.fill:Bolean 2.fillColor:Number (ARGB) 3.fillGradient:Object [ActionScript Only] 4.stroke:Boolean 5.strokeColor:Number (ARGB) 6.cornerRadius:Number 7.horizontalPadding:Number 8.verticalPadding:Number Example myLoop.itemContainerDefaultStyle = {fill:true, fillColor:0xFF0000CC, stroke:false, strokeColor:0x00FF00CC, cornerRadius:2, horizontalPadding: 5, verticalPadding: 5}; |
| itemContainerOverStyle | Object | Defines the item container shape style on mouse over event. 1.fill:Bolean 2.fillColor:Number (ARGB) 3.fillGradient:Object [ActionScript Only] 4.stroke:Boolean 5.strokeColor:Number (ARGB) 6.cornerRadius:Number 7.horizontalPadding:Number 8.verticalPadding:Number Example myLoop.itemContainerOverStyle = {fill:true, fillColor:0xFF0000CC, stroke:false, strokeColor:0x00FF00CC, cornerRadius:2, horizontalPadding: 5, verticalPadding: 5}; |
| itemContainerSelectedStyle | Object | Defines the style for a selected item. 1.fill:Bolean 2.fillColor:Number (ARGB) 3.fillGradient:Object [ActionScript Only] 4.stroke:Boolean 5.strokeColor:Number (ARGB) 6.cornerRadius:Number 7.horizontalPadding:Number 8.verticalPadding:Number Example myLoop.itemContainerSelectedStyle = {fill:true, fillColor:0xFF0000CC, stroke:false, strokeColor:0x00FF00CC, cornerRadius:2, horizontalPadding: 5, verticalPadding: 5}; |
| previewClip | String | Property defines a class of a placeholder movie clip. Example myLoop.previewClip = "MyClip"; |
| loopStyle | Object | Defines the Loops scroll. 1. scrollSpeed:Number 2. scrollOverSpeed:Number 3. scrollDirection:String (left, right, up, or down) myLoop.loopStyle = {scrollSpeed:3, scrollOverSpeed:1, scrollDirection: "left"} |
| transition | Object | Property determines whether to display image transition (true) or not (false). Fade transition is displayed after thumbnail image has been loaded. Options 1. enable:Boolean 2. transition:fl.transitions (Blinds, Fly, Fade, Iris, Photo, PixelDissolve, Rotate, Squizee, Wipe, or Zoom) 2. motion:Class 3. easing:String 4. duration:Number Example myLoop.transition = {enable:true, transition:fl.transition.PixelDissolve, motion:fl.motion.easing.Linear,duration:1} Example import fl.transitions.*; import fl.transitions.easing.*; myLoop.transition = {type:Zoom, direction:Transition.IN, duration:1, easing:Bounce.easeOut}; |
| reflectionStyle | Object | Set the reflection of the Loop. 1. enable:Bolean 2. alpha:Number 3. clipAlpha:Number 4. distance:Number 5. matrixRatio:Number 6. matrixDropOff:Number Example myLoop.reflectionStyle = {enable:true, alpha: 0.8, clipAlpha: 0.5, distance: 1, matrixRatio: 1, matrixDropOff: 1}; |
| loadItemsBeforeStart | Number | Defines how many items load before loop starts scrolling. Example myLoop.loadItemsBeforeStart = 3; |
| length | Number | Read-only property indicates the number of items in the Loop. Example trace(myLoop.length); |
Methods
| Name | Return Type | Description |
| getItemNum( index:Number ) | Object | Returns content item object specified by index parameter. Example var item:Object = new Object(); item = myLoop.getItemNum(2); trace(item.description); trace(item.path); trace(item.data); trace(item.id); |
| getTotalItems( ) | Number | Returns total number of items in the content object. Example var items = myLoop.getTotalItems(); |
| getSelectedItem( ) | Object | Returns selected item object. Example var item:Object = new Object(); item = myLoop.getSelectedItem(); trace(item.description); trace(item.path); trace(item.data); trace(item.id); |
| selectItem( item:Object ) | Void | Selects item specified by the item parameter. Example var item:Object = new Object(); item = myLoop.getItemNum(2); myLoop.selectItem(item); |
| selectItemNum( index:Number ) | Void | Selects item specified by the index parameter. Example myLoop.selectItemNum(2); |
| selectNextItem( ) | Void | Selects next item. Example myLoop.selectNextItem(); |
| selectPreviousItem( ) | Void | Selects previous item. Example myLoop.selectPreviousItem(); |
| addItem( item:Object ) | Void | Adds a new item to the Loop. Example myLoop.addItem({description:"Item", path:"image.jpg",data:"url.html", type:"image"}); |
| removeItem( item:Object ) | Void | Removes item from the Loop. Example var item = myLoop.getItemNum(3); myLoop.removeItem(item); |
| addGenericItemEventListener( event:String, listener:Function ) |
Void | Adds an event listener to each item in the Loop. Generic Event Example import flash.events.MouseEvent; function eventHandler(event:MouseEvent){ trace(event.target); } myLoop.addGenericItemEventListener(MouseEvent.CLICK, eventHandler); |
| getItemAt( index:Number ) | Object | Returns content item object specified by index parameter. Example var item:Object = new Object(); item = myLoop.getItemAt(2); trace(item.description); trace(item.path); trace(item.data); trace(item.id); |
| selectItemAt( index:Number ) | Void | Selects the item specified in the index parameter. Example myLoop.selectItemAt(3); |
| addItemAt( item:Object, index:Number ) |
Void | Adds the object passed in the item parameter at index in the Loop. Example myLoop.addItemAt({description:"description", path:"pic.jpg", data:"url.html"}, 3); |
| removeItemAt( index:Number ) | Void | Removes the item at index from the Loop. Example myLoop.removeItemAt(3); |
| replaceItemAt( item:Object, index:Number ) |
Void | Replaces the item at index with the passed item object. Example myLoop.replaceItemAt({description:"description", path:"pic.jpg", data:"url.html"}, 3); |
| removeAll( ) | Void | Removes all items from the Loop. Example myLoop.removeAll(); |
| addItemEventListener( index:Number, event:String, listener:Function ) |
Void | Adds an event listener to the item specified by index. Example myLoop.addItemEventListener(4, MouseEvent.CLICK, eventHandler); |
Events
| Name | Return Value | Description |
| INITIALIZE | target type |
Triggered after component initializes. Example import com.afcomponents.events.LoopEvent; function eventHandler(event:Event){ trace(event.type); trace(event.target); } myLoop.addEventListener(LoopEvent.INITIALIZE, eventHandler); |
| ERROR | target type message |
Triggered once error occurs. If there is an error loading an image this event fired. If a wrong parameter is passed to a function this event is fired. Example import com.afcomponents.events.LoopEvent; function eventHandler(event:Event){ trace(event.type); trace(event.target); trace(event.message); } myLoop.addEventListener(LoopEvent.ERROR, eventHandler); |
| CHANGE | target type |
Triggered once any of the component properties is modified or component state changes. Example import com.afcomponents.events.LoopEvent; function eventHandler(event:Event){ trace(event.type); trace(event.target); trace(event.target); } myLoop.addEventListener(LoopEvent.CHANGE, eventHandler); |
| CONTENT_LOAD_START | target type |
Triggered whenever content (images) start loading. This event helps user track general loading progress. Example import com.afcomponents.events.LoopEvent; function eventHandler(event:Event){ trace(event.type); trace(event.target); } myLoop.addEventListener(LoopEvent.CONTENT_LOAD_START, eventHandler); |
| CONTENT_LOAD_PROGRESS | target type itemsLoaded itemsTotal |
Triggered during content (images) loading. Returns total and loaded number of content elements. Example import com.afcomponents.events.LoopEvent; function eventHandler(event:Event){ trace(event.type); trace(event.target); trace(event.itemsLoaded); trace(event.itemsTotal); } myLoop.addEventListener(LoopEvent.CONTENT_LOAD_PROGRESS, eventHandler); |
| CONTENT_LOAD_COMPLETE | target type |
Triggered after the content finishes loading. Example import com.afcomponents.events.LoopEvent; function eventHandler(event:Event){ trace(event.type); trace(event.target); } myLoop.addEventListener(LoopEvent.CONTENT_LOAD_COMPLETE, eventHandler); |
| XML_LOAD_START | target type |
Triggered when XML starts loading. Example import com.afcomponents.events.LoopEvent; function eventHandler(event:Event){ trace(event.type); trace(event.target); } myLoop.addEventListener(LoopEvent.XML_LOAD_START, eventHandler); |
| XML_LOAD_PROGRESS | target type bytesLoaded bytesTotal |
Triggered while XML file is being loaded. Example import com.afcomponents.events.LoopEvent; function eventHandler(event:Event){ trace(event.type); trace(event.bytesLoaded); trace(event.bytesTotal); } myLoop.addEventListener(LoopEvent.XML_LOAD_PROGRESS, eventHandler); |
| XML_LOAD_COMPLETE | target type |
Triggered after XML file finishes loading. Example import com.afcomponents.events.LoopEvent; function eventHandler(event:Event){ trace(event.type); trace(event.target); } myLoop.addEventListener(LoopEvent.XML_LOAD_COMPLETE, eventHandler); |
| ITEM_LOAD_START | target type |
Triggered when item image starts loading. Example import com.afcomponents.events.LoopEvent; function eventHandler(event:Event){ trace(event.type); trace(event.target); } myLoop.addEventListener(LoopEvent.ITEM_LOAD_START, eventHandler); |
| ITEM_LOAD_PROGRESS | target type bytesLoaded bytesTotal |
Triggered while item image is being loaded. Example import com.afcomponents.events.LoopEvent; function eventHandler(event:Event){ trace(event.type); trace(event.target); trace(event.bytesLoaded); trace(event.bytesTotal); } myLoop.addEventListener(LoopEvent.XML_LOAD_PROGRESS, eventHandler); |
| ITEM_LOAD_COMPLETE | Target Type |
Triggered after item image finishes loading. Example import com.afcomponents.events.LoopEvent; function eventHandler(event:Event){ trace(event.type); trace(event.target); } myLoop.addEventListener(LoopEvent.ITEM_LOAD_COMPLETE, eventHandler); |
| ITEM_SELECTED | target type |
Triggered once the item is selected. This event is triggered during the during the slide show mode. Example import com.afcomponents.events.LoopEvent; function eventHandler(event:Event){ trace(event.type); trace(event.target); } myLoop.addEventListener(LoopEvent.ITEM_SELECTED, eventHandler); |
