如何动态地推实例化MC成数组?成数、实例、动态、MC

由网友(款少爷)分享简介:我真的卡住。我正在从一个阵列剪接在某个时间5 MC's。在同一功能我要推另一影片剪辑到另一个阵列。这两个数组保存三菱商事的是重新present正确或错误的答案。因此,当一个问题被给出一个正确的答案的问题,可视化会改变。这个函数持有递增变量我希望MC的由当时的用户和一个推动。事情是我不能似乎能够正确引用它们。从来就试...

我真的卡住。我正在从一个阵列剪接在某个时间5 MC's。在同一功能我要推另一影片剪辑到另一个阵列。这两个数组保存三菱商事的是重新present正确或错误的答案。因此,当一个问题被给出一个正确的答案的问题,可视化会改变。 这个函数持有递增变量我希望MC的由当时的用户和一个推动。事情是我不能似乎能够正确引用它们。 从来就试图

Im really stuck. I have 5 MC´s that are being spliced from one array at a certain time. In that same function I want to push another movieclips into another array. The two arrays holds mc's that represent right or wrong answers. So when one question is being given a correct answer that questions visualisation alters. This function holds a incrementing variable as I do want the mc's to be pushed by the user and one at the time. The thing is I cant seem to refer them properly. I´ve tried

pQuestSum = this[pQuest + pQuestNumber];

pQuestSum = this[pQuest] + pQuestNumber;

和pretty的每样东西从来就想到会工作......但问题是我还没有尝试过

and pretty much everything I´ve imagined would work...but the problem is I havent tried

正确的事情。

当我跟踪pQuestSum(这将是参考)我得到一个错误说这就是它不是一个数字。

when I trace pQuestSum (which would be the reference) I get an error saying thats its not a number.

这是5 1-5名为三菱商事的之一:

this is one of 5 mc's named from 1-5:

var passedquest1:PassedQuest = new PassedQuest();

这是我尝试打造一个参考瓦尔

this is the vars that i try to to build a reference of

var pQuest = "passedquest";
var pQuestNumber = 1;
var pQuestSum;
var questCorrArray:Array = [];

if(event.target.hitTestObject(questArray[ix])){
    removeChild(questArray[ix]);
    questArray.splice(ix,1);
    pQuestNumber ++;
    pQuestSum = this[pQuest] + pQuestNumber;
    trace("pQuestSum"); // NaN
    questCorrArray.push(pQuestSum);
    //trace(questArray.length);
    pointsIncreased = false;
        questPoints = 0;
    }

我如何参照现有的影片剪辑时,参考由两部分组成的字符串和一些?希望我自己有点清楚:)

How do I refer an existing movieclip when the reference consists of both a string and a number? Hope I made myself somewhat clear:)

推荐答案

如果你有你的时间轴上的对象称为passedquest1(作为一个例子)的实例,那么你可以访问它是这样的:

If you had an instance of an object on your timeline called "passedquest1" (as an example), then you could access it this way:

var myObj = this["passedquest" + 1];

或者

var pQuest = "passedquest";
var pQuestNumber = 1;
var myObj = this[pQuest+ pQuestNumber.toString()];

当你这样做: pQuestSum =本[pQuest] + pQuestNumber; ,您试图将号码添加到一个对象(此[pQuest ] ),除非你有被叫号码/ INT VARpassedquest,这将导致NaN的。

When you do this: pQuestSum = this[pQuest] + pQuestNumber;, you are trying add the number to an object (this[pQuest]), unless you have number/int var called "passedquest", this will result in NaN.

阅读全文

相关推荐

最新文章