Created
May 1, 2012 01:22
-
-
Save koeri/2564170 to your computer and use it in GitHub Desktop.
[AS3] 指定した秒・フレーム数の経過後に実行する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//(1) Flashを実行してからのフレーム数をカウントする方法 の例 | |
//ただし、このまま使うと無限ループに陥るので注意。 | |
// フレームレートを指定 | |
stage.frameRate = 12; | |
// 指定したいフレーム数 | |
// ex. フレームレート12のとき、3秒を指定したい場合 → 36 | |
var waitTime:int = 36; | |
// フレーム数をカウントするための変数 | |
var frameCount:int = 0; | |
// Flashを実行してからのフレーム数をカウント | |
this.addEventListener(Event.ENTER_FRAME, frameCountFunc); | |
function frameCountFunc(e:Event):void{ | |
// フレーム数をカウント | |
frameCount++; | |
// 現在のフレーム数と指定したフレーム数の差分を比較 | |
if(frameCount > waitTime){ | |
// 指定秒たってから実行したいことを記述 | |
trace("3秒たったよ"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment