Of course! I knew the answer was simple, man that was bugging me. Thanks Charlie.
:) _______________________________________________________________________ Joseph Balderson | http://joeflash.ca Flex & Flash Platform Developer | Abobe Certified Developer & Trainer Author, Professional Flex 3 (coming Winter 2008) Staff Writer, Community MX | http://communitymx.com/author.cfm?cid=4674 Charlie Hubbard wrote: > Right. Image is a UIComponent, and TextArea is a UIComponent. > UIComponent's can't contain other UIComponents without being a > subclass of Container or implementing the IContainer interface. Not a > simple task. > > addChild() is defined in DisplayObject which apart of the Flash API > not the Flex API. BitmapAsset is a sublcass of DisplayObject and not > UIComponent. So you can add it to the text area directly using this > code: > > var img : BitmapAsset = new imgCls() as BitmapAsset; > img.x = txtArea.mouseX; > img.y = txtArea.mouseY; > txtArea.addChild( img ); > > Now, try that out, and you'll start to see some issues that you'll > have to asess if this is going to work for what you're trying to do. > Since the bitmap is not apart of the document in the TextArea you are > going to get clipping or scrolling. If you want to do that you'll > have to get really dirty with the TextArea API. Probably even > ditching TextArea altogether and writing your own, or modifying rich > text editor. > > Charlie > > > On Thu, May 29, 2008 at 5:37 PM, aarhac <[EMAIL PROTECTED]> wrote: >> Hello, >> >> I have figured out how to work around my problem, but I do wonder why >> one of the following methods works, and the other doesn't. I would be >> grateful if someone could explain the error in the failing method. >> >> The code is pasted below (Below the line of dashes) in it's entirety, >> and is commented as to which works and which doesn't. >> >> The image referenced in this case is a 32x32 pixel png file on my >> local system. I am attempting to display the image "on" a text area. >> >> Using the default example from the flex documentation to embed an >> image, I cannot get the image to show up when added to the text area's >> display list, but it does show just fine when added to the root >> display list. I also added the image to the textArea using >> addChildAt(txtIcon, txtArea.numChildren) with no change in effect. >> >> The second method works just fine. I imagine that the problem has >> something to do with applying the image as a byte array to >> image.source, but I wonder why exactly? Is this a bug? >> >> Thanks in advance, >> >> --Aaron >> >> ------------------------------------ >> >> <?xml version="1.0" encoding="utf-8"?> >> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >> layout="absolute"> >> >> <!--Works--> >> <mx:Image id="txtIcon" source="@Embed(source='c:/icon.png')"/> >> >> <mx:TextArea id="txtArea" width="400" height="200" click="addImage()"/> >> >> <mx:Script> >> <![CDATA[ >> import mx.controls.Image; >> import mx.core.BitmapAsset; >> >> // Doesn't work >> [Embed(source="c:/icon.png")] >> [Bindable] >> public var imgCls:Class; >> >> public function addImage():void >> { >> // Doesn't work >> var loadedImg:Image = new Image(); >> loadedImg.source = new imgCls() as BitmapAsset; >> >> loadedImg.x = 10; >> loadedImg.y = 10; >> txtArea.addChild(loadedImg); >> >> // Note: While the above doesn't work, adding the >> // image to the root display list does work: >> //addChild(loadedImg); >> >> // Works >> txtIcon.x = 50; >> txtIcon.y = 10; >> txtArea.addChild(txtIcon); >> } >> ]]> >> </mx:Script> >> >> </mx:Application> >> >> > > ------------------------------------ > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Search Archives: > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links > > > >

