how to use mxml component in another actionscript

岁酱吖の 提交于 2019-12-25 00:13:18

问题


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")


回答1:


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();




回答2:


Make sure that you have imported your custom component to the file you are using it.




回答3:


You will need to reference the other custom component as a mxml namespace.

Check the following article to get an accurate illustration: http://www.roseindia.net/flex/custom-mxml-tags.shtml



来源:https://stackoverflow.com/questions/5961491/how-to-use-mxml-component-in-another-actionscript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!