Hi, I've been following this thread with interest since I was having the exact same problem as Jason. Instead of a Sprite, though, I'd like to be able to load an image into a MovieClip, which would then be loaded into a UIComponent so it can be displayed inside a Panel. I suspect it shouldn't be much different than using a Sprite, since MovieClip extends Sprite. Here's the relevant mxml:
<mx:Panel id="parentComponent" layout="vertical" height="500" width="500" backgroundColor="0x0000FF"> <dow:DisplayObjectWrapper id="wrapper" height="100" width="100"> <MyComp:MyMovieClip id="myMovie" height="100" width="100"/> </dow:DisplayObjectWrapper> </mx:Panel> Now, MyMovieClip is a custom class extending MovieClip: package myComponents { import flash.display.MovieClip; import mx.core.UIComponent; import mx.controls.Image; public class MyMovieClip extends MovieClip { public function MyMovieClip() { super(); var image1:Image = new Image(); image1.source = "../pics/batman.jpg"; image1.setActualSize(100,100); this.addChild(image1); this.scaleX=1.0; this.scaleY=1.0; this.height = 100; this.width = 100; //just to see if I can set any properties this.x = 2; this.y = 2; graphics.beginFill(0x000000); graphics.drawRect(20,20,50,50); graphics.endFill(); //prints 0, as expected trace("ChildIndex of image in MyMovieClip:"+this.getChildIndex(image1).toString()); } } } When I put breakpoints in here, the 'x' and 'y' properties are appropriately changed to 2, and the graphics display just fine, but 'height' and 'width' both remain at 0, even after the statements to set them. The DisplayObjectWrapper class is a custom extension of UIComponent that I found on another forum which is specifically designed to assist in adding DisplayObjects to UIComponents. (http://www.gskinner.com/blog/archives/2007/03/displayobjectwr.html) As per Amy's post, >Second, you need to explicitly give it a size. I think the >conventional method for doing this is to call setActualSize() on the >child image. I think the conventional place to do this is >updateDisplayList(), though I'm no whiz kid and I could be wrong. I checked to see that DisplayObjectWrapper had measure() and updateDisplayList() methods; it did not have an updateDisplayList() method, so I cobbled one up. It's a little ugly, because the children of this DisplayObjectWrapper will be MovieClips, and so I can't call the setActualSize() method on them; instead, just to see if I could get it working, I explicitly set the height and width to be the same of the parent DisplayObjectWrapper: override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth, unscaledHeight); //set actual size of all children for (var i:int = 0; i < numChildren; i++) { //set width and height of every child to that of the full UIComponent DisplayObject(getChildAt(i)).width=unscaledWidth; DisplayObject(getChildAt(i)).height=unscaledHeight; } } So, the graphics in the MovieClip display correctly, and the image displays with no problem when loaded directly into the Panel, but it still seems that the MovieClip is of size 0 and of course no Image can be seen inside it. Any insight would be much appreciated. --Steve -- View this message in context: http://www.nabble.com/problem-adding-images-to-UIComponents-using-AS3-tp18762698p18805059.html Sent from the FlexCoders mailing list archive at Nabble.com.