Flex中使用getDefinitionByName运行实例化一个FXG [英] Instantiate an Fxg on runtime using getDefinitionByName in Flex

查看:138
本文介绍了Flex中使用getDefinitionByName运行实例化一个FXG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小问题getDefinitionByName。 我的目的是要实例化一个FXG对象(Number10.fxg)在运行时文件的MXML。 类的名称是所使用的getDefinitionByName一个字符串变量 返回类insantiate的名称。如果不发送一个错误信息的code也不会起作用。在code是如下:

i have a little problem with getDefinitionByName. My purpose is to instantiate an FXG object(Number10.fxg) in a document mxml on runtime. The name of the Class is in a string variable that is used by getDefinitionByName to return the name of the class to insantiate. The code doesn't work even if doesn't send an error message. The code is as follows:

import assets.Number10;
import flash.utils.getDefinitionByName;
import mx.core.IVisualElement;

private function onClick(event:MouseEvent):void
{ 
  var value:String = "Number10";
  var ClassDefinition:Class = getDefinitionByName(value) as Class;
  var ten:IVisualElement = new ClassDefinition() as IVisualElement;
  this.contentGroup.addElement(ten);
}

我也试过用... VAR十:IVisualElement =新的ClassDefinition(); 但什么都没有。这是行不通的! 请帮帮我!

I tried also with... var ten:IVisualElement = new ClassDefinition(); but nothing. It Doesn't work! Please, Help me!

首先,我指的是涉及的话题让电信土坯文档页面。在这里,它是:

First of all, i refer to the adobe documentation pages that covering the topic so telegraphic. Here it is:

选项包括类[...]

说明链接一个或多个类来生成的应用程序的SWF文件,不论这些类需要在编译的时候。 要链接整个SWC文件,而不是单独的类,使用include-libraries选项。

Description Links one or more classes to the resulting application SWF file, whether or not those classes are required at compile time. To link an entire SWC file rather than individual classes, use the include-libraries option.

Ok.In Flash Builder中,我去到其他编译器参数那里是眼前这个选项

Ok.In Flash Builder i go to the Additional compiler arguments where there is just this option

-locale en_US

所以,我加入这下我的选项

So i add my option under this

-includes class = assets.Number10

- 包括类assets.Number10

- 包括类Number10

在运行应用程序时出现错误#2032。

When the application runs i get the Error #2032.

我觉得选择declaretion是错误的。我没有使用选项一个很好的参考。 所以......救救我!

I think that the option declaretion is wrong. I do not have a good reference for using option. So...Help me!

我怎样才能声明Number10类或资产包与其他FXG对象使用包括类选项?

How can i declare the Number10 class or the assets package with the other fxg object using the includes class option?

推荐答案

您可以添加类的SWC和使用包括和includeClasses编译器选项主权财富基金。通过这些,你不必引用类的code。查阅文档的正确用法。

You can add classes to SWCs and SWFs using the include and includeClasses compiler options. Using these, you don't have to reference the classes in the code. Consult the documentation for proper usage.

这篇关于Flex中使用getDefinitionByName运行实例化一个FXG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