0

I have the following code and I followed the answer from this question, but it doesn't seem to be working for me. I'm not getting an error or getting a trace response.

Basically I need to access this test_mc inside the added child. Am I doing something wrong?

for (var i:int=0; i<30; i++) {
    var mc:panelClass = new panelClass();
    all_mc.addChild(mc);
    mc.x = allWidth * i;

    // Accessing the test mc
    mc.test_mc.addEventListener(MouseEvent.CLICK, ctaOnClickHandler);

}
function ctaOnClickHandler(e:MouseEvent) {
    trace("Clicked");
}
Community
  • 1
  • 1
muudless
  • 7,422
  • 7
  • 39
  • 57
  • Try this within the loop and see if it works (under the addEventListener or something):: trace(mc.test_mc); – Marty Sep 22 '11 at 03:44
  • have you assign instance name for test_mc inside panelClass in property panel ???????? – hardik Sep 22 '11 at 06:37

1 Answers1

0

Kind of hard to answer this without know what panelClass is and how it is built. I'm assuming test_mc is a movieclip that's using all it's default properties and is on the display list of panelClass and since there are no errors it's been instantiated. The only think I can think of is there anything being displayed on top of test_mc inside panelClass?

toad013
  • 1,350
  • 9
  • 10
  • Hi toad013, panelClass is a movieClip with some text mcs and image mcs inside. test_mc is a button mc inside the panelClass, and it is at the very top inside panelClass. Hope that helps with the confusion? – muudless Sep 22 '11 at 03:29
  • just to clarify. the problem is the ctaOnClickHandler is not being executed correct? – toad013 Sep 22 '11 at 20:36