import flash.events.MouseEvent;
import flash.utils.Timer;
import flash.events.TimerEvent;
var wordArray:Array = [mc_clipA, mc_clipB];
var imgArray:Array = [Aimg, Bimg];
var posArray:Array = [ {x:816.15, y:396.05}, {x:518.3, y:410.05}];
var ClipA:MovieClip;
var ClipB:MovieClip;
var startXpositionClipA:Number;
var startYpositionClipA:Number;
var startXpositionClipB:Number;
var startYpositionClipB:Number;
wordArray[0].buttonMode = true;
wordArray[1].buttonMode = true;
wordArray[0].addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDownClipA);
wordArray[1].addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDownClipB);
//Mouse Down Function for ClipA
function item_onMouseDownClipA(event:MouseEvent):void {
ClipA = MovieClip(event.currentTarget);
startXpositionClipA = ClipA.x;
startYpositionClipA = ClipA.y;
addChild(ClipA);
ClipA.startDrag();
stage.addEventListener(MouseEvent.MOUSE_UP, stage_onMouseUpClipA);
wordArray[0].removeEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDownClipA);
wordArray[1].removeEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDownClipB);
}
//Mouse Up Function for ClipA
function stage_onMouseUpClipA(event:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_UP, stage_onMouseUpClipA);
ClipA.stopDrag();
var indexClipA:int = wordArray.indexOf(ClipClipA);
var matchClipClipA:MovieClip = MovieClip(imageArray[indexClipA]);
if(matchClipClipA.hitTestPoint(ClipA.x, ClipA.y, true)) {
ClipA.x = positionArray[indexClipA].x;
ClipA.y = positionArray[indexClipA].y;
ClipA.removeEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDownZip);
ClipA.buttonMode = false;
var tot=0;
tot=tot+10;
score.text="You scored: " + tot +" Points ";
var setTimer:Timer = new Timer(1000,60);
setTimer.addEventListener(TimerEvent.TIMER,doTask);
setTimer.start();
function doTask(event:TimerEvent) {
gotoAndStop(1,"Scene 2");
setTimer.stop();
}
}
else
{
ClipA.x = startXpositionClipA;
ClipA.y = startYpositionClipA;
wordArray[0].addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDownClipA);
wordArray[1].addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDownClipB);
}
}
//Mouse Down Function for ClipB
function item_onMouseDownClipB(event:MouseEvent):void {
ClipB = MovieClip(event.currentTarget);
startXpositionClipB = ClipB.x;
startYpositionClipB = ClipB.y;
addChild(ClipB);
ClipB.startDrag();
stage.addEventListener(MouseEvent.MOUSE_UP, stage_onMouseUpClipB);
wordArray[0].removeEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDownClipA);
wordArray[1].removeEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDownClipB);
}
//Mouse Up Function for ClipB
function stage_onMouseUpClipB(event:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_UP, stage_onMouseUpClipB);
ClipB.stopDrag();
var indexClipB:int = wordArray.indexOf(ClipB);
var matchClipClipB:MovieClip = MovieClip(imageArray[indexClipB]);
if(matchClipClipB.hitTestPoint(ClipB.x, ClipB.y, true)) {
ClipB.x = positionArray3[indexTie].x;
ClipB.y = positionArray3[indexTie].y;
ClipB.removeEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDownClipB);
ClipB.buttonMode = false;
var tot=0;
tot=tot;
score.text="You scored: " + tot +" Points ";
var setTimer:Timer = new Timer(1000,60);
setTimer.addEventListener(TimerEvent.TIMER,doTask);
setTimer.start();
function doTask(event:TimerEvent) {
gotoAndStop(1,"Scene 2");
setTimer.stop();
}
}
else
{
ClipB.x = startXpositionClipB;
ClipB.y = startYpositionClipB;
wordArray[0].addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDownClipA);
wordArray[1].addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDownClipB);
}
}
ドラッグアンドドロップゲームについてです。特定のオブジェクト名がユーザーに表示され、ユーザーは正しい画像を指定された位置にドラッグ アンド ドロップする必要があります。タスクが完了すると、次のシーンに動的に移動します。そのために、タイマークラスを使用しました。シーン 2 でこのエラーが発生していますが、シーン 1 ではコードは完全に実行されます。
命名規則はすべて正しいですが、それでも次のエラーが発生します。
TypeError: エラー #1009: null オブジェクト参照のプロパティまたはメソッドにアクセスできません。MethodInfo-1156() で flash.utils::Timer/_timerDispatch() で flash.utils::Timer/tick()
誰かがこれで私を助けることができますか?