2012-11-19 65 views
0

我有一个flash游戏,它显示在下面的代码错误的Actionscript错误#1056

private function onAddingTimer(event:TimerEvent) : void 
     { 
      var _loc_2:int = 0; 
      var _loc_3:MovieClip = null; 
      var _loc_4:MovieClip = null; 
      var _loc_5:String = this; 
      var _loc_6:* = this.timerAddCounter + 1; 
      _loc_5.timerAddCounter = _loc_6; 
      this.bonusIntervalDiff = int(this.levelData[this.level].enemyCount/this.levelData[this.level].bonusCount); 
      if (this.timerAddCounter >= this.levelData[this.level].createDelay) 
      { 
       var _loc_5:String = this; 
       var _loc_6:* = this.timerAddCount + 1; 
       _loc_5.timerAddCount = _loc_6; 
       if (int(this.timerAddCount % this.bonusIntervalDiff) == 0) 
       { 
        _loc_2 = this.rangeRandom(0, this.LIFE_CLASSES.length); 
        trace("Ran:: " + _loc_2); 
        _loc_3 = new this.LIFE_CLASSES[_loc_2].className() as MovieClip; 
        this.spLifeGround.addChild(_loc_3); 
        _loc_3.y = 500; 
        this.previousX = this.rangeRandomWithPreviousDifference(100, 700, 210, this.previousX); 
        _loc_3.x = this.previousX; 
        this.lifes.push({mc:_loc_3, score:this.LIFE_CLASSES[_loc_2].score, cls:this.LIFE_CLASSES[_loc_2].className}); 
       } 
       else 
       { 
        _loc_4 = new this.EMENY_CLASSES[this.rangeRandom(0, this.EMENY_CLASSES.length)] as MovieClip; 
        this.spEnemyGround.addChild(_loc_4); 
        _loc_4.y = 450; 
        this.previousX = this.rangeRandomWithPreviousDifference(75, 725, 210, this.previousX); 
        _loc_4.x = this.previousX; 
        this.enemys.push(_loc_4); 
       } 
       this.timerAddCounter = 0; 
      } 
      return; 
     }// end function 

从控制台错误是

ReferenceError: Error #1056: Cannot create property timerAddCounter on String. at JuegoGame/onAddingTimer() at flash.utils::Timer/_timerDispatch() at flash.utils::Timer/tick()

请问哪位知道,为什么不好好工作。

+3

这看起来不像你自己的代码,而是它的反编译代码。 – Vesper

+1

因为它被混淆器保护,反编译的代码不等于原始代码? – alxx

+0

是的,它是反编译的代码, –

回答

0

因为String Actionscript 3中的对象不支持动态添加变量。您的代码正试图将timerAddCounter属性添加到String实例。

var _loc_5:String = this; 
... 
_loc_5.timerAddCounter = _loc_6; 

_loc_5必须是动态对象,或具有用于timeAddCounter一个setter的对象。