I have a MovieClip (called "Chats") which plays when it is clicked but then I need it to navigateToURL when it has finished playing. This is as close as I have got but it doesn't work:
var chatTimer:Timer = new Timer(1000);
chats.addEventListener(MouseEvent.CLICK,startTimer);
function startTimer(event:MouseEvent):void {
chats.gotoAndPlay(2);
chats.addEventListener(TimerEvent.TIMER_COMPLETE,urlAction);
function urlAction(){
chatTimer.stop();
navigateToURL(new URLRequest("http://www.stackoverflow.com"));
}
Hope you can help! Steph
It seems you want to call navigateToURL once a movieclip has reached the final frame in its timeline. This is a lot easier if you use the totalFrames and currentFrame properties, like so:
chats.addEventListener(MouseEvent.CLICK, begin);
/**
* Begins the playing of chats
*/
function begin(e:MouseEvent):void
{
// only runs if the movieclip is on frame 1
// (can't click it multiple times)
if(chats.currentFrame == 1)
{
chats.gotoAndPlay(2);
chats.addEventListener(Event.ENTER_FRAME, _handleChats);
}
}
function _handleChats(e:Event):void
{
var m:MovieClip = MovieClip(e.target);
if(m.currentFrame == m.totalFrames)
{
m.stop();
var req:URLRequest = new URLRequest("http://stackoverflow.com/");
navigateToURL(req, "_blank");
m.removeEventListener(Event.ENTER_FRAME, _handleChats);
}
}
Hope this is what you were after!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.