Re: [Flashcoders] [AS3] Cleaning Up (timelines, movieclips and events)

2009-01-16 Thread Joel Stransky
@Jason,
Yes, that is the sad truth I was hoping to avoid here. It's just another
argument for adobe developing a built in Frame class.

@Olivier,
While listening for REMOVED_FROM_STAGE is a nice trick, its just one more
listener to remove as part of clean. I'll trust myself to stop, close and
remove everything I've started for now. I do like that superDestroy()
function though.

On Fri, Jan 16, 2009 at 6:31 AM, Olivier Besson  wrote:

>
>
>   Objects removed at any key
>> frame therefore should be eligible for garbage collection, assuming no
>> event
>> listeners or other code created a reference to them.
>>
>>
> Yes.
>
> Another problem is: even if no listener or code references to these
> objects, they continue "playing" when they are removed by a blank keyframe.
> "playing" means that if the playhead was in play mode, the playhead
> continues playing, possibly triggering sounds, scripts, etc... :(
>
> It seems that as3 dev team just forgot what a blank keyframe is.
>
> I'm interested in the topic of "removeMovieClip" in as3, because it's a
> convenient use of the timeline, but I didn't take time to establish best
> practices about it.
>
> However here are some tracks or tips:
> - listen to REMOVED_FROM_STAGE at the top of display list. When an object
> is removed, "stop" it.
> - add complex behaviors to displayObjects (such as listeners, sounds,
> timers, etc..) using a "safe" API. That is: when you add something new (for
> example A) to displayObject B, you listen B's REMOVED_FROM_STAGE to
> "dispose" A.
>
> I don't want to use a IDisposable interface everywhere. Probably I will use
> a more brutal approach with a function similar to
> http://blog.gludion.com/2008/11/script-code-test.html (sorry it's in
> french but the script is quite self-explanatory).
>
> I anyone has other ideas, don't hesitate to share ;)
>
>
> --
> Olivier Besson (gludion) - (33 1) 44 64 78 99
> http://www.gludion.com
> http://blog.gludion.com
>
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>



-- 
--Joel Stransky
stranskydesign.com
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] [AS3] Cleaning Up (timelines, movieclips and events)

2009-01-16 Thread Olivier Besson




 Objects removed at any key
frame therefore should be eligible for garbage collection, assuming no event
listeners or other code created a reference to them.
  

Yes.

Another problem is: even if no listener or code references to these 
objects, they continue "playing" when they are removed by a blank 
keyframe. "playing" means that if the playhead was in play mode, the 
playhead continues playing, possibly triggering sounds, scripts, etc... :(


It seems that as3 dev team just forgot what a blank keyframe is.

I'm interested in the topic of "removeMovieClip" in as3, because it's a 
convenient use of the timeline, but I didn't take time to establish best 
practices about it.


However here are some tracks or tips:
- listen to REMOVED_FROM_STAGE at the top of display list. When an 
object is removed, "stop" it.
- add complex behaviors to displayObjects (such as listeners, sounds, 
timers, etc..) using a "safe" API. That is: when you add something new 
(for example A) to displayObject B, you listen B's REMOVED_FROM_STAGE to 
"dispose" A.


I don't want to use a IDisposable interface everywhere. Probably I will 
use a more brutal approach with a function similar to 
http://blog.gludion.com/2008/11/script-code-test.html (sorry it's in 
french but the script is quite self-explanatory).


I anyone has other ideas, don't hesitate to share ;)


--
Olivier Besson (gludion) - (33 1) 44 64 78 99
http://www.gludion.com
http://blog.gludion.com

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] [AS3] Cleaning Up (timelines, movieclips and events)

2009-01-16 Thread Jason Boyd
Frames aren't objects in memory; they are just concepts. (Key)frames are
simply time markers when actions occur. Some of these actions are authored
as ActionScript code; others are authored graphically, but the latter are
the equivalent of writing addChild() and removeChild() statements to the
MovieClip. There is one display list that has things added and removed (or
transformed or Tweened) as the playhead advances. Objects removed at any key
frame therefore should be eligible for garbage collection, assuming no event
listeners or other code created a reference to them.

Is this explanation helpful?


2009/1/15 Joel Stransky 

> I've read that before. a couple of times. The question here is what happens
> to frames after the playhead leaves, not when Loader.unload() is called. I
> wasn't sure if each frame had their own display list or or just one per
> timeline. It seems like the sensible thing to do would have been to make a
> Frame class that extends DisplayObjectContainer where their display lists
> were eligable for gc after the playhead left. I set up the test files with
> the intention of seeing if fp9 acted that way or not.
>
> On Thu, Jan 15, 2009 at 10:55 PM, Jason Boyd  wrote:
>
> > You are asking a key question with AS3. Cleaning up movie clips is
> *hard*.
> > There is a list of things that must be done, and they've made it hard to
> do
> > all that.
> >
> > Here's a decent place to start reading:
> > http://www.gskinner.com/blog/archives/2008/04/failure_to_unlo.html
> >
> >
> >
> > 2009/1/14 Joel Stransky 
> >
> > > Are you saying display lists are persistent through an entire
> movieclips
> > > timeline?
> > >
> > > On Wed, Jan 14, 2009 at 7:32 AM, Cor  wrote:
> > >
> > > > If you declare target_mc in your Parent class and
> addChild(target_mc)it
> > > > does exist everywhere.
> > > >
> > > > ___
> > > > Flashcoders mailing list
> > > > Flashcoders@chattyfig.figleaf.com
> > > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > > >
> > >
> > >
> > >
> > > --
> > > --Joel Stransky
> > > stranskydesign.com
> > > ___
> > > Flashcoders mailing list
> > > Flashcoders@chattyfig.figleaf.com
> > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > >
> > ___
> > Flashcoders mailing list
> > Flashcoders@chattyfig.figleaf.com
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
>
>
>
> --
> --Joel Stransky
> stranskydesign.com
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] [AS3] Cleaning Up (timelines, movieclips and events)

