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_btn is an example of a button on the forum, every time you pet Creates a new example of animals So you are adding a new MouseEvent.CLICK event handler to the same my_btn example.

There are some different ways to decide this, but it depends on how you want to work. If you want a my_btn example to exist, then MouseEvent.CLICK is excluded from the Pets class (and only add it once) Add out If your own button is needed for each pet , then for a quick example of my_btn for every example of pet institute (Currently it looks like you are referring to all the pet examples of my_btn ).


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -