tags:

views:

30

answers:

3

I am embedding a flash file in my flex file and then trying to add it to the stage. IU try addChild to a canvas element and to a container element, but it keeps giving me the error, the symbol "myBtn" is cannot be converted to a IUIcomponent.

I understand that I need to place everything inside some sort of component, but what is the proper way to do this in flex?

A: 

Look here for info on Embedding swf files and embedding swf symbols.

www.Flextras.com
I guess what I am trying to do is use flex as a wrapper and then just use actionscript and flash the way i normally would inside of a container or canvas component. But it doesn't look like there is an easy way to do this.
pfunc
A: 

I figured it out thanks to this post: http://craiggrummitt.blogspot.com/2007/11/how-to-add-children-in-flex.html

you use something called rawChildren. so I would do myComponent.rawChildren.addChild('mymc');

pfunc
A: 

Adding to rawChildren isn't the way to go here. Containers ignore rawChildren when doing things such as layout, measurement, etc.

Instead, simply wrap it in a UIComponent:

[Embed(source="...")]
public var someSwf:Class;

public function addSwf():void
{
    var swf:Sprite = new someSwf();
    var wrapper:UIComponent = new UIComponent();
    wrapper.addChild(swf);
    this.addChild(wrapper);
}
Marty Pitt
thanks, I just figured out after my last comment that i couldn't actually use anything in the rawChildren. This works better.
pfunc