flash - Clear Class ( new ClassName() ) -
Question: What's behind the var animals: Pets = new pets (); ??
Script:
package {import flash.events.MouseEvent; PublicClick Pets {Public Function Pets () {// Constructor Code on my_btn.addEventListener (MouseEvent.CLICK, onClick)} onClick (e: MouseEvent) {trace (start); }}} Problem: When I call pet classes with second class (new pet); , This class runs and addEventListener works fine but:
First time: trace result
start
second time: Trace Results
Start
Start
Third Time: Detecting Result
Start
Start
Assume
my_btnis an example of a button on the forum, every time youpet Creates a new example of animalsSo you are adding a newMouseEvent.CLICKevent handler to the samemy_btnexample.There are some different ways to decide this, but it depends on how you want to work. If you want a
my_btnexample to exist, thenMouseEvent.CLICKis excluded from thePetsclass (and only add it once) Add out If your own button is needed for eachpet, then for a quick example ofmy_btnfor every example ofpetinstitute (Currently it looks like you are referring to all thepet examples ofmy_btn).
Comments
Post a Comment