我通过跟踪字符串尝试反复试验,这样我就可以理解actionscript(或任何类似的语言)的程序流程,但无济于事;在这一点上我无法理解,或者可能是因为我没有吃早餐。请向我解释为什么首先在输出中显示跟踪语句?
这是第一帧的代码
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");
第二帧:
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 并将它们注入到一个数组中,然后追溯它。
了解流程对我来说非常重要,我不想在不了解这一点的情况下继续前进。谢谢你。