Home > Tips > setTimeout

setTimeout

  • Posted by: ぢゃぃ
  • 2007年12月18日 10:40
  • Tips

街がにぎやかなのが逆に寂しい今日この頃、
皆さんいかがお過ごしでしょうかー。

ぢゃぃです。

setTimeoutで少しハマったのでメモー

help等にドキュメント化されてないことで有名ですが、
setTimeout便利です。

機能としては、
一定間隔で関数を呼び続けるsetIntereval()に対し、
一度だけ呼び出されて消えちゃうのがsetTimeout()。

ちょっと間隔を空けて、何かを呼びたいときに便利。
setIntervalでも同様のことができるけど、clearIntervalしなくてよい分便利。

使用法(書き方)は、setInterval()と同じ。

基本的な使い方は
setTimeout (objectReference:Object, methodName:String, delay:Number [, arg1:Object, arg2, ..., argN]) : Number

setInterevalと同様、
setTimeout (functionReference:Object, delay:Number [, arg1:Object, arg2, ..., argN]) : Number

ただし、この二つには決定的な違いがある。
呼び出されるfunctionのスコープが違うのです。

例(_rootの1フレに以下のコードを書くと)

this.clearIdA=setTimeout(funcA,1000)

this.clearIdB=setTimeout(this,"funcB",1000)

function funcA(){

   trace("funcA_"+this)

}

function funcB(){

   trace("funcB"+this)

}

出力funcA_undefined

出力funcB__level0


呼ばれる前に消したい時は、
clearTimeout(clearId)

で今回、ハマったのはここではなく、setTimeoutをクラス内で使おうとした時、エラーが帰ってきます。
基本的にsetIntervalと全く同じ書き方で、すべて大丈夫だと言う認識だったので焦りました。

おそらく、setTimeoutが toplevel.asに書き込まれてないからだと思われます。


解決法としては、
toplevel.asに書き込むか、_global.setTimeout()、_global.clearTimeout()とパスを明確に指定しておく必要があります。

fumiononaka.comに書かれてました
http://www.fumiononaka.com/TechNotes/Flash/FN0512001.html

wikiも参考までに、、。こちら

Comments:10

Comment Form
Bedelia 2009年8月16日 07:41

How are you. All human situations have their inconveniences. We feel those of the present but neither see nor feel those of the future; and hence we often make troublesome changes without amendment, and frequently for the worse. Help me! It has to find sites on the: Acai berry ireland. I found only this - natural acai berry side effects. Monavie juice products featuring an exclusive ai berry juice blend. In light of the massive interest, we felt the need to pull some strings and get with one of the top product suppliers. Thanks :rolleyes:. Bedelia from Niger.

Thurston 2010年2月17日 07:58

Hi guys. Many people weigh the guilt they will feel against the pleasure of the forbidden action they want to take. Help me! Could you help me find sites on the: Sun country airline tickets. I found only this - spirit airline tickets. Airline accounting in the travel enables their commercial turboprop to buy our seats, airline tickets. Airline tickets, gerstner is become with looking ibm from finding out of product in the available minutes. Thank you very much :cool:. Thurston from Egypt.

Led Watch 2010年4月18日 05:45

Jokes of the de rigueur big-hearted, properly told, can do more to inform questions of politics, values, and data than any company of dull arguments.

Maurice Lacroix Pontos 2010年4月20日 04:37

It was hitherto a issue of conclusion to whether or not life had to receive a message to be lived. It any longer becomes perspicuous, on the conflicting, that it will be lived all the improve if it has no meaning.

Nautica 2010年4月21日 05:14

No fetters lives without jostling and being jostled; in all ways he has to elbow himself during the terra, giving and receiving offence.

Nike Watch 2010年4月21日 23:55

And you at the end of the day win to a consensus, where you proceed a judgement of what really ought to be done, and then they entrust it to me and then I use it. I utilizing a instrument delineate it in the sentiment, the philosophical sense.

Nike Triax 2010年4月22日 04:34

And you finally win to a consensus, where you turn someone on a judgement of what unqualifiedly ought to be done, and then they give ground it to me and then I use it. I utilizing a instrument draw up it in the sentiment, the thoughtful sense.

Seiko Watch Bands 2010年6月29日 19:22

To be a good charitable being is to from a kind of openness to the mankind, an cleverness to group aleatory things beyond your own control, that can govern you to be shattered in very exceptionally circumstances for which you were not to blame. That says something exceedingly important relating to the get of the honest life: that it is based on a corporation in the unpredictable and on a willingness to be exposed; it's based on being more like a plant than like a jewel, something somewhat fragile, but whose extremely precise attractiveness is inseparable from that fragility.

Samsung Tv Light 2010年7月 3日 04:30

To be a noble lenient being is to from a kind of openness to the world, an cleverness to guardianship aleatory things beyond your own restrain, that can front you to be shattered in hugely exceptionally circumstances pro which you were not to blame. That says something remarkably impressive thither the fettle of the righteous autobiography: that it is based on a trust in the up in the air and on a willingness to be exposed; it's based on being more like a spy than like a sparkler, something fairly dainty, but whose extremely special handsomeness is inseparable from that fragility.

Canon IXUS 2010年7月 4日 03:38

But things being what they are I be enduring show up to allow that the fit world is an enigma, a benign problem that is made terrible not later than our own out of one's mind strive to explicate it as though it had an underlying truth.

Trackbacks:0

TrackBack URL for this entry
http://www.mononoahare.com/cgi/mt4/mt-tb.cgi/34
Listed below are links to weblogs that reference
setTimeout from もののあはれ_すたいるず

Home > Tips > setTimeout

Search
Feeds
         
Tag Cloud

Return to page top