PDA

View Full Version : Calling a function


ThickGraphics
10-10-2010, 11:30 PM
Simple question, how do I call the slideShow function?

import com.greensock.*;
import com.greensock.easing.*;

var austin:Symbol1 = new Symbol1();
var champoy:Symbol2 = new Symbol2();
var group:Symbol3 = new Symbol3();
var hollow:Symbol4 = new Symbol4();
var MyArray:Array = [austin,champoy,group,hollow];

function slideShow(e:Event):void{
for (var i:Number = 0; i < MyArray.length; i++) {
MyArray[i].x = stage.stageWidth/2;
MyArray[i].y = 200;
MyArray[i].alpha = 0;
addChild(MyArray[i]);
TweenLite.to(MyArray[i], 1, {alpha:1, delay:2 * i, ease:Strong.easeOut});
}
}

function replay():void {
var replay:Symbol5 = new Symbol5();
replay.alpha = 0;
replay.x = stage.stageWidth/2;
replay.y = 250;
replay.addEventListener(MouseEvent.CLICK, slideShow)
TweenLite.to(replay, 1, {alpha:1, ease:Strong.easeOut});
addChild(replay);
}

slideShow(e:Event);

not sure why this isn't working:confused:

ofranko
10-11-2010, 01:22 PM
yourButton.addEventListener(MouseEvent.CLICK, slideShow);

Rada
10-12-2010, 06:53 PM
the function you have
function slideShow(e:Event)...
e:Event means that it's expecting to respond to an Event.

If you want to run the slideshow function without dispatching an event you can just pass null to the function
slideShow(null)

if you use ofranko's solution above, because its responding to a MouseEvent, you'd need to change the function to be
function slideShow(e:MouseEvent)...