0

有人非常好心地帮助我用 actionscript 3 创建了一个用于 flash 的 youtube 播放器,但是当我测试电影时,它出现了错误 1083,意外的右大括号,这恰好是程序末尾的最后一个右大括号。如果我拿走那个右大括号,我会同时收到错误 1083 和 1084(程序结束是意外的,并且在程序结束之前需要右大括号。这是代码本身:

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

如果有人可以提供帮助,将不胜感激,谢谢!

4

1 回答 1

0

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

你没有对那个if声明做任何事情。这就是问题所在。要么用它做点什么,要么将其删除以消除错误。

于 2013-08-01T23:08:49.447 回答