从外部ActionScript文件访问MXML组件 [英] access mxml component from external actionscript file

查看:142
本文介绍了从外部ActionScript文件访问MXML组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从我的外部访问MXML组件的文件。例如

i'm trying to access an mxml component from my external as file. e.g

main.mxml:<br>
<code>[mx:text id="myText" />]</code>

file.as:<br>
<code>var mainM:main = new main();

mainM.text.visible = true;</code>

我收到以下错误:

I get the following error:

[TypeError: Error #1009: Cannot access a property or method of a null object reference]

在如何更好地接近它的任何建议。

Any suggestions on how to approach it better.

推荐答案

组件实例的ID成为你的应用程序中的一员,并且可以很容易被像这样访问

The ID of your component instance becomes a member of your application and can easy be accessed like so

import mx.core.Application;
mx.core.Application.application.myText.visible = true;

这篇关于从外部ActionScript文件访问MXML组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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