나는 이것이 당신이 이것을 의미한다고 가정 할 것입니다.
당신은 당신이 블록의 두 가지를 만들 가능성이 귀하의 기본 클래스에서 배열에 저장할 블록
라는 클래스가 있습니다. 당신의 블록 클래스 이제
//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)
}
이제 다시 메인 클래스
//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
}
을에
//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
}
}
희망이 당신이
두 블록 모두 동일한 기능을 가져야하며 동일한 기능을 확장하더라도 함수가 어떤 블록을 호출하는지에 따라 두 가지 다른 작업을 수행해야한다는 것을 의미합니까? – Marty