2009-01-15 Thread Joel Stransky
I've read that before. a couple of times. The question here is what happens
to frames after the playhead leaves, not when Loader.unload() is called. I
wasn't sure if each frame had their own display list or or just one per
timeline. It seems like the sensible thing to do would have been to make a
Frame class that extends DisplayObjectContainer where their display lists
were eligable for gc after the playhead left. I set up the test files with
the intention of seeing if fp9 acted that way or not.

On Thu, Jan 15, 2009 at 10:55 PM, Jason Boyd  wrote:

> You are asking a key question with AS3. Cleaning up movie clips is *hard*.
> There is a list of things that must be done, and they've made it hard to do
> all that.
>
> Here's a decent place to start reading:
> http://www.gskinner.com/blog/archives/2008/04/failure_to_unlo.html
>
>
>
> 2009/1/14 Joel Stransky 
>
> > Are you saying display lists are persistent through an entire movieclips
> > timeline?
> >
> > On Wed, Jan 14, 2009 at 7:32 AM, Cor  wrote:
> >
> > > If you declare target_mc in your Parent class and addChild(target_mc)it
> > > does exist everywhere.
> > >
> > > ___
> > > Flashcoders mailing list
> > > Flashcoders@chattyfig.figleaf.com
> > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > >
> >
> >
> >
> > --
> > --Joel Stransky
> > stranskydesign.com
> > ___
> > Flashcoders mailing list
> > Flashcoders@chattyfig.figleaf.com
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>



-- 
--Joel Stransky
stranskydesign.com
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] [AS3] Cleaning Up (timelines, movieclips and events)

2009-01-15 Thread Jason Boyd
You are asking a key question with AS3. Cleaning up movie clips is *hard*.
There is a list of things that must be done, and they've made it hard to do
all that.

Here's a decent place to start reading:
http://www.gskinner.com/blog/archives/2008/04/failure_to_unlo.html



2009/1/14 Joel Stransky 

> Are you saying display lists are persistent through an entire movieclips
> timeline?
>
> On Wed, Jan 14, 2009 at 7:32 AM, Cor  wrote:
>
> > If you declare target_mc in your Parent class and addChild(target_mc)it
> > does exist everywhere.
> >
> > ___
> > Flashcoders mailing list
> > Flashcoders@chattyfig.figleaf.com
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
>
>
>
> --
> --Joel Stransky
> stranskydesign.com
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] [AS3] Cleaning Up (timelines, movieclips and events)

2009-01-14 Thread Joel Stransky
Are you saying display lists are persistent through an entire movieclips
timeline?

On Wed, Jan 14, 2009 at 7:32 AM, Cor  wrote:

> If you declare target_mc in your Parent class and addChild(target_mc)it
> does exist everywhere.
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>



-- 
--Joel Stransky
stranskydesign.com
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] [AS3] Cleaning Up (timelines, movieclips and events)

2009-01-14 Thread Cor
If you declare target_mc in your Parent class and addChild(target_mc)it does 
exist everywhere.

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] [AS3] Cleaning Up (timelines, movieclips and events)

2009-01-13 Thread Joel Stransky
I know this is old news and most of you have just left timelines and mc's
for dead and moved on. But I'm having a hard time believing AS3 screwed us
this bad. I'm also just now getting hip enough with as3 to understand the
topic.

I've created a little test case involving a parent.swf and a child.swf.
There is zero code on either timeline and their document classes are listed
below.
parent.swf has 2 frames and child.swf has 30.

Some key clean up is purposely left out to test the weak references, garbage
collector and for the sake of discussion. I don't normally use timelines for
anything. I'm just trying to get a clear understanding.

>>Parent.as
package {
import flash.display.Loader;
import flash.display.MovieClip;
import flash.net.URLRequest;
import flash.events.*;
public class Parent extends MovieClip {
var url:URLRequest;
var loader:Loader;
//target_mc is a stage instance (automatic declaration turned off)
//target_mc does not exist on frame 2
public var target_mc:MovieClip;
public function Parent() {
stop();
init();
}

private function init():void
{
url = new URLRequest("Child.swf");
loader = new Loader();
loader.load(url);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
onLoadComplete, false, 0, true);
}

private function onLoadComplete(e:Event):void
{
var c:MovieClip = e.target.content;
target_mc.addChild(c);
}
}
}


>>Child.as
package {
import flash.display.MovieClip;
import flash.events.*;
public class Child extends MovieClip {
var count:uint = 0;
public function Child() {
addEventListener(Event.ENTER_FRAME, onEnterFrame, false, 0,
true);
this.addFrameScript(29, onFrame29);
}

private function onEnterFrame(e:Event):void
{
trace(this+" "+count++);
}
private function onFrame29():void {
stop();
trace("frame 29 " + parent);
(parent.parent as MovieClip).gotoAndStop(2);
}
}
}

The goal here is see the output eventually stop tracing. Obviously I could
remove the Enter Frame event listener before sending parent to frame 2 but
what I want to be sure of is the memory taken up by child.swf is freed up.
How would I gaurantee this happening?

-- 
--Joel Stransky
stranskydesign.com
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders