views:

46

answers:

1

Say I make a class that extends the movieclip class and this class has a number of buttons in it. This movie clip exists in an .fla and is linked to the class definition. How can I control the events from within the class? The following does not work:

class newMovie extends MovieClip {
   var test_btn:Button;
   function newMovie() {
   }
   function test_btn.onRelease() {
       trace("Button pressed");
   }
}
+1  A: 

Try doing this,

import mx.utils.Delegate;
class newMovie extends MovieClip {
    var test_btn:Button;
    function newMovie() {
        test_btn.onRelease = Delegate.create(this, onButtonRelease);
    }
    function onButtonRelease() {
        trace("Button pressed");
    }
}
Chris Gutierrez
Works like a charm! Thanks, Chris!
Everett