Jump to content
Search Community

DispatchEvent Performance Question

UbiAssassin test
Moderator Tag

Recommended Posts

Hello again :) I have yet another question concerning what sticks around in memory and has to be forcefully cleaned and what gets flushed auto-magically under the hood. I recently stumbled upon the beauty of dispatchEvents trying to find a way to communicate from my NavButton ClassFile to the Main Class file for my website.

 

My basic setup is as follows:

 

NavButton.as

 

Button with definitions and eventlistener watching for someone to click on the button

 

Public Function onButtonClick with a dispatchEvent inside.

 

Main.as

 

EventListener for dispatchEvent from Public Button Function in the NavButton.as

 

dispatchEvent listener fires off a Public Function that loads content into the main section of my website when the navbutton is clicked.

 

Yay simple, easy communication between the two class files. My question is this:

 

Does a dispatchEvent get sent, get picked up by eventListeners, then get removed from memory under the hood or does each dispatchEvent call just sit in memory until you manually clean it with a Kill call of some sort? The only reason I worry about this is because I have 9 navigation buttons, so 9 dispatchEvents that can be called at any time. If they stick around in memory then it could, I guess, cause issues over time if the website stays open and continues to be navigated from content page to content page. I am probably being ridiculous about performance, but it never hurts to ask :)

Link to comment
Share on other sites

Nope, no need to worry about that stuff. Flash pretty much always [eventually] garbage collects objects that you don't specifically hold a reference to. So the only way a dispatched event would persist is if you store it in a persistent variable somewhere in your code (very unlikely).

 

Again, no need to fret about manually deleting every event that gets dispatched.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...