English 中文(简体)
从一个阵列添加实例到另一个电影剪
原标题:Add instances from an array to another movieclip

我做了“3.0行动”编程,我非常清楚这一点。我有一个与“2.0行动”有关的项目,我有一个在舞台上添加实例的简单问题。在“3.0行动”中,我想在一些电影剪辑中添加多个实例,首先将它们保存在一个阵列中,然后我与该阵列一起设定 X和Y,宽度、阿尔法和其他细节。

例如:

" itemBlock " 是我的实例,是图书馆导出的一个电影剪贴片。

for ( var i = 0 ; i < 24 ; i++ ) {
blockBANK[i] = new itemBlock(); // itemBlock is an exported movieclip in the library. 
blockBANK[i].x = // some calculation;
blockBANK[i].y = // some other calculation;
mainPage_mc.addChild(blockBANK[i]); // add to the mainPage_mc  holder
}

and now I can use this array to add and edit my instance everywhere in my AS3 code. In AS2 I try these but not working and also NO compiler error !

for (var i=0;i<7;i++) { 
    var temp:MovieClip = new MovieClip();
    temp.attachMovie("itemBlock "," itemBlock "+i,0); 
    textboxBANK[i].addChild(temp);
    textboxBANK[i]._y = 40; 
    textboxBANK[i]._x = i * 20; 
    mainPage_mc.addChild(textboxBANK[i]);// add to holder
}

没有工作,没有编译器错误

for (var i=0;i<7;i++) { 
    var temp:MovieClip = new MovieClip();
    temp.attachMovie("itemBlock","itemBlock"+i,0); 
    textboxBANK[i].attachMovie(temp);
    textboxBANK[i]._y = 40; 
    textboxBANK[i]._x = i * 20; 
    mainPage_mc.attachMovie(textboxBANK[i]);// add to holder
}

没有再次工作,也没有编译器错误..

我如何将实例放入一个数组, 并将其 < 坚固 > 添加 < / 坚固 > 给AS2 中的数组的持有者 < 坚固 > FROM < /坚固 >?

最佳回答

据我所知,您在 AS2 中使用 < em> create EmptyMovieClip 方法创建一个新的电影剪贴页。 另外, AS2 不支持 < em > add child 方法 。

AS2 显示列表与 AS3 显示列表有很大不同。 显示对象只有在处于舞台上时才存在( 与 AS3 不同, 在那里您可以用存储的“ 显示对象” 绕过显示树 。 简而言之, 如果您试图将电影剪辑存储在一个阵列中, 以后再添加到舞台上, 则不可能 。

您需要做的是把他们添加到舞台上, 并搅乱他们的“ 可见” 财产。 然后让他们在稍后的阶段显现出来。 根据我所理解的你们想要做的, 这里有一些代码...

var tempClips:Array = new Array();

for(var i = 0; i < 10; i++){

    var temp = mainStage.createEmptyMovieClip("temp"+i, mainStage.getNextHighestDepth());

    var temp_inner = temp.attachMovie("exportedLibrarySymbol", "temp_inner", temp.getNextHighestDepth());

    temp._visible = false; //or true if you want them to be seen instantly

    temp._x = someCalculation;
    temp._y = someCalculation;

    tempClips.push(temp);

}

请注意, 在 AS2 中, 如果您尝试在同一深度的舞台上添加一些东西, 原始显示对象将会消失 。 使用 < em> get theexthighest Depth 的方法来精确正确的整数 。

更好地描述一下你试图做什么 将是非常有帮助的。

问题回答

暂无回答




相关问题
WordPress Data Storage Efficiency

I ve been asked to review a WordPress plugin of sorts and try to find ways of making it faster. The premise of this plugin is basically to store a bunch of users and shifts and appointments and ...

Convert a 2D array index into a 1D index

I have two arrays for a chess variant I am coding in java...I have a console version so far which represents the board as a 1D array (size is 32) but I am working on making a GUI for it and I want it ...

Convert an array of integers for use in a SQL "IN" clause

Surely there is a framework method that given an array of integers, strings etc converts them into a list that can be used in a SQL "IN" clause? e.g. int[] values = {1,2,3}; would go to "(1,2,3)"

Sorting twodimensional Array in AS3

So, i have a two-dimensional Array of ID s and vote count - voteArray[i][0] = ID, voteArray[i][1] = vote count I want the top 3 voted items to be displayed in different colors, so i have a 2nd Array -...

C++ Array Sort Me

Stuck on an array sorter. Have to sort numbers from largest to smallest. I m trying two loops (one nested in the other). Here s the code: int counter=0; // inner counter int counter2=0; // outer ...

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...

Best practice of big javascript objects

sry for this imprecise topic name. I am querying a dataset a lot of times so using ajax request would end up in tons of http requests. For this reason I decided to use the json encode method to ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

热门标签