Actionscript 2 Events

Events are called whenever the photoFlow performs the specified action. When publishing for Actionscript 2 the photoFlow includes the following events:

onInitPhotoFlow
Executed upon initializing the photoFlow

onLoadPhotosComplete
Executed once the specified number of images have finished loading

onSelectPhoto
Executed when an image becomes the current/selected image

onAddPhoto

Executed when an image is added

onRemovePhoto
Executed when an image is removed

onDoubleClick
Executed when double clicking on an image

onMouseOver
Executed when the mouse is rolled over an image

onMouseOut
Executed when the mouse is rolled off an image

onAutoFlip
Executed each time an image is auto flipped

onLoadPhoto
Executed each time an image has loaded

onLoadSet
Executed once the specified number of images has loaded

onLoadProgress
Executed whenever the load progress has changed

onStartLoadPhoto
Executed whenever an image starts loading


In order to use an event, you need to add a listener, which listens for the event's occurance. The following example shows how the onInitPhotoFlow event is called when the photoFlow is initialized:

var lis={};
lis.onInitPhotoFlow = function  (evt) {
trace ("photoflow initialized"); // type event action here.
}
photoflow.addEventListener ("onInitPhotoFlow", lis);

The lis object now listens to the initialization event of the photoFlow and performs the specified action.

An event object contains information that can be used. The following event objects have the same data structure:

onSelectPhoto
onAddPhoto
onRemovePhoto
onDoubleClick
onAutoFlip


Here is a example of using a variable from event object:

var  lis={};
lis.onSelectPhoto=function(evt){
    trace("selected photo");
    trace("name:"+evt.name);
    trace("photo index:"+evt.index);
    trace("desc:"+evt.desc);
    trace("url:" + evt.url);
}
photoflow.addEventListener ("onSelectPhoto", lis);


The evt object also represents the object that is added to the photoFlow component, for example if you add object with this line of script:

var  obj={name:"p1",url:"photo1.jpg",link:"home.html"};
Then you can retrieve the link attribute from the event object, like this:
var  lis={};
lis.onDoubleClick=function(evt){
getURL(evt.link);// open browser page to home.html
}
photoflow.addEventListener ("onDoubleClick", lis);

In the example above, the link attribute is read from the object (evt).

The following example shows how to extract the "rate" value from the image (the object):

var obj={name:"p1",url:"photo1.jpg",rate:"5"};
  photoflow.addPhoto(obj);
  var lis={};
  lis.onDoubleClick=function(evt){
  // retrieve rate attribute of photo.
  trace("this photo's rate: "+evt.rate);ลก 
}
photoflow.addEventListener(lis);

 

 


 

 

Actionscript 3 Events

Events are called whenever the photoFlow performs the specified action. When publishing for Actionscript 3 the photoFlow includes the following events:

ADD
Executed when an image is added

CLICK_SELECTED
Executed when an image becomes the selected image

INIT
Executed upon initializing the photoFlow

PHOTO_LOAD_PROGRESS
Executed whenever the load progress has changed

PHOTO_LOADED
Executed each time an image has loaded

PHOTOS_LOADED
Executed once the specified number of images has loaded

PHOTO_MOUSE_OUT
Executed when the mouse is rolled off an image

PHOTO_MOUSE_OVER
Executed when the mouse is rolled over an image

REMOVE
Executed when an image is removed

SELECT
Executed when an image becomes the current/selected image

UPDATE
Triggered when the component is updated.

 

Using events in Actionscript 3 is simpler than in Actionscript 2. The following example shows how the INIT event is called when the photoFlow is initialized:

import com.flashloaded.as3.PhotoFlowEvent;
myPhotoFlow.addEventListener(PhotoFlowEvent.INIT, initHandler);
function initHandler(evt:PhotoFlowEvent) {
trace ("photoflow initialized"); // type event action here.
}

This script imports the event class. The second line adds the listener to the component. The rest of the script defines the function that receives the event.