Chapter 16 Example 1

by actionscriptbible
♥0 | Line 30 | Modified 2009-12-16 19:48:16 | MIT License
play

ActionScript3 source code

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

package {
  import com.actionscriptbible.Example;
  
  import flash.display.DisplayObject;
  import flash.display.Loader;
  import flash.events.Event;
  import flash.net.URLRequest;
  import flash.system.ApplicationDomain;
  import flash.system.LoaderContext;

  public class ch16ex1 extends Example {
    protected var loader:Loader;
    public function ch16ex1() {
      trace("Loading assets...");
      loader = new Loader();
      loader.load(new URLRequest("http://actionscriptbible.com/files/ch16assets.swf"),
        new LoaderContext(true));
    }
    protected function onLoad(event:Event):void {
      try {
        var assetsDomain:ApplicationDomain = loader.contentLoaderInfo.applicationDomain;
        var FishingCatClass:Class = Class(assetsDomain.getDefinition("assets.FishingCat"));
        var cat:DisplayObject = new FishingCatClass();
        cat.y = 100;
        addChild(cat);
        trace("added fishing cat!");
      } catch (error:Error) {
        trace(error);
      }
    }
  }
}