as you have said, you can't add a bitmap to a container, if the class doesn't implement UICompoenent. You can the bitmap to a UIComponent which can be added to a Container. Also, you can do directly draw the bitmap on the container using Graphics.beginBitmapFill(), but this creates a fair a amount of limitations on what you can (easily) do with the bitmap after it has been added so that might not be the right approach.
The documentation is correct that you can add DisplayObjects to DisplayObjectContainers, but Container overrides addChild/addChildAt so that it will only accept a UIComponents. So the documentation is correct, but a little confusing in this respect. - Dan On 11/28/06, Mark Piller <[EMAIL PROTECTED]> wrote:
Patrick, But what if "myComponent" type has to be Bitmap? How can I add it then to my container? Thanks, Mark --- In [email protected] <flexcoders%40yahoogroups.com>, {reduxdj} <[EMAIL PROTECTED]> wrote: > > Mark: > > > Instantiate a new UIComponent then try: > > import mx.controls.UIComponent; > > ... > > > var myComponent:UIComponent = new UIComponent(); > > (blah blah blah - Your code here then don't forget to add that > component to the display list) > > > addChild(myComponent); > > This should fix your problem, hope this helps, > > Patrick > > > > Mark Piller wrote: > > > > I am experiencing a difficulting adding a Bitmap to a container using > > the addChild() method. The error i get is: > > > > TypeError: Error #1034: Type Coercion failed: cannot convert > > flash.display::[EMAIL PROTECTED] to mx.core.IUIComponent. > > > > The error actually makes sense since flash.display.Bitmap does not > > implement IUIComponent, which aparently is required, since the doc for > > mx.core.Container.addChild says: > > > > "Note: While the child argument to the method is specified as of type > > DisplayObject, the argument must implement the IUIComponent interface > > to be added as a child of a container. All Flex components implement > > this interface." > > > > However, the documentation for the Bitmap class states the following: > > > > "The Bitmap() constructor allows you to create a Bitmap object that > > contains a reference to a BitmapData object. After you create a Bitmap > > object, use the addChild() or addChildAt() method of the parent > > DisplayObjectContainer instance to place the bitmap on the display list." > > > > Anyone has any idea what's going on with this? Is the documentation > > incorrect? Has anyone been able to add Bitmap to the display list? > > > > Thanks, > > Mark > > > > >

