PDA

View Full Version : loaded object x & y positions


inquizard
03-25-2008, 11:20 PM
Hi,

wondering if anyone could shine some light on my ignorance? - just a generally answer would be a great help...

I've got 2 swf files with objects in them which have their positions on the screen controlled by a seperate class - one is the holder swf with loader and the other i intended to be the content.

they both can have their size altered as they both have stage.resize listeners + the objects are controlled by the same listener.

When i had the content swf load into the holder swf, the output panel gave me an error 1009 and said a had a null object. Someone explained that the null object was me referring to the stage in the content swf - apparently only the holder swf would let references to the stage exsist.

i took out all references to the stage in the Content swf and the loader worked - except the loaded content wasnt where i wanted them to be...

my question is if you can only refer to the stage in the holder swf, how do you control the position of the objects in the content swf without referring to their position in relation to the stage?

any answers would be appreciated.

thanks.

jaga
03-25-2008, 11:44 PM
It isn't that you can never refer to the stage, just that you cannot refer to the stage until after it has been added to the stage.

In your constructor have

addEventListener(Event.ADDED_TO_STAGE, stageActive);

function stageActive(evt:Event):void {
// NOW you can refer to stage
stage.addEventListener(Event.RESIZE, resizeHandler);
}

function resizeHandler(evt:Event):void {
// Your code here
}