views:

33

answers:

1

Canvas.addChild() insists any DisplayObject added implements IUIComponent. But I don't want my core graphics engine dependent on Flex. Is there an obvious/common way around this, to have simple graphical objects like Sprites & Shapes in a Flex application? The individual DisplayObject children I want to add as children represent objects in a game world, like a spaceship or a missile or a horse...

Not sure if Canvas is the most appropriate container, perhaps Group or another class is optimal for a game-engine... example MXML & AS3 code showing a skeleton setup is most welcome. I'm targeting Flex4 & Flash 10, but Flex3/Flash9 solutions are still of interest.

A: 

Instead of canvas, you can use UIComponent as it does not have the IUIComponent implementor requirement. Then addChild() your sprites to that.

Rhysyngsun
That's what I'm trying to _avoid_, making all my objects `UIComponent`. Or are you suggesting something else?
John
Sorry, I'll clarify the answer.
Rhysyngsun
OK, I see. I can have an inner container the same size as the main MXML, for instance. In Flex4 I want to use `Group` rather than canvas... but the idea is the same.
John