어떻게 클래스 인스턴스에서 다른 클래스 객체를 인스턴스화 할 수 있습니까?ActionScript - 인스턴스에서 새 객체를 인스턴스화 하시겠습니까?
(작동하지 않음) 전달 된 인수 클래스를 기반으로 새 클래스 인스턴스를 반환하는 함수를 싶습니다. 즉, new MySprite();
을 호출하지 않고도 MySprite의 새 인스턴스를 반환하는 함수가 필요합니다.
var mySprite:Sprite = new MySprite();
var anotherSprite:Sprite = makeAnotherSprite(mySprite);
function makeAnotherSprite(instance:Sprite):Sprite
{
return new getDefinitionByName(getQualifiedClassName(instance));
}
멋진! 나는 constructor 속성을 사용하는 것을 잊었다. 이것은 flash.utils 정적 함수를 사용하는 것보다 훨씬 깔끔합니다. 감사! – TheDarkIn1978