Flint Particle System Forum - Removing initializers Sun, 11 Dec 2011 05:16:55 +0000 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & Feed Publisher Removing initializers http://flintparticles.org/forum/comments.php?DiscussionID=367&Focus=1239#Comment_1239 http://flintparticles.org/forum/comments.php?DiscussionID=367&Focus=1239#Comment_1239 Wed, 23 Jun 2010 21:59:40 +0100 rrh
var tempList:Array = emit.initializers;
for (var i:int=0;i<tempList.length;i++) {
emit.removeInitializer(Initializer(tempList[i]));
}

trace(emit.initializers.length);


That trace at the end keeps tracing 3 or 4, but if it's removing the initializers, I'd expect it to be 0. Does removeInitializer not remove the intializer from the linitializers array? ]]>
Removing initializers http://flintparticles.org/forum/comments.php?DiscussionID=367&Focus=1240#Comment_1240 http://flintparticles.org/forum/comments.php?DiscussionID=367&Focus=1240#Comment_1240 Thu, 24 Jun 2010 23:40:56 +0100 rrh
emit.addInitializer( new ScaleImageInit( scale*0.25, scale ) );
emit.addInitializer( new ColorInit( colour ) );


What happens to the old initializers? I figured, hey, the easy solution is to just remove the old initializers before I add the new ones, but whatever I do, I want to be sure I'm not creating a memory leak. ]]>
Removing initializers http://flintparticles.org/forum/comments.php?DiscussionID=367&Focus=1241#Comment_1241 http://flintparticles.org/forum/comments.php?DiscussionID=367&Focus=1241#Comment_1241 Thu, 01 Jul 2010 07:57:07 +0100 Richard
There are a number of other ways you could do this that would work. Here's three of them...

var tempList : Array = emit.initializers.slice();
for ( var i : int = 0; i < tempList.length; i++ )
{
emit.removeInitializer( Initializer( tempList[i] ) );
}


for ( var i : int = emit.initializers.length - 1; i >= 0; i-- )
{
emit.removeInitializer( Initializer( emit.initializers[i] ) );
}


while ( emit.initializers.length > 0 )
{
emit.removeInitializer( Initializer( emit.initializers[0] ) );
}
]]>
Removing initializers http://flintparticles.org/forum/comments.php?DiscussionID=367&Focus=1243#Comment_1243 http://flintparticles.org/forum/comments.php?DiscussionID=367&Focus=1243#Comment_1243 Mon, 05 Jul 2010 16:58:05 +0100 Xor
var colorInit :ColorInit = new ColorInit( colour );
emit.addInitializer( colorInit );

// later
colorInit.minColor = 0xFFFFFF;
]]>