Dynamic Object Initiation As3

前端 未结 6 1956
被撕碎了的回忆
被撕碎了的回忆 2021-01-17 04:33

I notice in older version of flash you can create an instance of a dynamic class. I am creating a game that will have many different classes that can be displayed on the sta

6条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-17 04:47

    You can simple if you want to do it for example an editor for a game:

    selectItem(e.target);       
    
    private function selectItem(whatItem:Object):void
    {
        var TemplateObj:Class = getDefinitionByName(getQualifiedClassName(whatItem)) as Class;
        var newItem:* = new TemplateObj();
    

提交回复
热议问题