Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 障碍物不会移动_Actionscript 3 - Fatal编程技术网

Actionscript 3 障碍物不会移动

Actionscript 3 障碍物不会移动,actionscript-3,Actionscript 3,我无法理解为什么我的阵列中的项目不会沿y轴向下移动,我希望它们在x轴上随机出现。这是我的密码: import flash.display.MovieClip; import flash.events.Event; import fl.transitions.Tween; import fl.transitions.easing.*; public class obstacleOne extends MovieClip { private var speed:Number; pr

我无法理解为什么我的阵列中的项目不会沿y轴向下移动,我希望它们在x轴上随机出现。这是我的密码:

import flash.display.MovieClip;
import flash.events.Event;
import fl.transitions.Tween;
import fl.transitions.easing.*;

public class obstacleOne extends MovieClip {
    private var speed:Number;
    private var obstacleOneTypes:Array = ["obstacle1","obstacle2"];
    private var thisObstacleOneType:String;

    public function obstacleOne() {
        // constructor code
        // pick a random number between 1 and the amount of types of litter
        var randomNumber:uint = Math.ceil(Math.random() * obstacleOneTypes.length);
        thisObstacleOneType = obstacleOneTypes[randomNumber - 1];
        this.gotoAndStop(randomNumber);
        this.x = Math.ceil(Math.random() * 400);
        this.y =0 - Math.random()*400;
        speed = 4 + (Math.random()*4)
        addEventListener(Event.ENTER_FRAME,updateMe);
    }

    public function caught():void{
        // in this function are going to animate the litter removing from the screen using a tween equation
        // when it is finished we can remove the object
        // now place in a random position on the beach
        this.x = Math.ceil(Math.random() * stage.stageWidth);
        this.y =0 - Math.random()*2000;
    }

    private function updateMe(evt:Event):void{
        this.y += speed;
        if(y>stage.stageHeight){
            this.y = 7;
            // send an event to main class to subtract score
            //stage.dispatchEvent(new Event("hitBottom",true));
        }//*/
    }

它对我有用。我将该类放在一个名为“ch”的包中,然后在主时间线中:

import ch.obstacleOne;

stage.addChild(new obstacleOne());
stage.addChild(new obstacleOne());
stage.addChild(new obstacleOne());
stage.addChild(new obstacleOne());
课程和以前一样:

package ch{

import flash.display.MovieClip;
import flash.events.Event;
import fl.transitions.Tween;
import fl.transitions.easing.*;

public class obstacleOne extends MovieClip {
....
然后,您需要将库中的movieclip与您的类连接起来(对不起,GUI是德语的):


如果您找到了问题的解决方案,请在此处提供,以便其他有相同问题的人可以从中受益。谢谢。