CS5和AS3的新手,所以如果我犯了一個根本性的錯誤,請不要猶豫糾正我。Flash CS5 + AS3時間線導航
我試圖建立一個相當冗長和複雜的形式。所以這需要通過不同的部分進行導航。我是Flash和AS3的新手,所以我從一些原型開始,並有兩個按鈕在時間軸中向前和向後導航。我現在的問題是,現在我試圖從「代碼片段」(正確的術語?)區域和我的主ActionScript文件中取出它。按鈕出現,但按下它們不會執行MouseEvent。
所以有兩個問題。 1. Am I doing this right?
2. Why doesn't MouseEvent work when the code is in the .as file?
Form.fla - 第1幀代碼段
var form:Form = new Form();
addChild(form);
Form.as
package
{
import flash.display.MovieClip;
import fl.controls.Button;
import flash.events.MouseEvent;
public class Form extends MovieClip
{
private var nextButton:Button;
private var prevButton:Button;
public function Form()
{
setupNavigation();
}
private function setupNavigation():void
{
nextButton = new Button();
nextButton.label = "Next";
// ... size and position code
nextButton.addEventListener(MouseEvent.CLICK, moveForward);
prevButton = new Button();
prevButton.label = "Previous";
// ... size and position code
prevButton.addEventListener(MouseEvent.CLICK, moveBackward);
addChild(nextButton);
addChild(prevButton);
}
// Setup Mouse events
private function moveForward(event:MouseEvent):void
{
nextFrame();
}
private function moveBackward(event:MouseEvent):void
{
prevFrame();
}
}
}
您可以將`_mainTimeLine`屬性鍵入MovieClip而不是Object,並對`mtl`參數執行相同的操作。 – Taurayi 2011-02-17 23:13:01