Reputation: 747
I create a action in a frame for 2 purposes: 1. add a clickTag 2. stop the animation after 5 seconds.
The clickTAG is working but not the stop after 5 seconds and I don't understand why
on (release) {
if (_root.clickTAG.substr(0,5) == "http:") {
getURL(_root.clickTAG, "_blank");
}
};
var myTimer:Timer = new Timer(5000, 1);
myTimer.start();
myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, function(e:TimerEvent){
stop();
});
Any advice?
Upvotes: 1
Views: 4712
Reputation: 1985
ugh.. there is so much wrong with the provided code i don't know where to start. first of all, you are mixing as2 with as3
the on(...)
on the movieclip is allowed in actionscript 2 only, while the timer class is as3.
another huge mixup is that you are placing the on(...)
handler on a movie itself (the movie is selected and the code is placed on it)- this is ok. what's not ok is that you can not place regular code- meaning the timer- on a movieclip. such things must be placed on a frame (click on a frame and edit actionscript then). and even then the timer wouldn't work as it's actionscrtip3 class.
considering the fact that your "clicktag" is working it means that you are probably running as2.
as i already said, there is no native timer class in as2. you must use setTimeout. note that setTimeout, like most of regular actionscript, must be placed on a frame, not a movieclip. and example of a setTimeout:
setTimeout( function(){
stop();
},5000); //5000 is amount of miliseconds
... by the way... google ads should be stopped after 30 seconds, not 5 seconds.
Upvotes: 3