从外部ActionScript文件访问MXML组件组件、文件、ActionScript、MXML

2023-09-09 21:31:33 作者:该死的心动   7mr°

我试图从我的外部访问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;
 
精彩推荐
图片推荐