Have misunderstanding with addEventListener
Hello!
I have an asset that is a normal MovieClip and I want to add an event listener.
Event handler, however, will be a method of a generic class that is not extended to any of the AS3 classes.
So I have a code like this:
class Foo {}
public void Foo(asset:MovieClip) {}
asset.addEventListener (MouseEvent.CLICK, this.handle_click, false, 0, true); the use of weak references
}
private void handle_click(e:MouseEvent) {}
trace ("Click!");
}
}
It compiles well but the listener does not at all. Once I change the Foo class be extended form or Sprite, the listener magically begin to operate.
Also, when I do not use the weak reference, it also starts to work.
I don't understand why. The problem could be that active object gets garbage-collected so the event listener is destroyed, but this isn't the case, the asset continues to exist on the screen.
OK I got it. The asset was not garbage collected, but the instance of class Foo has been, higher, while it was hard to notice several levels.
To prevent garbage collection only keeping not references external for all instances, you can just make a reference within an instance itself, similar to this:
(not saying it's better or anything useful at all, just a casual employee to find who might have some implementatons)
class Foo() {}
class GC protected before you call unlock()
private var: locking function.
public void Foo() {}
This.Lock = this.unlock;
}
private function unlock() {}
This.Lock = null;
}
}
Tags: Adobe Animate
Similar Questions
-
I have problem with wifi iphone 6 s not connected...
I have problem with iphone 6s more wifi not connected...
I'm having the same problem and tried all the fixes I found online and nothing has worked so far.
-
Hello I have problem with my site, and mozilla. Google chrome, safari, explorer, opera work ok. I have Sobipro for both the company and the logos and images without work!
When I try to open the url is this:http://www.athens-dayandnight.gr/images/sobipro/entries/288/587_img.jpgwhith mozilla is the following: /images/sobipro/entries\288\587_img.jpg when ichange it------with this / work.
any idea?
Thank you
Hello, the URLS that contain-in their path are not valid. Firefox is less tolerant to errors in this respect than other browsers.
Correct the path to http://www.athens-dayandnight.gr/images/sobipro/entries/288/587_img.jpg in the source code of this site or if you don't control the contact of the site their webadmin to do... -
I have problems with my Apple ID when you download applications, that it is said that your ID Apple has not yet been used in the iTunes Store
What exactly is the problem? You are also being invited to review the account and enter payment details? If you did you are your details accepted - if they are, you should be able to remove them then.
-
I have no sound in YouTube with FF. I have audio with Internet Explorer.
When I try to play a music or any other video on You Tube or on several other web sites, I have video, but no sound. I can play audio files on my computer, and I can hear the sound when I use Internet Explorer.
I went on You Tube and has opened a video.
At the bottom of the video window there is a speaker icon. The audio was muted. I clicked on the icon which canceled the muting, and now I have audio with You Tube. Bob
-
have problems with hardware acceleration of rendering: fonts looks terrible
have problems with hardware acceleration of rendering (integrated gpu: amd 760 g) of one of the latest nightly updates - police seem terrible http://i.imgur.com/kWnySVv.png
Note that the gfx.content.azure.enabled pref has more effect and you can try to disable Direct2D by setting the pref gfx.direct2d.disabled true on the subject: config page and leave hardware acceleration enabled otherwise.
See also commentary 414 in bug 812695:
This way you still have the advantage of hardware acceleration, but can not suffer rendering problems.
-
Why my iphone will have problems with pandora in synchronization with the pandora application on infotainment chevy via a usb connection?
This was never resolved? I have the same problem with an iphone 6s. It is only my phone like an ipod playback. I don't get the interface of Pandora.
-
Up to version 6.22 of entry and other components HTML texts have been with a width. Now, after installing version 7. The entries have increased in size not more about before defined sizes... You can fix this?
I think it's about the size, just differently than before. See the discussion in:
https://Bugzilla.Mozilla.org/show_bug.cgi?id=691157 -
Hello. I'm just a beginner and I downloaded the itunes 12.3.3 update and now when I right click on a work of art albums all disappear from the track of this album. I also have problems with my get info tab. All of my info from the album crashes.
This can help (from turingtest2):
-
I have problem with my lphone6s when I want to download or go online or on wifi error come (code 1009) Please help I don't know what to do?
1009 error means that you are trying to download on the app store in a
country other than the one you are located in or from one another AppStore
that you have an account. That error can also mean that you
are in a country that is blocked.
In which country are you physically located? In which country is youriTunes account? Which store AppStore/iTunes to the country you are
try to download from? What VPN do you use?
-
HP 470 G3 laptop: I have problem with multimedia Audio Controller
I have instaled Windows 7 ultimate 64bite on my laptop and instaled all the driver I have can not install for sound and can't find it. I have problem with Multimedia Audio Contorller I try to auto update, but it does not work. Please help me guys.
Thank you
I recommend that you contact HP technical support and submit a case of covered by the guarantee.
-
I recently bought an iPhone 6s I have loaded with my iTunes support information (old phone an iPhone 5). Problem is that I now have a replica on both phones I have an Apple ID - how to change the apple on the new ID
What do you mean by 'repetition '?
You use two phones? Or did you give the old phone to someone else? If you use two phones, one ID on both Apple is probably than most people. Before you give or sell an iOS device, you must sign in iCloud in settings > iCloud and restore the device as good as new.
-
I have problem with my iphone 5 has no 4g 3g only. in Sweden in the works of 4g Malmö... can someone help me please...
Where did you buy this phone? 4G has already worked on this phone? Whatever the carrier said when contacting you? Have what troubleshooting you tried?
-
Satellite Pro A120: I have problems with the installation of the graphics driver for W2k
I installed windows 2000 on an A120, the system is fully packed and service updated before I even start to install the necessary drivers, I am unable to restart the system. I once, install as recommended drivers that I have problems with the graphics driver because it will not be installed because it requires a reboot and then I can't install new programs that require a restart that the driver has not been installed correctly.
The laptop is a Pro A120, age of 1 week and came with XP home, because of this toshiba will not offer me support I changed the o/s even though they obviously support 2000 on this laptop, because they provide the drivers.
Any ideas would be greatly appreciated.
Hello
Did you use and install the drivers from the Toshiba driver page right?
The drivers of Toshiba W2k for Satellite Pro A120 have been published and are ready!But please pay attention to the Toshiba drivers.
There are two different sets of Satellite Pro A120, with different drivers W2k!
After choosing the good laptop and download the drivers please follow the proper installation order that is indicated in the document "installation instructions"! Check it!I think that if you follow this guide line everything works and runs correctly. Good luck
-
I have problems with the mail (El Capitan)
I have problems with the mail
See writing an effective communities of Apple support question.
Without knowing what are these problems there is no way we can really help you.
Try this:
Start the computer in Safe Mode, and then restart normally. It will be slower than a normal startup.
MacIntel: Reset of the controller (SMC) system management
Reset the PRAM and NVRAM on your Mac.
Repair the hard drive and permissions - El Capitan
HD recovery start:
Restart the computer and after the buzzer, press on and hold down the COMMAND and R until the menu screen appears.
Repair
When the recovery menu appears, select disk utility and press the continue button. Disk utility charges and select Macintosh HD entry indented from the list on the left. Click the first aid tab in the toolbar... If disk utility reports any errors that have been corrected, then re-run first aid until no errors are reported. Wait until the operation is complete, then quit disk utility and return to the main menu. Select restart from the Apple menu.
Now, download and reinstall OS X El Capitan 10.11.3 Combo Update.
Maybe you are looking for
-
Photo library on iCloud and on my Mac?
Now that I use iCloud for my Photo library, I can access of course from other devices, including another Mac. But not from the original Mac where I had the library on an external drive. Whenever I want to open Photo on the Mac, it will search the lib
-
Satellite C870-12F - shaded BIOS settings
Recently, I noticed that I can not change the settings in the BIOS more, almost all of the settings are grayed out. I don't know when it happened, perhaps after update BIOS version 1.6 but it could also happened after the upgrade to Windows 8. I'm no
-
HP PAVILION 15-n071nr: digital keyboard of HP PAVILION 15-n071nr does not work
everything works fine on this computer with the exception of the keypad - most of the keys do nothing 1 connect a usb keyboard gives the same results 2. sometimes by pressing 9 acts as the top and arrow down 3. sometimes by pressing the 3 acts as the
-
has been set back to normal, there was something wrong my user name and password there is six months. I forgot what the sn and the password. I there a way to know what my my old sn and password?
-
TOOLBOX for officejet 6500 disappeared
OfficeJet 6500 (e709n) Windows 7-64 I have more access to the Toolbox to check my ink level Help, please Thank you