<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: 由Flash中的异步、同步联想到setInterval的一些用法。</title>
	<atom:link href="http://www.awflasher.com/blog/archives/504/feed" rel="self" type="application/rss+xml" />
	<link>http://www.awflasher.com/blog/archives/504</link>
	<description>分享互联网, 分享人生</description>
	<lastBuildDate>Sun, 12 Feb 2012 04:59:23 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>By: 哈米特</title>
		<link>http://www.awflasher.com/blog/archives/504#comment-107533</link>
		<dc:creator>哈米特</dc:creator>
		<pubDate>Fri, 23 Sep 2011 03:50:39 +0000</pubDate>
		<guid isPermaLink="false">#comment-107533</guid>
		<description>stop();
loadMovie(&quot;Flash/Intro.swf&quot;,&quot;Intronm&quot;);
tmpInterval=setInterval(function(){_root.gotoAndStop(2);clearInterval(tmpInterval);},73000);


这段代码

clearInterval(tmpInterval);

不起作用得怎么改啊？</description>
		<content:encoded><![CDATA[<p>stop();<br />
loadMovie(&#8220;Flash/Intro.swf&#8221;,&#8221;Intronm&#8221;);<br />
tmpInterval=setInterval(function(){_root.gotoAndStop(2);clearInterval(tmpInterval);},73000);</p>
<p>这段代码</p>
<p>clearInterval(tmpInterval);</p>
<p>不起作用得怎么改啊？</p>
<div digg="0" bury="0" class="diggcomment" cid="107533"></div>]]></content:encoded>
	</item>
	<item>
		<title>By: 解决 setInterval 和 clearInterval 脱僵状态的类 &#171; fly away</title>
		<link>http://www.awflasher.com/blog/archives/504#comment-103743</link>
		<dc:creator>解决 setInterval 和 clearInterval 脱僵状态的类 &#171; fly away</dc:creator>
		<pubDate>Sun, 01 Nov 2009 12:39:29 +0000</pubDate>
		<guid isPermaLink="false">#comment-103743</guid>
		<description>[...] 刚开始使用 setInterval 和 clearInterval 的时候，总是会被脱僵状态困扰。就是说，明明有时候将 intervalID给清理掉了，原来定义的间隔还是不停的执行着，具体的内容可以看aw同学的分析，讲的非常清晰了。于是为了避免出现未预期的程序问题，通常只好使用onEnterFrame来替代。 不过在单纯继承于Object，仅仅处理逻辑的类中，没有MovieClip来充当onEnterFrame的载体，为了创建interval还是要用到 setInterval 方法才行(除非你传一个MovieClip对象进来当holder)。于是参照分析中interval进出栈的做法，封装成一个Interval 类，使用起来就万无一失了。 class Interval { [...]</description>
		<content:encoded><![CDATA[<p>[...] 刚开始使用 setInterval 和 clearInterval 的时候，总是会被脱僵状态困扰。就是说，明明有时候将 intervalID给清理掉了，原来定义的间隔还是不停的执行着，具体的内容可以看aw同学的分析，讲的非常清晰了。于是为了避免出现未预期的程序问题，通常只好使用onEnterFrame来替代。 不过在单纯继承于Object，仅仅处理逻辑的类中，没有MovieClip来充当onEnterFrame的载体，为了创建interval还是要用到 setInterval 方法才行(除非你传一个MovieClip对象进来当holder)。于是参照分析中interval进出栈的做法，封装成一个Interval 类，使用起来就万无一失了。 class Interval { [...]</p>
<div digg="0" bury="0" class="diggcomment" cid="103743"></div>]]></content:encoded>
	</item>
	<item>
		<title>By: 蹩脚馒头</title>
		<link>http://www.awflasher.com/blog/archives/504#comment-59575</link>
		<dc:creator>蹩脚馒头</dc:creator>
		<pubDate>Thu, 13 Mar 2008 01:52:47 +0000</pubDate>
		<guid isPermaLink="false">#comment-59575</guid>
		<description>突然想到一个潜在的BUG。
假如有多个线程在执行， 比如有
function callBack1( s:String ):Void{}
var x1:Interval = new Interval(null, callBack1, 500, &quot;Hello &quot;);

function callBack2( s:String ):Void{}
var x2:Interval = new Interval(null, callBack2, 500, &quot;Hello&quot;);

是不是有可能在x1.clearIntervals(); 的时候把x2这个线程也destroy掉了？ 似乎有可能。 

x2产生的intervalID, 有可能x1也产生了!!!!</description>
		<content:encoded><![CDATA[<p>突然想到一个潜在的BUG。<br />
假如有多个线程在执行， 比如有<br />
function callBack1( s:String ):Void{}<br />
var x1:Interval = new Interval(null, callBack1, 500, &#8220;Hello &#8220;);</p>
<p>function callBack2( s:String ):Void{}<br />
var x2:Interval = new Interval(null, callBack2, 500, &#8220;Hello&#8221;);</p>
<p>是不是有可能在x1.clearIntervals(); 的时候把x2这个线程也destroy掉了？ 似乎有可能。 </p>
<p>x2产生的intervalID, 有可能x1也产生了!!!!</p>
<div digg="0" bury="0" class="diggcomment" cid="59575"></div>]]></content:encoded>
	</item>
	<item>
		<title>By: 蹩脚馒头</title>
		<link>http://www.awflasher.com/blog/archives/504#comment-59523</link>
		<dc:creator>蹩脚馒头</dc:creator>
		<pubDate>Wed, 12 Mar 2008 10:39:43 +0000</pubDate>
		<guid isPermaLink="false">#comment-59523</guid>
		<description>遇到这个问题， 在这里得到解答， THX， 对hirokimo代码做了小ixiao改进
/**
 * @author  蹩脚馒头
 * @version 1.0
 * @usage   
//example 1 :
	var x:Interval = new Interval(null, function(s:String)
										{
											trace(&quot;output---&gt;&quot;+s);
										}, 500, &quot;Hello&quot;);
	clr_btn.onPress = function( ) { x.clearIntervals( ); }
	
//example 2 :
	function callBack( s:String ):Void
	{
		trace(&quot;output---&gt;&quot;+s);
	}
	var x:Interval = new Interval(null, callBack, 500, &quot;Hello&quot;);
	clr_btn.onPress = function( ) { x.clearIntervals( ); }
 
//example 3 :
	var o:Object = new Object( );
	o.callBack = function( s:String ):Void
	{
		trace(&quot;output---&gt;&quot;+s);
	}
	var x:Interval = new Interval(o, &quot;callBack&quot;, 500, &quot;Hello&quot;);
	clr_btn.onPress = function( ) { x.clearIntervals( ); }
 */
class Interval
{
	/**
	 * 构造器
	 * @usage   
	 * var x:Interval = new Interval(null, function(){ 这是个匿名函数 }, 时间间隔, [, param1, param2, ..., paramN]);
	 * 
	 * function callBack(){}
	 * var x:Interval = new Interval(null, callBack, 时间间隔, [, param1, param2, ..., paramN]);
	 * 
	 * var o:Object = new Object();
	 * o.callBack = function(){};
	 * var x:Interval = new Interval(o, &quot;callBack&quot;, 时间间隔, [, param1, param2, ..., paramN]);
	 * 
	 * @param   obj  	监听者
	 * @param   func 	函数
	 * @param   time 	时间间隔
	 * @return  
	 */
	public function Interval(obj:Object, func, time:Number)
	{
		intervalArray = new Array();
		
		var paramArray:Array = new Array();
		if(obj == null)
		{
			for(var i:Number=1; i</description>
		<content:encoded><![CDATA[<p>遇到这个问题， 在这里得到解答， THX， 对hirokimo代码做了小ixiao改进<br />
/**<br />
 * @author  蹩脚馒头<br />
 * @version 1.0<br />
 * @usage<br />
//example 1 :<br />
	var x:Interval = new Interval(null, function(s:String)<br />
										{<br />
											trace(&#8220;output&#8212;&gt;&#8221;+s);<br />
										}, 500, &#8220;Hello&#8221;);<br />
	clr_btn.onPress = function( ) { x.clearIntervals( ); }</p>
<p>//example 2 :<br />
	function callBack( s:String ):Void<br />
	{<br />
		trace(&#8220;output&#8212;&gt;&#8221;+s);<br />
	}<br />
	var x:Interval = new Interval(null, callBack, 500, &#8220;Hello&#8221;);<br />
	clr_btn.onPress = function( ) { x.clearIntervals( ); }</p>
<p>//example 3 :<br />
	var o:Object = new Object( );<br />
	o.callBack = function( s:String ):Void<br />
	{<br />
		trace(&#8220;output&#8212;&gt;&#8221;+s);<br />
	}<br />
	var x:Interval = new Interval(o, &#8220;callBack&#8221;, 500, &#8220;Hello&#8221;);<br />
	clr_btn.onPress = function( ) { x.clearIntervals( ); }<br />
 */<br />
class Interval<br />
{<br />
	/**<br />
	 * 构造器<br />
	 * @usage<br />
	 * var x:Interval = new Interval(null, function(){ 这是个匿名函数 }, 时间间隔, [, param1, param2, ..., paramN]);<br />
	 *<br />
	 * function callBack(){}<br />
	 * var x:Interval = new Interval(null, callBack, 时间间隔, [, param1, param2, ..., paramN]);<br />
	 *<br />
	 * var o:Object = new Object();<br />
	 * o.callBack = function(){};<br />
	 * var x:Interval = new Interval(o, &#8220;callBack&#8221;, 时间间隔, [, param1, param2, ..., paramN]);<br />
	 *<br />
	 * @param   obj  	监听者<br />
	 * @param   func 	函数<br />
	 * @param   time 	时间间隔<br />
	 * @return<br />
	 */<br />
	public function Interval(obj:Object, func, time:Number)<br />
	{<br />
		intervalArray = new Array();</p>
<p>		var paramArray:Array = new Array();<br />
		if(obj == null)<br />
		{<br />
			for(var i:Number=1; i</p>
<div digg="0" bury="0" class="diggcomment" cid="59523"></div>]]></content:encoded>
	</item>
	<item>
		<title>By: hirokimo &#187; 解决 setInterval 和 clearInterval 脱僵状态的类</title>
		<link>http://www.awflasher.com/blog/archives/504#comment-42512</link>
		<dc:creator>hirokimo &#187; 解决 setInterval 和 clearInterval 脱僵状态的类</dc:creator>
		<pubDate>Thu, 29 Nov 2007 10:26:45 +0000</pubDate>
		<guid isPermaLink="false">#comment-42512</guid>
		<description>[...] 刚开始使用 setInterval 和 clearInterval 的时候，总是会被脱僵状态困扰。就是说，明明有时候将 intervalID给清理掉了，原来定义的间隔还是不停的执行着，具体的内容可以看aw同学的分析，讲的非常清晰了。于是为了避免出现未预期的程序问题，通常只好使用onEnterFrame来替代。 不过在单纯继承于Object，仅仅处理逻辑的类中，没有MovieClip来充当onEnterFrame的载体，为了创建interval还是要用到 setInterval 方法才行(除非你传一个MovieClip对象进来当holder)。于是参照分析中interval进出栈的做法，封装成一个Interval 类，使用起来就万无一失了。 [...]</description>
		<content:encoded><![CDATA[<p>[...] 刚开始使用 setInterval 和 clearInterval 的时候，总是会被脱僵状态困扰。就是说，明明有时候将 intervalID给清理掉了，原来定义的间隔还是不停的执行着，具体的内容可以看aw同学的分析，讲的非常清晰了。于是为了避免出现未预期的程序问题，通常只好使用onEnterFrame来替代。 不过在单纯继承于Object，仅仅处理逻辑的类中，没有MovieClip来充当onEnterFrame的载体，为了创建interval还是要用到 setInterval 方法才行(除非你传一个MovieClip对象进来当holder)。于是参照分析中interval进出栈的做法，封装成一个Interval 类，使用起来就万无一失了。 [...]</p>
<div digg="0" bury="0" class="diggcomment" cid="42512"></div>]]></content:encoded>
	</item>
	<item>
		<title>By: ShArC</title>
		<link>http://www.awflasher.com/blog/archives/504#comment-31433</link>
		<dc:creator>ShArC</dc:creator>
		<pubDate>Fri, 31 Aug 2007 06:34:53 +0000</pubDate>
		<guid isPermaLink="false">#comment-31433</guid>
		<description>好!挺好的！</description>
		<content:encoded><![CDATA[<p>好!挺好的！</p>
<div digg="0" bury="0" class="diggcomment" cid="31433"></div>]]></content:encoded>
	</item>
	<item>
		<title>By: liuhuan</title>
		<link>http://www.awflasher.com/blog/archives/504#comment-4325</link>
		<dc:creator>liuhuan</dc:creator>
		<pubDate>Tue, 26 Sep 2006 23:04:34 +0000</pubDate>
		<guid isPermaLink="false">#comment-4325</guid>
		<description>非常棒~谢谢~

我就觉得setInterval的路径很麻烦，很多时候老是路径不对,最后只好用上_global 

www.liuhuan.com</description>
		<content:encoded><![CDATA[<p>非常棒~谢谢~</p>
<p>我就觉得setInterval的路径很麻烦，很多时候老是路径不对,最后只好用上_global </p>
<p><a href="http://www.liuhuan.com" rel="nofollow">http://www.liuhuan.com</a></p>
<div digg="0" bury="0" class="diggcomment" cid="4325"></div>]]></content:encoded>
	</item>
	<item>
		<title>By: aw</title>
		<link>http://www.awflasher.com/blog/archives/504#comment-3975</link>
		<dc:creator>aw</dc:creator>
		<pubDate>Mon, 11 Sep 2006 18:20:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-3975</guid>
		<description>很久前写的了。你用debug模式监测一下那个object和那个array。</description>
		<content:encoded><![CDATA[<p>很久前写的了。你用debug模式监测一下那个object和那个array。</p>
<div digg="0" bury="1" class="diggcomment" cid="3975"></div>]]></content:encoded>
	</item>
	<item>
		<title>By: rison</title>
		<link>http://www.awflasher.com/blog/archives/504#comment-3974</link>
		<dc:creator>rison</dc:creator>
		<pubDate>Mon, 11 Sep 2006 18:14:28 +0000</pubDate>
		<guid isPermaLink="false">#comment-3974</guid>
		<description>for (var j in myTempInterval1_arr)
  {
    clearInterval(myTempInterval1_arr[j]);
    myTempInterval1_arr.pop();
  }
后面
为什么下面还要调用一次clearInterval(intervalID);
那个object里的interval不是全部被清空了么？
还是另外有什么目的？</description>
		<content:encoded><![CDATA[<p>for (var j in myTempInterval1_arr)<br />
  {<br />
    clearInterval(myTempInterval1_arr[j]);<br />
    myTempInterval1_arr.pop();<br />
  }<br />
后面<br />
为什么下面还要调用一次clearInterval(intervalID);<br />
那个object里的interval不是全部被清空了么？<br />
还是另外有什么目的？</p>
<div digg="0" bury="0" class="diggcomment" cid="3974"></div>]]></content:encoded>
	</item>
</channel>
</rss>

