iso中应用外部资源

//s0.sprites = [treeTrunkClass];  将外部资源添加进isoSprite中  -------主要是测试代码 

可以结合这个看:http://code.google.com/p/as3isolib/wiki/as3isolib_tutorial_004

package 
{
        import as3isolib.display.IsoSprite;
        import as3isolib.display.primitive.IsoBox;
        import as3isolib.display.scene.IsoGrid;
        import as3isolib.display.scene.IsoScene;
        
        import flash.display.Loader;
        import flash.display.*;
        import flash.events.Event;
        import flash.net.URLRequest;
        
        public class IsoApplication extends Sprite
        {
                private var scene:IsoScene;
                private var assets:Object;
                
                private var loader:Loader
                
                private function loadAssets ():void
                {
                        loader = new Loader();
                        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loader_initHandler);
                        loader.load(new URLRequest("swf/assets.swf"));
                        
                }
                
                private function loader_initHandler (e:Event):void
                {
             
              
                        scene = new IsoScene();
                        scene.hostContainer = this; //it is recommended to use an IsoView
                        
                       // var treeTrunkClass:Class = loader.contentLoaderInfo.applicationDomain.getDefinition("TreeTrunk") as Class;
//                        var treeLeavesClass:Class = loader.contentLoaderInfo.applicationDomain.getDefinition("TreeLeaves") as Class;
     
     
      var mc:MovieClip=MovieClip (e.target.content);
      var treeTrunkClass:*=mc.getTrunk();
      var treeLeavesClass:*=mc.getLeaves()
      //var treeTrunkClass:MovieClip=MovieClip(e.target.content.getTrunk());//这得到的是swf的资源---- 图片(我在资源swf中通过getTrunk() {  return new Trunk() }  来返回资源)
//      var treeLeavesClass:MovieClip=MovieClip(loader.contentLoaderInfo.content.getLeaves());
     
                        
                        var grid:IsoGrid = new IsoGrid();
                        grid.showOrigin = false;
                        scene.addChild(grid);
                        
                        var s0:IsoSprite = new IsoSprite();
                        s0.setSize(25, 25, 65);
                        s0.moveTo(50, 50, 0);
                        s0.sprites = [treeTrunkClass]; //添加到so中
                        scene.addChild(s0);
                        
                        var s1:IsoSprite = new IsoSprite();
                        s1.setSize(125, 125, 100);
                        s1.moveTo(0, 0, 200);
                        s1.sprites = [treeLeavesClass];
                        scene.addChild(s1);
                        
                        scene.render();
                }
                
                public function IsoApplication ()
                {
                        loadAssets();
                }
        }
}

posted @ 2011-05-30 16:55  zhych  阅读(260)  评论(0编辑  收藏  举报