0
嗨,我有三個類Mainintro.as,Gameplay.as,Lastscene.as,在這裏我用這個代碼來調用另一個類..幀移動連續不停止...框架無法移動在actionscript3.0
Mainintro.as
package
{
import flash.display.MovieClip;
import flash.events.TimerEvent;
import flash.events.MouseEvent;
import com.greensock.*;
import com.greensock.easing.*;
import Globe;
public class MainIntro
{
public function MainIntro(Mc:MovieClip)
{
Globe.self.realstage = Mc;
Globe.self.realstage.intro_mc.stop();
Mc.intro_mc.play_mc.addEventListener(MouseEvent.CLICK, GameStart);
Mc.intro_mc.play_mc.buttonMode = true;
Mc.intro_mc.ins_btn.buttonMode = true;
var gameply:GamePlay = new GamePlay();
}
public function GameStart(e:MouseEvent):void
{
{
Globe.self.realstage.gotoAndPlay("game");
}
}
}
}
在這裏,在這個類文件(Gameplay.as)發生在public function onClick
的代碼引起的:
Globe.self.realstage.click_mc.addEventListener(MouseEvent.CLICK,onClick);
這給null object reference
錯誤,但我一直在給定的正確名稱爲 立場,然後我試圖運行忽略錯誤,那麼幀移動不 停止......
Gameplay.as
package
{
import com.greensock.*;
import com.greensock.easing.*;
import flash.events.MouseEvent;
import flash.display.MovieClip;
import Globe;
public class GamePlay
{
var currentEntry:int = -1;
var aList:Array =
[
{card:Globe.self.realstage.joker_mc, x:605.55, y:195.45},
{card:Globe.self.realstage.king_mc, x:323.80, y:298.45},
{card:Globe.self.realstage.queen_mc, x:45.85, y:213.95},
{card:Globe.self.realstage.a_mc, x:605.55, y:195.45},
{card:Globe.self.realstage.ten_mc, x:323.80, y:298.45},
{card:Globe.self.realstage.five_mc, x:45.85, y:213.95},
{card:Globe.self.realstage.two_mc, x:605.55, y:195.45},
{card:Globe.self.realstage.nine_mc, x:323.80, y:298.45},
{card:Globe.self.realstage.four_mc, x:45.85, y:213.95},
];
public function GamePlay()
{
Globe.self.realstage.stop();
var gameply:LastScene = new LastScene();
Globe.self.realstage.click_mc.addEventListener(MouseEvent.CLICK,
onClick);
Globe.self.realstage.exit_mc.addEventListener(MouseEvent.CLICK,
lastScene);
}
public function lastScene(e:MouseEvent):void
{
Globe.self.realstage.gotoAndPlay("Scene");
}
public function onClick(e:MouseEvent):void
{
// Unsubscribe to avoid the mess with second click.
Globe.self.realstage.click_mc.removeEventListener(MouseEvent.CLICK,
onClick);
// Start process.
moveNext();
}
public function moveNext():void
{
Globe.self.realstage.currentEntry++;
// Stop the process if all the cards have been moved.
if (Globe.self.realstage.currentEntry >=
Globe.self.realstage.aList.length) return;
// Get the entry.
var anEntry:Object =
Globe.self.realstage.aList[Globe.self.realstage.currentEntry];
// Move the card.
Globe.self.realstage.TweenLite.to(Globe.self.realstage.anEntry['card'],
.4,
{x:Globe.self.realstage.anEntry['x'],y:Globe.self.realstage.anEntry['y'],
onComplete:moveNext});
}
}
}
任何時間軸上的錯誤,導致所有腳本被忽略;因此,時間軸回落到「玩」的默認行爲!因此,你應該**不要忽略錯誤;但是,如果您需要進一步的幫助,您應該編輯您的問題,最有可能添加錯誤信息並做更多的說明,特別是在'Globe'上:) – someOne
如果您替換'Globe.self.realstage.click_mc會發生什麼。 .etc ... etc':'e.currentTarget.removeEventListener(MouseEvent.CLICK, onClick);'? –