0
votes

someone very kindly helped me out on creating a youtube player for flash with actionscript 3, however when I test the movie it comes up with error 1083, unexpected rightbrace, which happens to be the last right brace at the end of the program. If I take away that right brace, I then receive both errors 1083 and 1084 (end of program is unexpected and expecting rightbrace before end of program. Here's the code itself:

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

If anyone can help, it would be greatly appreciated, thank you!

1

1 Answers

0
votes

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

You are not doing anything with that if statement. That is causing the problem. Either do something with it or remove it to remove the error.