アクションスクリプト(または一般的な同様の言語)のプログラムフローを理解できるように、文字列をトレースして試行錯誤を試みましたが、役に立ちませんでした。朝食を食べなかったので、現時点では理解できませんでした。トレースステートメントが最初に出力に表示された理由を説明してください。
これが最初のフレームのコードです
import flash.events.MouseEvent;
import flash.events.Event;
trace("I'm in line 3!");
stage.addEventListener(Event.ENTER_FRAME, generateURLs);
imageThumb.invButton.addEventListener(MouseEvent.MOUSE_OVER, showBar);
imageThumb.invButton.addEventListener(MouseEvent.MOUSE_OUT, hideBar);
trace("I'm in line 8");
// Generates the image URLs and inject them to the imageURLs array
var imageURLs:Array = new Array();
function generateURLs(e:Event):void {
trace("I'm inside the generateURLs function!");
var url:String = new String();
for(var i:int = 0; i <= 31; i++) {
url = new String('pokemon/img_' + i);
imageURLs.push(url + ".jpg");
trace(imageURLs[i]);
}
stage.removeEventListener(Event.ENTER_FRAME, generateURLs);
}
trace("I'm in line 24");
function showBar(evt:MouseEvent):void {
trace("I'm inside the ShowBar function!");
imageThumb.bar.gotoAndPlay('over');
}
function hideBar(evt:MouseEvent):void {
trace("I'm inside the hideBar function!");
imageThumb.bar.gotoAndPlay('out');
}
trace("I'm in line 34");
2番目のフレーム:
trace("We're not in Frame 1 anymore!");
最後のフレーム:
stop();
trace("STOP!!!");
そして出力
I'm in line 3!
I'm in line 8
I'm in line 24
I'm in line 34
I'm inside the generateURLs function!
pokemon/img_0.jpg
pokemon/img_1.jpg
pokemon/img_2.jpg
pokemon/img_3.jpg
pokemon/img_4.jpg
pokemon/img_5.jpg
pokemon/img_6.jpg
pokemon/img_7.jpg
pokemon/img_8.jpg
pokemon/img_9.jpg
pokemon/img_10.jpg
pokemon/img_11.jpg
pokemon/img_12.jpg
pokemon/img_13.jpg
pokemon/img_14.jpg
pokemon/img_15.jpg
pokemon/img_16.jpg
pokemon/img_17.jpg
pokemon/img_18.jpg
pokemon/img_19.jpg
pokemon/img_20.jpg
pokemon/img_21.jpg
pokemon/img_22.jpg
pokemon/img_23.jpg
pokemon/img_24.jpg
pokemon/img_25.jpg
pokemon/img_26.jpg
pokemon/img_27.jpg
pokemon/img_28.jpg
pokemon/img_29.jpg
pokemon/img_30.jpg
pokemon/img_31.jpg
We're not in Frame 1 anymore!
STOP!!!
私がやろうとしているのは、ステージがロードされたときにイベントをトリガーすることです。画像のURLを生成し、それらを配列に挿入してからトレースバックします。
流れを理解することは私にとって非常に重要です。私はこれを理解せずに前進したくありません。ありがとうございました。