如何使用参数制作MXML组件构造函数? [英] How to make MXML Component Constructor with Arguments?

查看:126
本文介绍了如何使用参数制作MXML组件构造函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是flex的新手,有人可以帮助我吗?

I`m new in flex and could anyone help me?

如何创建一个接受MXML组件参数的构造函数?

How do I create a constructor that takes arguments for an MXML component?

推荐答案

您不能; MXML组件没有可以修改的构造函数.

You can't; MXML Components do not have constructors that you can modify.

您有一些选择.首先是重写您的组件以使用ActionScript.在某些情况下这可能很乏味,而在另一些情况下则很琐碎.这取决于组件的功能.

You have a few options. The first is to rewrite your component to use ActionScript. This can be tedious in some situations, and trivial in others. It depends what the component does.

第二个选项os,用于在组件上使用公共变量.创建MXML组件的实例时,请在其上设置属性.您应该能够在预初始化事件处理程序中访问此类属性. prenitinialize将在构造函数之后但在createChildren()之前调度.

A second option os to use public variables on the component. When you create the instance of your MXML Component, set the properties on it. You should be able to access such properties in a preinitialize event handler. prenitinialize will be dispatched after the constructor, but before createChildren().

这篇关于如何使用参数制作MXML组件构造函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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