dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Newbie AS 3 Question (Capturing Menu Click/How to call back from class event listene)

  1. #1
    Junior Member
    Join Date
    Mar 2007
    Posts
    21

    Newbie AS 3 Question (Capturing Menu Click/How to call back from class event listene)

    Hello,

    I have recently started learning actionscript 3, and I think this is just some concept I am not understanding.

    I found a class for a menu that I am using, basically I want to attach a Movie Clip to the stage when a menu button is hit, but I am stuck on how to do this. Basically I have this in my main timeline:

    import menuexample.BasicMenu;
    import movieClipTest.movieClipTest;
    var myMenu:BasicMenu = new BasicMenu();
    myMenu.init();
    myMenu.x = 50;
    myMenu.y = 100;
    addChild(myMenu);

    var myClip:movieClipTest = new movieClipTest();
    myClip.init();

    // now how do I add it to the stage when a button is hit in the menu?


    I have this in my BasicMenu class:

    private function displayMessage(event:MouseEvent):void {

    // Output the name of the clicked button.
    trace(event.currentTarget.name);
    }

    Which traces the text (which is set to the button name) to the output window.

    Can I do any kind of call back function? I know AS3 is trying to get away from this.

    Thanks in advandce

  2. #2
    Junior Member
    Join Date
    Mar 2007
    Posts
    21
    Never mind, I figured it out. I just set a click event listener and used a public variable inside of the class to get the value of the button that was pressed. I don't know why I didn't think of that before.

  3. #3
    Junior Member
    Join Date
    Apr 2002
    Posts
    23
    Is there any way that you could post your solution? It would help us S00perNoobs alot!

    thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center