package { import flash.display.*; import flash.events.*; public class actionscript_embed_ClassLevelEmbedDemo extends Sprite { public function actionscript_embed_ClassLevelEmbedDemo () { // Class-level bitmap var photo:actionscript_embed_Photo = new actionscript_embed_Photo(); addChild(photo); // Class-level SVG var svgline:actionscript_embed_SVGLine = new actionscript_embed_SVGLine(); addChild(svgline); // Class-level FP8 .swf symbol var fp8ball:actionscript_embed_FP8Ball = new actionscript_embed_FP8Ball(); addChild(fp8ball); // Class-level binary data (FP9 .swf) var fp9binarydata:actionscript_embed_FP9BinaryData = new actionscript_embed_FP9BinaryData(); var loader:Loader = new Loader(); loader.loadBytes(fp9binarydata); addChild(loader); // Wait for the embedded .swf file to initialize loader.contentLoaderInfo.addEventListener(Event.INIT, initListener); } private function initListener (e:Event):void { // Obtain a reference to the Ball symbol from the embedded .swf file var BallSymbol:Class = Object(e.target.content).loaderInfo.applicationDomain.getDefinition("Ball"); // Make a new instance of the Ball symbol var ball:MovieClip = MovieClip(new BallSymbol()); // Position the Ball instance and place it on screen ball.x = 200; ball.y = 230; addChild(ball); } } }