Actionscript 蜂拥而至

Actionscript 蜂拥而至,actionscript,actionscript-2,Actionscript,Actionscript 2,您好,我一直收到错误:在大于之前需要标识符。 第13行。 请帮忙,谢谢 fly = function () { this.animate = function() { // Capture mouse positions and distance from mouse this.targetX = _root._xmouse; this.targetY = _root._ymouse; this.distX = th

您好,我一直收到错误:在大于之前需要标识符。 第13行。 请帮忙,谢谢

    fly = function () {
    this.animate = function() {
        // Capture mouse positions and distance from mouse
        this.targetX = _root._xmouse;
        this.targetY = _root._ymouse;
        this.distX = this.targetX-this.meX+this.flockX;
        this.distY = this.targetY-this.meY+this.flockY;
        // 
        if ((this.targetX == this.oldTargetX) && Math.random()>0.9) {
            // add small scale random darting if mouse is still
            this.flockX = (Math.random()*100)-50;
            this.flockY = (Math.random()*100)-50;
        } else if ((this.targetX<>this.oldTargetX) && Math.random()>0.8) {
            // add large scale random darting if mouse is moving
            this.flockX = (Math.random()*400)-200;
            this.flockY = (Math.random()*400)-200;
        }
        // Apply inertia equation
        this.meX = Math.round(this.meX+(this.distX)/20);
        this.meY = Math.round(this.meY+(this.distY)/20);
        // perform animation
        this._x = this.meX;
        this._y = this.meY;
        // remember the current mouse pos so we can tell if
        // it has moved next time around
        this.oldTargetX = this.targetX;
    };
    this.initialize = function() {
        this.targetX = 0;
        this.targetY = 0;
        this.distX = 0;
        this.distY = 0;
        this.meX = this._x;
        this.meY = this._y;
        this.oldTargetX = 0;
        this.flockX = (Math.random()*200)-100;
        this.flockY = (Math.random()*200)-100;
    };
    // set up onEnterFrame script to animate _parent...
    this.initialize();
    this.onEnterFrame = this.animate;
};
    //
    //
    var i:Number = 0;
    var bugClip:MovieClip;
    for (i=0; i<30; i++) {
        bugClip = this.attachMovie("bug", "bug"+i, i);
        fly.apply(bugClip);
    }

我不知道Actionscript,但通过查看您的代码,我建议您这样做:

    randomValue = Math.random()
    if ((this.targetX == this.oldTargetX) && randomValue>0.9) {
自Flash Player 5以来,不等于的运算符已被弃用

你应该使用!=对于相同的功能


尽管我在FlashPlayer10.2上测试了它,它仍然可以编译并运行,没有错误。我猜您正在编译到更高版本。

您需要在代码块中编辑代码,否则没有人会回答您的问题question@StudentRik我已经修改了你的问题,使用{}符号格式化stackoverflow上的代码,你的标题是AS3,但代码显然是AS2。我认为错误可能是由以下原因引起的:this.targetx this.oldTargetX。这是一个错误吗?应该是<或>还是“不同”/“不相等”,在这种情况下,您应该使用!非操作员:this.targetX!=这个是.oldTargetX