Hi ganaraj, i think before the creation complete of button you are trying to get the bitmap data, can u try this...
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()"> <mx:Script> <![CDATA[ import mx.controls.Label; import mx.controls.Button; import mx.core.UIComponent; private var uicomp:UIComponent = new UIComponent(); private var bmpdata:BitmapData ;//= new BitmapData(100,100,false,0xeecc00); private var btn:Button; private function init():void { this.addChild(uicomp); btn = new Button(); btn.label = "HI"; this.addChild(btn); btn.width = 200; btn.height = 22; callLater(sample); } private function sample():void{ bmpdata = getUIComponentBitmapData(btn); var bmp:Bitmap = new Bitmap(bmpdata); uicomp.addChild(bmp); bmp.x = bmp.y = 500; } private function getUIComponentBitmapData( target : UIComponent ) : BitmapData { var bd : BitmapData = new BitmapData( 100, 100); var m : Matrix = new Matrix(); bd.draw( target, m ); return bd; } ]]> </mx:Script> </mx:Application> Thanks, DineshKumar.T On Thu, Mar 5, 2009 at 12:56 PM, ganaraj p r <[email protected]> wrote: > Hi, > I am facing a very peculiar problem.. Not able to draw a Flex component to > bitmapdata.. Dont know if this only specific to me or something specific to > SDK .. > > I am assuming so far that the code is right..( is something wrong with my > flex? ) > > I am attaching the mxml here.. > > Also going to be pasting code here.. Can someone tell me if something here > is wrong? > > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > layout="absolute" creationComplete="init()"> > <mx:Script> > <![CDATA[ > import mx.controls.Label; > import mx.controls.Button; > import mx.core.UIComponent; > private var uicomp:UIComponent = new UIComponent(); > private var bmpdata:BitmapData ;//= new > BitmapData(100,100,false,0xeecc00); > private var btn:Button; > private function init():void > { > this.addChild(uicomp); > btn = new Button(); > btn.label = "HI"; > this.addChild(btn); > btn.width = 200; > btn.height = 22; > bmpdata = getUIComponentBitmapData(btn); > var bmp:Bitmap = new Bitmap(bmpdata); > uicomp.addChild(bmp); > bmp.x = bmp.y = 200; > } > private function getUIComponentBitmapData( target : UIComponent ) : > BitmapData > { > var bd : BitmapData = new BitmapData( 100, 100); > var m : Matrix = new Matrix(); > bd.draw( target, m ); > return bd; > } > ]]> > </mx:Script> > </mx:Application> > > > -- > Regards, > Ganaraj P R > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Flex India Community" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/flex_india?hl=en -~----------~----~----~----~------~----~------~--~---

