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