내 프로그램의 대부분의 데이터를로드하는 xml 구조가 있습니다. 이 경우 xml에 지정된 클래스를 인스턴스화하려고합니다. 클래스 이름을 XML로 작성한 다음 인스턴스를 생성하고 매개 변수를 전달할 수 있다고 생각했습니다. 그것이 쉽지 않은 것으로 밝혀졌다! As3에서 'name'클래스의 문자열을 사용하여 인스턴스 만들기
는이 같은 코드를 시도 : //special objects
for each (o in xml.Objects[0].special)
{
p.x = [email protected];
p.y = [email protected];
s.x = [email protected];
s.y = [email protected];
trace([email protected]);
//var type:Class = [email protected] as Class;
var type:Class = getDefinitionByName(String([email protected])) as Class;
trace(type);
objectArray.push(new type(p, s));
trace("special");
}
당신은 내가 XML 파일에서 클래스 이름 속성에 내 클래스의 이름을 볼 수 있듯이. 내가의 getDefinitionByName와 정의를 얻을 수 있었다 (적어도 다음 트레이스는 올바른 클래스 이름을 보여줍니다)하지만 난 그것을 인스턴스화하고 배열로 밀어하려고 할 때 나는
오류 # 2136을 시작 오류의 더미를 얻을 : SWF 파일을 file : ///Users/tuomas/Dropbox/Flash/ScorpionBox/bin-debug/ScorpionBox.swf에 잘못된 데이터가 있습니다.
어떻게하면 좋을까요?
[가능한 이름을 아는 AS3에서 클래스의 인스턴스를 만들 수 있습니까?] (http://stackoverflow.com/questions/7597343/can-i-create-an-instance-of-a) -class-from-as3-just-knowing-his-name) – bobobobo