【问题标题】:Actionscript 3 - Call to a possibly undefined method Round through a reference with static type ClassActionscript 3 - 调用可能未定义的方法 通过静态类型 Class 的引用循环
【发布时间】:2014-03-07 01:27:35
【问题描述】:

好的,看来我通过将所有内容都转换为公共静态来解决了以下问题。但是数学函数呢? Error:Call to a possibly undefined method Round through a reference with static type Class

我是 AS3 的新手。这只是我编码的第二天.. 但似乎 成为我无法理解为什么会发生的事情。

      private var baseExp:int = 10;
      private var offset:int = 32;
      private var expCurve:Number = 1.036486;
      //------------------------
      private var nextExp:Number = Math.Round(Math.Pow((base_stats[0] * (baseExp / expCurve)), expCurve * (1 + (base_stats[0] / (offset * 5)))));
      private var _nextExp:Number = nextExp;
      private var currentExp:int = 0;
      /*
       * Check Exp if player can LEVEL UP
       */
      public static function CheckExp():void {
          if (currentExp >= nextExp) {
              base_stats[0] += 1;
              //Add Stat Increments here
              currentExp -= nextExp;
              for (var i:int = 1; i < base_stats.length; i++) {
                  trace(base_stats[i]);
              }
          }
          if (nextExp != _nextExp) {
              RefreshRequiredExp();
              _nextExp = nextExp;
          }
      }

I declared nextExp, _nextExp and currentExp as private... but when I call them in the static function CheckExp, it throws the `Access of

未定义的属性 nextExp` 等等等等

And also an `Error: Call to a possibly undefined method Pow through a reference with static type Class.` in the Math functions.

Is there something wrong I'm doing?

【问题讨论】:

    标签: actionscript-3 flash


    【解决方案1】:

    我通过将Math.Round 更改为Math.round 解决了数学问题。和其他人一样。私有变量也被设置为私有静态变量以匹配函数。好的,已经解决了。

    哇,我不知道我可以自己解决这个问题。 这真的很荒谬,我觉得我只是在自言自语。

    【讨论】:

    • 我明白了。如果我首先向全世界寻求帮助,我通常只能自己找到解决方案!去图吧。
    • 在不寻求帮助的情况下,实际上花了大约一个小时才弄清楚。但是在发布后,我在几分钟内解决了它。很棒的东西。
    • @Don 这被称为“与 Bob 交谈”,其中“Bob”是一个沉默的人,你向他讲述你的问题,并在最终意识到解决方案的过程中停下来。如果我认为有任何问题,您可以尝试这种技术。也有人说“好问题已经是答案的一半”,所以如果你问得正确,你可能会被自己的话暗示答案。
    • 顺便说一句,您可以接受自己的答案,只是为了其他人不要在不再需要帮助时浪费精力帮助您。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-17
    相关资源
    最近更新 更多