<?xml version="1.0" encoding="iso-8859-1"?><rss version="2.0">
<channel><title><![CDATA[ActionScript.org Flash, Flex and ActionScript Resources - Comments for article: Working with setInterval in classes]]></title><link>http://www.actionscript.org/resources</link><description /><language>en-us</language><copyright><![CDATA[http://www.actionscript.org/resources]]></copyright><generator>N/A</generator><webMaster>general.redirect@gmail.com</webMaster><lastBuildDate>Sun, 22 Nov 2009 23:02:24 CST</lastBuildDate><ttl>20</ttl><item><title><![CDATA[Comment #1]]></title><link>http://www.actionscript.org/resources/articles/592/1/Working-with-setInterval-in-classes/Page1.html#Comment4043</link><description><![CDATA[You're currently sending the constructing object along as a parameter for the function to catch (i.e. function( _this: Object ) ). An easier, often overlooked notation to keep scopes intact is the following: 

var interval: Number = setInterval( this, "methodName", 100 );

function methodName(): Void
{
  trace( this ) // will output the actual 'this', i.e. the object/movieclip that contains both the interval and this function.
}<br/><br/>
(Comment posted by Tiemen Glastra at 7:59 am, Mon 18th Jun 2007)]]></description><author>no@spam.com (Tiemen Glastra)</author><pubDate><![CDATA[Mon, 18 Jun 2007 07:59:29 CDT]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/592/1/Working-with-setInterval-in-classes/Page1.html#Comment4043</guid></item><item><title><![CDATA[Comment #2]]></title><link>http://www.actionscript.org/resources/articles/592/1/Working-with-setInterval-in-classes/Page1.html#Comment7500</link><description><![CDATA[Regarding scoping using setInterval or onEnterFrame... lets go crazy!
Imagine this, being able to call a piece of code in any movieclip sitting in  a certain movieclip scope, crazy? not!

set it like this:
var tID:Number;
var mcArray:Array = [mc_1, mc_2, mc_3] // the movieclips with the code pieces

tID = setInterval(this, "act", 100, mcArray);

function act(arr:Array){
  for(var i=0; i<arr.length; i++){
    arr[i].callMe();
  }
}

And in each of the movieclip, declare:
function callMe(){
  trace(this._name + "is doing something interesting");
}

Want more flexibility? I'll write a tutorial soon ;)<br/><br/>
(Comment posted by Gregorius Soedharmo at 9:41 pm, Tue 13th Nov 2007)]]></description><author>no@spam.com (Gregorius Soedharmo)</author><pubDate><![CDATA[Tue, 13 Nov 2007 21:41:39 CST]]></pubDate><guid isPermaLink="true">http://www.actionscript.org/resources/articles/592/1/Working-with-setInterval-in-classes/Page1.html#Comment7500</guid></item></channel></rss>