adding / removing clusters of events should i use pause/resume?

10 views
Skip to first unread message

akrobata79

unread,
Feb 3, 2011, 5:11:45 PM2/3/11
to EventController
hi folks,
heres what I'm trying to achieve

say, I have an object that consists of 3 different objects all linked
up using event listeners

now, I want to have 300 of them and display but only 50 of them active

so now this is the part where it would be cool to plug in your Event
OCntroller

what I would like to do is disable event listeners for remaining 250
objects and just toggle them on and off whenever needed

how can i achieve this?

I cant just remove cluster events because I don't see a way to neatly
add them back in

how does the pause functionality works? does it temporarily remove
event listeners and then when i resume it just remembers where it
should add what event listener?

I havent got the time to poke around with your class yet but it looks
very promising...

how would you do what I wanted to achieve here?
can you mock up a quick little example?

thanks!

Rob

Ben Fhala

unread,
Feb 3, 2011, 5:24:55 PM2/3/11
to eventco...@googlegroups.com
Hey Rob great question,
i've been bad on documenting the latest updates.

Basically this is the work flow give your 250 events the same cluster id or one that you can easily find with a regexp expression


There isn't an explisit pause but something kind of cool a bit hidden when you remove it returns to you all of the events in an array that where removed its actually the blueprint to turn them back on as well

so when you call

var a:Array = lec.rem(/group2/); //remove all events with the string 'group2'

//i saved all the events in an array so there still in memory if you wouldn't they would automaticly get removed from memory as there isn't anything linking up to it

now when you are ready to reactivate:

lec.addGroup(a);

that will behind the hood run through the array and add them back in.

so its kind of a pause just without really calling it pause its giving you more control as you can pause many things and then reactivate them together or separately as it just depends on how many buckets you create and you have less of a chance to create a memory leak as if you don't save the array and there are no references to the item them would self destruct.

let me know if this helped.

;)


--
Best,

Ben Fhala


http://everythingfla.com
The ActionScript & Flash School
follow us on  @everythingFLA  ][  Subscribe to  Youtube  ][ Like us on FaceBook

EverythingFLA is part of Everything Nice ,inc creations.

-----
Up-to $24,000 in goods in our Feb/11 giveaway can be yours. Want to learn flash and/or help others know us.  http://bit.ly/h2IlPK







Robert Fiedo

unread,
Feb 3, 2011, 5:32:33 PM2/3/11
to eventco...@googlegroups.com
hi Ben
this is great stuff
I forgot to add one thing though
the reason why I am doing all this is to improve the performance


things started to get a bit choppy with so many objects

and i figured maybe your class could temporarialy remove those events (and not just move them over to an array) and then put them back in 'the easy way'

i could write like this for all of my classes I guess, have a public function that would toggle on and off appropriate events but if your class could do this globally that would be kick ass

possible?


Ben Fhala

unread,
Feb 3, 2011, 5:44:15 PM2/3/11
to eventco...@googlegroups.com
Hey Robert,

yea i don't know you will probably need to try and find out how much would it help.
follow up question to your comment what type of events are you working with is it ENTER_FRAME or something that is very heavy on the system?
as 250 events are not that much flash should be able to deal with it unless its happening all the time. so might not be an issue with the events at all might be a visual rendering issue or something like that
would love to hear more.

Robert Fiedo

unread,
Feb 3, 2011, 9:25:47 PM2/3/11
to eventco...@googlegroups.com
actually I'm still trying to get a feel for how many events i can have at one time,
I'm developing this aplication that has 300 custom made checkboxes (each checkbox is a MVC triad, and  both V & C have event listeners listening for CHANGE events, and in addition to that the V has some mouse events)
 
those 300 checkboxes are split into 6 panels, each panel has 50 of those checkboxes
you can see only one of those panels at the time, rest of them are covered by a solid sprite
 
there are arrows on top that enable you to go from one panel to another (so with each move I'm moving all of those 300 elements via Tweenlite), this way you move from one panel to another and are able to select check boxes form the active panel that you can see at the moment
 
everything was fine untill i tried to run it on an older laptop (but not that old, stil does the job)
 
and I noticed a big performance drop
 
of course this can be due to many reasons
might as well be the fact that 300 of those objects being shifted by 400 pixels is just too much by itself
(so in this case I would have to either before using tweenlite convert the panelHolder into a bitmap and move that bitmap then after the animation is done swap it with final position of the panels)
 
but i decided see if maybe switching the events off for the duration of animation will do the trick
and your framework certainly would fit in nicely here...
 
what do you recommend? 
nontheless I have big plans for teh eventcontroller framework and plan to use it in my next projects :)
brilliant stuff 
!
(oh and thanks for being so helpful, this internet thing is amazing, everyway you turn people WANT to help you, from one forum to another, this really blows my mind ;)
 
   
 
 


Ben Fhala

unread,
Feb 4, 2011, 8:49:50 AM2/4/11
to eventco...@googlegroups.com
Yea who ever invented the internet is a rock star ;)
its odd that its making you issues but it might be just because its the built in components there overly complex here is what i would do


1. i would use my eventctonroller - well because i made it - ;) i don't know how much its goign to help in this case my lec is really about making it easier to not get into memory leaks i didn't really care or focus to much about making it memory optimized one day but the real goal was to create a really easy to user interface that gave you more control then you have without it so probably eventCntroller is a bad name it should be youControlEvents.


2. try actually removing them from the stage - see if that helps it should

3. try to destroy them when there not used and make them each time.

4. if none of the above work i would think about making your own checkbox and not as part of the built in components that is if this is critical as you have more control and you can make a more minimal combo that doesn't have all the bells the component has.


the thing with Event.CHANGE its not that heavy on memory its only dispatched when it changes so it shouldn't be hitting you so bad
p.s check to see your memory usage and memory usage over time and see how these changes effect that as it sounds like its down to cutting down the memory flash needs to operate and to do that you just need to have less going on (less saved in memory)
--

Robert Fiedo

unread,
Feb 4, 2011, 4:52:52 PM2/4/11
to eventco...@googlegroups.com
thanks Ben,
I will do as you said, + memory leaks no more as I'll be implementing the framework in future projects

hey, you have more goodies like this? what else you guys are working on>?
;)

Ben Fhala

unread,
Feb 4, 2011, 5:27:58 PM2/4/11
to eventco...@googlegroups.com
I got a few up my sleeve ;). A good friend Corban when we worked together on a project checked it out and that's how it really started to become public .

We past it through a few friends gathered feedback tried to make it better and released it to the world.

http://everythingfla.com/
is really my main job these days well i wouldn't call it job my main love these days ;)
but I'll get back to this project and others as I free up more at some point this year I hope.

Thanks for the support people like you are what make me want to share. :P your 1 out of 600(ha statistically speaking that is  ;)

Robert Fiedo

unread,
Feb 8, 2011, 9:50:31 AM2/8/11
to eventco...@googlegroups.com
'statistically speakin" hehe, keep up the good work man!


Reply all
Reply to author
Forward
0 new messages