通过greensock 的MaxLoader 获取外部swf的图片!

 

通过greensock 的MaxLoader 获取外部swf的图片!

 

package  {

    

    import com.greensock.loading.data.ImageLoaderVars;

    import com.greensock.loading.display.ContentDisplay;

    import com.greensock.loading.ImageLoader;

    import flash.display.Bitmap;

    import flash.display.BitmapData;

    import flash.display.Sprite;

    import flash.system.ApplicationDomain;

    import flash.system.LoaderContext;

    import flash.utils.getDefinitionByName;

    

    import com.greensock.events.LoaderEvent;

    import com.greensock.loading.LoaderMax;

    import com.greensock.loading.SWFLoader;

    

    import com.greensock.TweenLite;

    

    

    

    public class Main extends Sprite {

        

        

        public function Main() {

            // constructor code

            

            trace('this is use swf...');

            

            

            loadingSwf();

            

            

        }

        

        

        

        private var queue:LoaderMax;

        

        private function loadingSwf():void {

            

            trace('loadingSwf...');

            

            queue = new LoaderMax( { 

                

                name:'initStage',

                requireWithRoot:root,

                

                onProgress:onProgressHander,

                onComplete:onCompleteHandler,

                onError:onErrorHander

            } );

            

            queue.maxConnections = 10;//最大线程

            

            //queue.append(new SWFLoader('swf/initStage1.swf',{name:'InitStage1',estimatedBytes:1457520 }));

            queue.append(new SWFLoader('swf/initStage2.swf',{name:'InitStage2',estimatedBytes:1457520 }));

            queue.append(new ImageLoader('swf/pic1.jpg', { name:'pic1', estimatedBytes:2400, x:100,y:0, height:400, width:200, container:this, alpha:0.5,  scaleMode:"proportionalInside" } ));

            queue.load();

            

            

            

        }

        

        

        private function onProgressHander(e:LoaderEvent):void {

            

            //trace('InitStage.swf :: onProgress');

            trace('_>'+e.target.progress + '<___' +e.toString());

        }

            

        private function onCompleteHandler(e:LoaderEvent):void {

            

            trace('InitStage.swf :: onComplete');

            trace('_>' + e.target.progress + '<___' +e.toString());

            

            var image:ContentDisplay = LoaderMax.getContent('pic1');

            TweenLite.to(image, 6, { alpha:1, y:100 } );

            

            trace('pic1 :: onComplete');

            

            var context:SWFLoader = LoaderMax.getLoader('InitStage2');

            

            var oil:Class = context.getClass('icon_oil');

            trace('oil__'+ typeof oil);

            var oilbmd:BitmapData = new oil(0, 0) as BitmapData;

            var oilbmp:Bitmap = new Bitmap(oilbmd);

            oilbmp.x = 350;

            oilbmp.y = 260;

             

            var cls:Class =  context.getClass('icon_new');

            var bmd:BitmapData = new cls(50, 100) as BitmapData;

            var bmp:Bitmap = new Bitmap(bmd);

            bmp.x = 150;

            bmp.y = 200;

            addChild(bmp);//*/

             

            addChild(oilbmp);

            

            

        }

            

        private function onErrorHander(e:LoaderEvent):void {

            

            trace('InitStage.swf :: onError');

            trace(e.toString());

        }

        

        

        

        

        

        

        

    }

    

}

你可能感兴趣的:(loader)