In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you what should be paid attention to when using the FlexaddChild () method. I hope you will get something after reading this article. Let's discuss it together.
Considerations for the FlexaddChild () method
In FlexApplication, it is not possible to add classes from flash.display packages such as Sprite,MovieClip directly with FlexaddChild.
For example, the following code will report an error:
Privatefunctioninit (): void {varsp:Sprite=newSprite (); addChild (sp);}
The code is as follows:
TypeError:Error#1034: cast type failed: unable to convert flash.display::Sprite@156b7b1 to mx.core.IUIComponent.
This is because the FlexaddChild method of Application is not completely inherited from DisplayObjectContainer
Application → LayoutContainer → Container → UIComponent → FlexSprite → Sprite → DisplayObjectContainer
It was rewritten in Container:
The code is as follows:
PublicoverridefunctionaddChild (child:DisplayObject): DisplayObject
Although the parameter child is of type DisplayObject, it must implement the IUIComponent interface (which all Flex components implement) before it can be added.
If you want to add a Sprite to Application, you can first install it into a UIComponent, and then add the UIComponent:
Example:
The code is as follows:
Importmx.core.UIComponent;privatefunctioninit (): void {varsp:Sprite=newSprite (); varuc:UIComponent=newUIComponent (); uc.addChild (sp); addChild (uc);} after reading this article, I believe you have some understanding of "what should be paid attention to when using the FlexaddChild () method". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.