Also one other thought i forgot to include in regards on what Jerome
has said. My original question about event listeners really came about
when in the past i created  several hundred hexagons in native Flash
and AS3 (before i started using away3D) and i just drew the hexagon
shapes using a SPRITE object and drew the outline for it using a SHAPE
object and i used another SPRITE object as a container to hold those
two objects. At that time, i created the 500 to 1000 hexagons using a
FOR loop and i added 3 even listeners to EACH hexagon.

Once i completely changed to Away3D, i no longer do that. I just have
a class that extends ObjectContainer3D and all 1261 hexagons are
stored in the container as Face objects AND i just add ONE
Evenlistener to that container WHICH allows me to access all of its
children so i can modify each face object as i want. I was really just
trying to see if adding one even listener to the ObjectContainer3D
doesn't like magically add it to all 1261 face objects...lol.

So anyways, i was realizing that adding so many even-listeners before
was a lot of wasted RAM.

Thanks again for all

On May 10, 9:58 am, elguapoloco <[email protected]>
wrote:
> Hi CyberHawk,
>
> If you do not remove the event listeners on an object it will not be
> Garbage Collected and will remain in memory. That means that an
> ENTER_FRAME handler will keep running. That can affect the memory but
> also performance of your app. Obviously for persistent interactions
> (like keys) on the stage you don't need to remove them unless you
> don't need them anymore. But when you have objects that you plan on
> creating and removing dynamically (like containers for sections on a
> site or images in a carousel) you should build a way to remove all the
> events once you are disposing of that object. You can just add 2
> functions to classes that will handle this addAllEvents() and
> removeAllEvents(). Just make sure all the events added in addAllEvents
> are removed in removeAllEvents.
>
> But the best way to handle this is to avoid creating garbage in the
> first place! Use Object Pools where ever possible. Google it, there
> are vary simple implementations you can apply to your projects. By
> recycling your objects, like those using BitmapMaterials, you can save
> yourself a lot of hair lost in debugging memory issues :)
>
> The HYPE framework has a lot of Object Pools demo and Lost In
> Actionscript has a Basic Object Pool class in its repository.
>
> ath.
>
> Jerome.

Reply via email to