Translate

> > Flex change Image source dynamically by coding

Flex change Image source dynamically by coding

Posted on Tuesday, September 20, 2011 | No Comments

private function loadImages():void
        {
           
            var source:String  = "your dynamic image path";
            var loader:Loader = new Loader();
            var request:URLRequest = new URLRequest(pageSource);
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadCompleteHandler);
            loader.load(request);
        }


private function loadCompleteHandler(e:Event):void
        {
          
            var bitmapData:BitmapData = e.target.content.bitmapData as BitmapData;
            var bitmap:Bitmap = new Bitmap(bitmapData)

            image0.source = bitmap; // where image0 is your mxml file control
            image0.validateNow();
      }

Leave a Reply

Powered by Blogger.