Reputation: 68
i'm trying to embed a swf to my as3 flex project like this:
[Embed(source = "../assets/next_button.swf")]
[Bindable]
protected var nextButtonClass:Class;
protected var next_btn:MovieClip = next_btn = new nextButtonClass() as MovieClip;
// ...
next_btn.addEventListener(MouseEvent.CLICK, onAdChange);
next_button.swf is as2 and created with adobe flash cs4. there is a single button inside it.
if i change type of button symbol to movieclip at next_button.fla, there is no problem at passing CLICK event.
i tried to cast next_btn to mx.controls.Button and fl.controls.Button classes, next_btn is becoming null in that case.
by the way button is reacting mouseover and click events properly just doesn't pass it to upper swf.
is there any trick i can do to pass Button events to my container swf?
Upvotes: 1
Views: 864
Reputation: 68
to summarize, after the solution grapefrukt suggested, code looks like this:
[Embed(source = "../assets/next_button.swf", symbol="next_button")]
[Bindable]
protected var nextButtonClass:Class;
protected var next_btn:DisplayObject = new nextButtonClass() as DisplayObject;
// ...
next_btn.addEventListener(MouseEvent.CLICK, onAdChange);
Upvotes: 1
Reputation: 27045
Try embedding and instancing the symbol from inside the swf, not the entire swf:
[Embed(source = "../assets/next_button.swf", symbol"MyButton")]
You will obviously need to replace MyButton
with the actual symbol name of the button.
That should give you more direct access to it, since it won't be wrapped by a Loader
.
Upvotes: 0
Reputation: 9572
I don't think it is possible for an As3 script to access properties of an AS2 SWF. If you have access to the fla, why not change the button fla into an AS3 project?
Upvotes: 0