私はあなたがこれを意味すると仮定しようとしています。
あなたはあなたがこれらのブロックのうちの2つを作成し、それらを格納、おそらくあなたの基本クラスから配列にブロック
というクラスを持っています。
あなたのブロックのクラスで今すぐ
//stage base class
var blockArray:Array = new Array()
private function createBlocks():void{
var blockOne:Block = new Block(1); //passing in an int to block, could be anything but this
// will be used to do slightly different things
var blockTwo:Block = new Block(2);
blockArray.push(blockOne...blockTwo)
}
//block class
class Block{
var somethingDifferent:int; //this is where we will store the int you pass in when the blocks are made
public function Block(aInt:int){
somethingDifferent = aInt //grabbing the int
}
public function doSomething():void{
trace(somethingDifferent); //will trace out the number passed
}
}
今すぐ戻ってあなたのメインクラスで
//stage base class
private function doSomethingToBlocks():void{
//lets call doSomething on each block
Block(blockArray[0]).doSomething() //this will trace 1 because we passed that into the block in our array slot 0
Block(blockArray[1]).doSomething() //this will trace 2
}
うまくいけば、これはあなたが
これらのブロックの両方が同じ機能を持つ必要があり、同じ機能を拡張しても、どのブロックがそれを呼び出すかに応じて2つの異なる処理を行う必要があることを意味しますか? – Marty