This content has been marked as final. Show 9 replies
are you getting errors on nothing is shown?
also should not you do endFill after beginFill?
I get the red box that is produced by MyShape.as, but the green box that is supposed to be generated by Square.mxml does not show. I added the endFill, but it didn't make a difference.
endFill is called automatically when using drawRect, eclipse and roundRect
It appears that the problem is caused by using a Sprite. As soon as I changed to a Canvas the problem went away. I don't understand why I can't use a Sprite-- can anyone explain? Presumably if I need to use a sprite I could place one on the canvas??
yeas I forgot about that, as I recall , Sprite can not (directly) be used within hierarchy of DisplayList Objects ..
Note (Sprite): 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.
also this : http://userflex.wordpress.com/2008/06/12/sprite-uicomponent/
"SiHoop" <email@example.com> wrote in message
> It appears that the problem is caused by using a Sprite. As soon as I
> to a Canvas the problem went away. I don't understand why I can't use a
> Sprite-- can anyone explain? Presumably if I need to use a sprite I could
> one on the canvas??
No, container children must implement IUICompnent. It would have worked if
you'd used UIComponent instead of Canvas or Sprite.
"levancho" <firstname.lastname@example.org> wrote in message
> yeas I forgot about that, as I recall , Sprite can not be used within
> hierarchy of DisplayList Objects
It can, in one of two ways.
(1) Extend Sprite, and implement IUIComponent.
(2) It can be a cbild of UIComponent.
I think you can also use rawChildren().addChild(sprite) if you want to stay with using a Sprite. I have certainly done this with things like image loaders.
Best is to wrap the Sprite in a UIComponent:
var mySprite:Sprite = new Sprite();
var uic:UIComponent = new UIComponent();