2009. február 20., péntek

getObjectsUnderPoint fails to work

getObjectsUnderPoint fails to work for some reason, when the movie is loaded into a flex application and it is called in a nested movie clip.
Flex -> app.swf -> [movieclip].getObjectsUnderPoint: returns fail things
Solution is to always call getObjectsUnderPoint on the stage instance!
Flex -> app.swf -> [stage].getObjectsUnderPoint: returns good things
But watch out to stage instance, because when swf is loaded and the creator of the main class is called, there is no stage property set!
Implement an init() method that is about to call from flex on the SWFLoader.complete event.

// flex:
private function swfLoaderComplete(event:Event):void
{
contentLoader.content["init"].apply();
}

// SWF main class:
public function init():void
{
stage.addEventListener(MouseEvent.MOUSE_MOVE, stageMouseMove);
}

Nincsenek megjegyzések: