Quote:
Originally Posted by As2John
Hi,
Does anyone know how to access a button in a movieClip that is loaded into Window component? I tried following but it does not work.
|
Hi John,
There are two things you must correct for the button to work. First, when targeting the window content, you
don't need to include the target movieclip as well. You wrote:
Code:
my_win.content.aa.b_btn.onRelease
instead you should use:
Code:
my_win.content.b_btn.onRelease
Also, put the onRelease function into the complete function so that you can be sure the button is loaded (and can be targeted) when you click it. The working code looks like this:
Code:
import mx.managers.PopUpManager;
import mx.containers.Window;
var my_win:MovieClip = PopUpManager.createPopUp(this, Window, true, {closeButton:true, contentPath:"aa"});
var winListener:Object = new Object();
winListener.complete = function(evt_obj:Object) {
my_win.setSize(my_win.content._width+50, my_win.content._height+50);
my_win.content.b_btn.onRelease = function() {
trace("Button pressed");
}
};
my_win.addEventListener("complete", winListener);