Actionscript 3 AS3-使用If语句拖动到下一个场景。

Actionscript 3 AS3-使用If语句拖动到下一个场景。,actionscript-3,if-statement,drag-and-drop,Actionscript 3,If Statement,Drag And Drop,我正在制作一个互动游戏——到目前为止我已经有了这个代码。其中drop1是一枚硬币,用户将其放入target1(盒子)中,一旦完成,他们就可以在下一个场景中观看视频播放。正如你所看到的,当drop1(硬币)掉到盒子上时,硬币就消失了 //Array to hold the target instances, the drop instances, //and the start positions of the drop instances. var hitArray:Array

我正在制作一个互动游戏——到目前为止我已经有了这个代码。其中drop1是一枚硬币,用户将其放入target1(盒子)中,一旦完成,他们就可以在下一个场景中观看视频播放。正如你所看到的,当drop1(硬币)掉到盒子上时,硬币就消失了

  //Array to hold the target instances, the drop instances,   
  //and the start positions of the drop instances.
  var hitArray:Array = new Array(hitTarget1);
  var dropArray:Array = new Array(drop1);
  var positionsArray:Array = new Array();


  //This adds the mouse down and up listener to the drop instances
  //and add the starting x and y positions of the drop instances
  //into the array.
  for (var i:int = 0; i < dropArray.length; i++) {
  dropArray[i].buttonMode = true;
  dropArray[i].addEventListener(MouseEvent.MOUSE_DOWN, mdown);
  dropArray[i].addEventListener(MouseEvent.MOUSE_UP, mUp);

  positionsArray.push({xPos:dropArray[i].x, yPos:dropArray[i].y});
  }

  //This drags the object that has been selected and moves it
  //to the top of the display list. This means you can't drag
  //this object underneath anything.
  function mdown(e:MouseEvent):void {
  e.currentTarget.startDrag();
  setChildIndex(MovieClip(e.currentTarget), numChildren - 1);
  }

  //This stops the dragging of the selected object when the mouse is
  //released. If the object is dropped on the corresponding target
  //then it get set to the x and y position of the target. Otherwise
  //it returns to the original position.
  function mUp(e:MouseEvent):void {
  var dropIndex:int = dropArray.indexOf(e.currentTarget);
  var target:MovieClip = e.currentTarget as MovieClip;

  target.stopDrag();

  if (target.hitTestObject(hitArray[dropIndex])) {
  target.x = hitArray[dropIndex].x;
  target.y = hitArray[dropIndex].y;
  drop1.visible = false;
  }else{
  target.x = positionsArray[dropIndex].xPos;
  target.y = positionsArray[dropIndex].yPos;

  }
  }
//用于保存目标实例、放置实例、,
//以及放置实例的开始位置。
var hitArray:Array=新数组(hitTarget1);
var dropArray:Array=新数组(drop1);
变量位置数组:数组=新数组();
//这会将鼠标向下和向上侦听器添加到drop实例
//并添加放置实例的起始x和y位置
//进入阵列。
for(变量i:int=0;i
现在。。。我想让代码知道用户何时将硬币投进盒子,如果用户有,他们可以观看视频,但只有当他们将硬币投进盒子时才能观看视频。我如何编写代码

请帮忙


谢谢你

如果你还在苦苦挣扎,你可以试着阅读手册。。?我想这就是你至今没有答案的原因。在帧/场景之间移动需要gotoAndPlay或gotoAndStop。检查:

请看示例2中的场景跳跃代码。在显示“简介”(帧标签)的地方,可以只使用数字,但场景必须有名称。。e、 g:

mc1.gotoAndPlay("intro", "Scene 12");
或者在您的案例中,类似于下面的内容(假设您将其命名为scene_video)

我再次假设你的视频播放器在场景的第1帧上,所以停在那里可以让用户有机会观看视频播放器

if (target.hitTestObject(hitArray[dropIndex])) {
target.x = hitArray[dropIndex].x;
target.y = hitArray[dropIndex].y;
drop1.visible = false;
gotoAndStop(1, "scene_video");     }