I'm using the YouTube embed API (https://developers.google.com/youtub..._api_reference) to stream a YouTube clip inside a swf file. I have put a transparent button directly into the stage but once the YouTube clip is loaded, it keeps appearing over the button.
How can I change the layer order so that the button always stays at the top?
Here is my AS3 code to embed the YouTube clip…
Thanks very much,Code:// This will hold the API player instance once it is initialized. var player:Object; var loader:Loader = new Loader(); var context:LoaderContext = new LoaderContext(); context.checkPolicyFile = true; context.securityDomain = SecurityDomain.currentDomain; context.applicationDomain = ApplicationDomain.currentDomain; loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit); Security.allowDomain("www.youtube.com") loader.load(new URLRequest("http://www.youtube.com/v/Z3wnzmJBCDo?version=3&rel=0&autoplay=1&controls=1&showinfo=0&modestbranding=1")); function onLoaderInit(event:Event):void { addChild(loader); loader.content.addEventListener("onReady", onPlayerReady); loader.content.addEventListener("onError", onPlayerError); loader.content.addEventListener("onStateChange", onPlayerStateChange); loader.content.addEventListener("onPlaybackQualityChange", onVideoPlaybackQualityChange); } function onPlayerReady(event:Event):void { // Event.data contains the event parameter, which is the Player API ID trace("player ready:", Object(event).data); // Once this event has been dispatched by the player, we can use // cueVideoById, loadVideoById, cueVideoByUrl and loadVideoByUrl // to load a particular YouTube video. player = loader.content; // Set appropriate player dimensions for your application player.setSize(300, 250); } function onPlayerError(event:Event):void { // Event.data contains the event parameter, which is the error code trace("player error:", Object(event).data); } function onPlayerStateChange(event:Event):void { // Event.data contains the event parameter, which is the new player state trace("player state:", Object(event).data); } function onVideoPlaybackQualityChange(event:Event):void { // Event.data contains the event parameter, which is the new video quality trace("video quality:", Object(event).data); }
James




Reply With Quote
