I just now tracked down a bug in my code to the fact that the creationComplete event is not being raised by class Player.
Grid.mxml:
m_arrSpaces[4][4].entities.addItem(new Player());
Player.mxml:
<?xml version="1.0" encoding="utf-8"?>
<Entity xmlns="entities.*" xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="onCreationComplete">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function onCreationComplete():void {
Alert.show("cration");
m_imgActiveImage = imgUp;
}
]]>
</mx:Script>
I know that the line in Grid.mxml is being run and that the Player object is being added to m_arrSpaces[4][4].entities. I also know that Player.onCreationComplete() is never being called. Wth?
EDIT: Wait, it’s doing the same thing even when I correct the typo and include the parantheses in the MXML tag, as in:
creationComplete="onCreationComplete()"
EDIT: Oh, yeah, here’s the code for Entity:
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="onCreationComplete()">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Image;
import spaces.Space;
protected var m_imgActiveImage:Image;
public function get activeImage():Image {
return m_imgActiveImage;
}
private function onCreationComplete():void {
width = Space.SPAN - 4;
height = width;
}
]]>
</mx:Script>
</mx:Canvas>
you have this:
creationComplete=”onCreationComplete”
and it should be:
creationComplete=”onCreationComplete()”
did a quick test on new application with and alert and never reached the onComplete() method.