Copy link to clipboard
Copied
Thanks in advance for your help!
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
}
Copy link to clipboard
Copied
Your last function, onPlayerStateChange, you are starting an āifā conditional statement, but you never finish it. You need to add a pair of curly braces, ā{}ā at the end of the if statement even if you have nothing inside them. Hereās the Actionscript reference: Adobe ActionScript 3.0 * Conditionals