Add a Sprite object to a flex iner

Source: Internet
Author: User

In Flex, adding a Sprite directly to a iner (for example, canvas panel) object does not work.

For exampleCode:

<Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute">
<Mx: SCRIPT>
<! [CDATA [
Import com. roguedevelopment. Pulse. pulseengine;
Import com. roguedevelopment. Pulse. Simple. simpleparticipant;
Import MX. Core. flexsprite;
Public Function showit (E: Event): void
{
VaR BG: flexsprite = new flexsprite ();
Canvas. addchild (BG );
}
]>
</MX: SCRIPT>
<Mx: canvas x = "35.5" Y = "20" width = "377" Height = "289" id = "canvas">
<Mx: button x = "10" Y = "20" label = "show! "Id =" btnshow "Click =" showit (event) "width =" 65 "/>
</MX: canvas>
</MX: Application>

A type error is reported.

Typeerror: Error #1034: Type coercion failed: cannot convert MX. Core: flexsprite @ 40b5271 to MX. Core. iuicomponent.

Rawchildren attribute should be used

Public Function showit (E: Event): void
{
VaR BG: flexsprite = new flexsprite ();
Canvas. rawchildren. addchild (BG );
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.