2013-08-01 82 views
0

有人非常好心地幫助我創建一個Flash動畫3的YouTube播放器,但是當我測試電影時出現錯誤1083,意外的右擊,這恰好是最後一個右括號程序結束。如果我帶走右括號,然後我收到兩個錯誤1083和1084(程序結束是意外和程序結束前rightbrace期待下面的代碼本身。語法錯誤1083 actionscript 3

import flash.system.Security; 

Security.allowDomain('*'); 
Security.allowInsecureDomain('*'); 

var vPlayer:Object; 
var playerLoader:Loader; 

function loadVideo():void 
{ 
    playerLoader = new Loader(); 

    // next line loads a youtube player with no UI 
    playerLoader.load(new URLRequest('http://www.youtube.com/apiplayer?version=3')); 

    // wait for it to load 
    playerLoader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit); 
} 

function onLoaderInit(evt:Event):void 
{ 
    // 'vPlayer_container' is a movieclip on stage same size as video player you need. 
    // add your youtube Loader, (which is actually the player), to vPlayer_container's display list. 
    vPlayer_container.addChild(playerLoader); 

    // set the vPlayer variable to be the loaded youtube player 
    vPlayer = playerLoader.content; 

    // wait for it to be ready 
    vPlayer.addEventListener('onReady', onPlayerReady); 
} 

function onPlayerReady(evt:Event):void 
{ 
    vPlayer.removeEventListener('onReady', onPlayerReady); 

    // set listener for onComplete and play/pause events 
    vPlayer.addEventListener('onStateChange', onPlayerStateChange); 

    // mute it on start if you want 
    vPlayer.mute(); 

    // set size of video screen 
    vPlayer.setSize(392,220); 

    // now load your youtube video in your new youtube player 
    // get this video number off the url to your youtube video 
    vPlayer.loadVideoById('GEghz32qhiA', 0); 
} 

function onPlayerStateChange(evt:Event):void 
{ 
    // if video is over 
    if(Object(evt).data == 0) //do something when video is over 
} 

// other player commands available - you need to make your own buttons for these 
// vPlayer.mute(); 
// vPlayer.unMute(); 
// vPlayer.pauseVideo(); 
// vPlayer.playVideo(); 

如果有人可以幫助,這將是不勝感激,謝謝!

回答

0

if(Object(evt).data == 0)

你不這樣做與if聲明任何東西,這是造成問題。無論是用它做什麼或刪除其刪除錯誤。