だから、これにはいくつかの問題があります。
大きな数字がvar i:myArray[rando] = myArray[rando] new myArray[rando]()
ここで何をしようとしているかわからない。
とにかく、ボール、ウォール、フォールはあなたのライブラリにあるムービークリップのインスタンス名です。私はあなたがこのようなものをしたいと思うと思う。
var rando:int = Math.floor(Math.random()*3); //As the comments point out this should give you a random
//int between 0 and 2, arrays are 0 indexed so this is what we want if we have 3 items
あなたの現在の配列では、あなたは現在文字列を入れている。 Flashは "ボール"などが何であるかは分かりません。
は、あなたのステージにこれらのいずれかを追加するには、[今すぐこの
var myArray:Array = new Array [new ball(), new wall(), new fall()]; //this creates a new instance of your library object and stores it in your array
のようなものを試してみてください:
addChild(myArray[rando]); //this uses the random number to pull one of the items out of your array
何がvar i:myArray[rando]
で何をしようとしていることは本当に意味がありません。 myArray [rando]のタイプはありません。このスロットはMovieClipを保持する必要があります
「これは動作しません」 - どのくらい正確に?エラーまたは予期しない動作? –
まず、ランダム変数をラウンドさせずにフロアしたいとします。 'var rando = Math.floor(Math.random()* 3);' –
あなたがしていることをよく見てください - 'addChild(" ball ")'はうまくいくと思いますか? – Marty