-
Call a function
I have this actionscript that is set to a Mouse Event to flip an image over, but I want to flip it like at 10seconds, regardless if a mouse event happened. I have tried many ways.. How do I call "cardDown" in like 10 seconds, but leave the MouseEvent there too... Any help would be appreciated.
Here is the code:
-----------------------------------------------------------------
import com.greensock.TimelineLite;
import com.greensock.TweenLite;
import com.greensock.easing.*;
card.z = 5;
card.getChildAt(0).visible = false;
card.getChildAt(0).rotationY = 180;
card.addEventListener(MouseEvent.MOUSE_DOWN,cardDo wn);
function cardDown(e){
trace("Tick");
flipSelf(e.currentTarget);
}
function flipSelf(self){
var toRot;
if(self.rotationY > 89){
toRot = 0;
}else{
toRot = 180;
}
var timeline = new TimelineLite();
timeline.insert(TweenLite.to(self,0.5,{z:5,ease:Ba ck.easeOut }));
timeline.insert(TweenLite.to(self,1.5,{rotationY:t oRot,ease:Strong.easeInOut,onUpdate:setFlipSide, onUpdateParams:[self] }));
timeline.insert(TweenLite.to(self,0.5,{z:5,ease:Ba ck.easeIn }),0.75);
}
function setFlipSide(self){
if(self.rotationY > 89){
card.getChildAt(1).visible = false;
card.getChildAt(0).visible = true;
}else{
card.getChildAt(0).visible = false;
card.getChildAt(1).visible = true;
}
}
-
Code:
var interv = setInterval(cardDown, 10000);
This will trigger the function every 10 seconds. If you want it to stop calling, use this:
Code:
clearInterval(interv);
-
Another way is to use the delayedCall property which does the same as above.
Actionscript Code:
TweenLite.delayedCall(10, cardDown);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|