簡體   English   中英

需要延遲navigationToURL Flash AS3

[英]Need to delay navigateToURL Flash AS3

我有一個MovieClip(稱為“聊天”),當單擊它時會播放,但是播放完成后需要它來導航ToURL。 這和我所得到的差不多,但是不起作用:

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"));
}

希望能對您有所幫助! 斯蒂芬

影片剪輯到達其時間軸的最后一幀后,您似乎要調用navigationToURL。 如果使用totalFrames和currentFrame屬性,則這樣會容易得多,如下所示:

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);
   }
}

希望這就是你所追求的!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM