如何在另一个动作中使用mxml组件 [英] how to use mxml component in another actionscript

查看:214
本文介绍了如何在另一个动作中使用mxml组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在另一个mxml组件中使用mxml组件actioncript代码


在我的主mxml文件中

  private var warningMessage:Warning; //这是变量

if(!_controller.flashVars.chatSession || _controller.flashVars.chatSession ==)
{

warningMessage.includeInLayout = true;
warningMessage.visible = true;
}
else
{
_controller.flashVars.showWarningMessage =2;

code

$ b $ private $ warningMessage:Warning;

warningMessage.visible = true (我想用它来像这在我的动作代码



但我得到错误说类型未找到或不是编译时常量:警告
$ b

解决方案

如果这个组件在另一个SWC文件中,请确保在项目设置中引用它。
  • 导入命名空间或直接调用它(com.whatever。 namespace.Warning)

  • 确保调用 new 来生成一个新的对象。在上面的代码中, warningMessage 为null。

    private var warningMessage:Warning = new Warning();


    how to use mxml component in another mxml component actionscript code

    for ex. in my main mxml file

    private var warningMessage:Warning;//this is variable
    
    if (!_controller.flashVars.chatSession || _controller.flashVars.chatSession == "")
                {
    
                    warningMessage.includeInLayout = true;
                    warningMessage.visible = true;
                }
                else
                {
                    _controller.flashVars.showWarningMessage = "2";
                }
    

    private var warningMessage:Warning;(warning is external custom component)

    warningMessage.visible=true (and i want use it like this in my actionscript code

    but i am getting error saying "Type was not found or was not compile time constant:warning")

    解决方案

    There are three things that jump out.

    1. If this component is in another SWC file, make sure to reference it in the project settings
    2. Import the namespace or call it directly (com.whatever.namespace.Warning)
    3. Make sure to call new to generate a new object. In your code above, warningMessage is null.

    private var warningMessage:Warning = new Warning();

    这篇关于如何在另一个动作中使用mxml组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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