框架在actionscript3.0中不能移动
Posted
技术标签:
【中文标题】框架在actionscript3.0中不能移动【英文标题】:Frame can't move in actionscript3.0 【发布时间】:2017-10-24 04:48:44 【问题描述】:您好,我有三个类 Mainintro.as、Gameplay.as、Lastscene.as,在这里我使用此代码调用另一个类.. 框架不断移动而不是停止...
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);
【问题讨论】:
任何时间线上的错误,导致里面的所有脚本都被忽略;因此,时间线会退回到play
ed 的默认行为!因此,你应该不忽略这些错误;相反,如果您需要进一步的帮助,您应该编辑您的问题,很可能添加错误消息并做更多说明,特别是在Globe
:)
如果将Globe.self.realstage.click_mc...etc...etc
替换为:e.currentTarget.removeEventListener(MouseEvent.CLICK, onClick);
,会发生什么?
【参考方案1】:
我在框架中使用了停止,现在它工作正常。
【讨论】:
以上是关于框架在actionscript3.0中不能移动的主要内容,如果未能解决你的问题,请参考以下文章
如何在 Flash CC/Action Script 3.0 中创建自定义 MovieClip 边界?