Re: [Flashcoders] Passing vars with the the timer and events

2008-03-14 Thread Cory Petosky
rchives/2006/07/as3_weakly_refe.html > > > > - Original Message - > From: "EECOLOR" <[EMAIL PROTECTED]> > To: "Flash Coders List" > Sent: Friday, March 14, 2008 1:18 PM > Subject: Re: [Flashcoders] Passing vars with the the timer and

Re: [Flashcoders] Passing vars with the the timer and events

2008-03-14 Thread Muzak
- Original Message - From: "EECOLOR" <[EMAIL PROTECTED]> To: "Flash Coders List" Sent: Friday, March 14, 2008 1:18 PM Subject: Re: [Flashcoders] Passing vars with the the timer and events I have modified my test classes slightly. And found that when debugging this mo

Re: [Flashcoders] Passing vars with the the timer and events

2008-03-14 Thread EECOLOR
I have modified my test classes slightly. And found that when debugging this movie in Flex Builder 3, the garbage collection was triggered when I moved my mouse within the Flash movie. I suspect that the method behind the screens that runs the garbage collector is quite complex. I think that in mo

Re: [Flashcoders] Passing vars with the the timer and events

2008-03-14 Thread EECOLOR
Hey there, I was totally shocked this morning. If what you were saying was true it would mean that if you created a class with a listener to itself and instantiated it, it would never be garbage collected. So I did some extra tests. 1. Your example with a weak listener (same result) 2. Trying to

Re: [Flashcoders] Passing vars with the the timer and events

2008-03-14 Thread EECOLOR
Oh man, thank you for this example! This totally blows me away. I am sorry I was so persistent. You are correct. I will have to check all my applications now, hehe. This also means that all my earlier arguments are incorrect and that the use of Delegate is indeed very dangerous. Thank you for sh

Re: [Flashcoders] Passing vars with the the timer and events

2008-03-13 Thread Cory Petosky
> There is no such thing as "a reference to be created invisibly within the > event system". I disagree. Try this test code: package { import flash.events.Event; import flash.display.Sprite; import flash.utils.getTimer; public class TestClass ex

Re: [Flashcoders] Passing vars with the the timer and events

2008-03-13 Thread EECOLOR
>If you add a normal event listener to a child, >and then remove that child, the child is _not_ garbage collected. >Objects are only garbage collected when all references to the object >are removed. Adding a normal event listener causes a reference to be >created invisibly within the event system.

Re: [Flashcoders] Passing vars with the the timer and events

2008-03-13 Thread Cory Petosky
> The common use for weak event > listeners is when adding listeners to the stage I disagree. Weak event listeners should be used in nearly all cases. > In most cases there is actually no real benefit of creating weak event > listeners. In most cases parents add > listeners to their children

Re: [Flashcoders] Passing vars with the the timer and events

2008-03-13 Thread EECOLOR
>That's a dangerous practice. I do not completely agree. >It prevents you from using weak event listeners Correct. The common use for weak event listeners is when adding listeners to the stage: the stage is allways present and adding normal listeners to it will insure that the listener will per

Re: [Flashcoders] Passing vars with the the timer and events

2008-03-12 Thread Helmut Granda
Thanks Jason, That is how I approached in the end. I was just getting stuck while dispatching custom events from the extended Timer class. but I think all is solved now. On 3/12/08, Merrill, Jason <[EMAIL PROTECTED]> wrote: > > Haven't followed this thread, and don't even know what the original

RE: [Flashcoders] Passing vars with the the timer and events

2008-03-12 Thread Merrill, Jason
Haven't followed this thread, and don't even know what the original question is other than the thread title, but I'll just jump in and add, I don't think attaching variables to events is a good idea anymore, I used to do it in AS2 all the time with Delegate, but now with the new AS2 event model, I

Re: [Flashcoders] Passing vars with the the timer and events

2008-03-12 Thread Helmut Granda
I was a little bit concerned about the Delegate approach and I was able to figure out that extending the Timer class and adding a property to to the new class everything worked fine. My issue was that once the handler the extended time

Re: [Flashcoders] Passing vars with the the timer and events

2008-03-12 Thread Cory Petosky
That's a dangerous practice. It prevents you from using weak event listeners -- because the only reference to your delegate function object is the event listener itself, a weakly-referenced listener will be garbage collected. Now have to manually remove your listener to make sure your object is gar

Re: [Flashcoders] Passing vars with the the timer and events

2008-03-12 Thread EECOLOR
If we ever he need to pass extra arguments to the handler we use a delegate class to pass them. Usage: obj.addEventListener(Event.TYPE, Delegate.create(this, _handler, arg1, arg2)); private function _handler(e:Event, arg1:Object, arg2:Object):void { }; I added our delegate class as an attachmen

Re: [Flashcoders] Passing vars with the the timer and events

2008-03-12 Thread Helmut Granda
Hi Bob, Thanks for the comment, that is the route that started working on after posting the question and the only issue I am having is dispatching the custom event when the timer has been reached, I did a soft search for samples of extending the Timer Class with custom TimerEvents but wasnt able t

Re: [Flashcoders] Passing vars with the the timer and events

2008-03-12 Thread Bob Leisle
Hi Helmut, One option is extending Timer such that it dispatches your custom SoundTimerEvent rather than the built in TimerEvent. Another option, if _sound is a class var, would be to have your timeEventHandler dispatch the SoundTimerEvent. hth, Bob Helmut Granda wrote: