In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

YouTube埋め込みプレイヤーのテスト

/**
 * Copyright pekeq ( http://wonderfl.net/user/pekeq )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/4PK1
 */

// forked from pekeq's YouTubeクロムレスプレイヤーのテスト
package {
    import flash.display.Sprite;
    import flash.display.Loader;
    import flash.net.URLRequest;
    import flash.events.Event;
    import flash.system.Security;
    import flash.display.StageScaleMode;


    [SWF(width="480", height="385", backgroundColor="#802020")]

    
    public class FlashTest extends Sprite {
        private var player:Object = new Object();
        private var loader:Loader = new Loader();

        public function FlashTest() {
            // write as3 code here..
            Security.allowDomain("www.youtube.com");
            stage.scaleMode = StageScaleMode.NO_SCALE;
            loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
            loader.load(new URLRequest("http://www.youtube.com/v/XbbHBvy6GoU?version=3"));
        }

        private function onLoaderInit(event:Event):void {
        		addChild(loader);
        		loader.content.addEventListener("onReady", onPlayerReady);
        }
        
        private function onPlayerReady(event:Event):void {
        		player = loader.content;
        		player.setSize(480,385);
        		player.loadVideoById("XbbHBvy6GoU", 0, "small");
        }
        
    }
}