PDA

View Full Version : Popup resize error


corbo950
07-23-2008, 12:20 AM
im trying to make the popup resize if the browser is resized i get an error but then if i click continue it works. the error says

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at mx.managers::PopUpManagerImpl/findPopupInfoByOwner()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\ managers\PopUpManagerImpl.as:657]
at mx.managers::PopUpManagerImpl/centerPopUp()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\ managers\PopUpManagerImpl.as:341]
at mx.managers::PopUpManager$/centerPopUp()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\ managers\PopUpManager.as:184]
at open_swim/onResize()[C:\Documents and Settings\Administrator\My Documents\Flex Builder 3\Open Swim\src\open_swim.mxml:52]
at open_swim/___open_swim_Application1_resize()[C:\Documents and Settings\Administrator\My Documents\Flex Builder 3\Open Swim\src\open_swim.mxml:18]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\ core\UIComponent.as:9051]
at mx.core::UIComponent/dispatchResizeEvent()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\ core\UIComponent.as:6912]
at mx.core::UIComponent/setActualSize()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\ core\UIComponent.as:6541]
at mx.managers::SystemManager/initializeTopLevelWindow()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\ managers\SystemManager.as:2456]
at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::docFrameHandler()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\ managers\SystemManager.as:2330]

here is my code:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*"
creationComplete="applicationStart();" resize="onResize(event)">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
import mx.events.ResizeEvent;

public var loginPopUp:login = new login();

private function applicationStart():void
{
PopUpManager.addPopUp(loginPopUp, this, true),
PopUpManager.centerPopUp(loginPopUp);
}

private function onResize(event:Event):void
{
if(loginPopUp)
{
PopUpManager.centerPopUp(loginPopUp);
}
}
]]>
</mx:Script>

drkstr
07-23-2008, 09:00 AM
This is a guess, but I think it's because you are instantiating loginPopUp in the initialization stage which means it may try to center before it's created (if(loginPopUp ) will always be true). Try instantiating it in applicationStart() instead.


Best Regards,
~Aaron

corbo950
07-23-2008, 08:45 PM
wait what do u mean instencing it in application start wouldnt that just move it and not solve my problem? what do i need 2 put in the "if" to see if the popup is up or not?

corbo950
08-04-2008, 02:55 PM
i tried putting my fuction in application start and that doesnt work it isnt that the popup doesnt extist yet is that popupmanager hasnt loaded yet is there and if statment i can do to find out of the popupmanager has loaded?

drkstr
08-04-2008, 04:02 PM
What I meant was this line here:

public var loginPopUp:login = new login();

Means that loginPopUp will be true (not null) when onResize gets called, even though the popup has not been created yet. Instead, try this:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*"
creationComplete="applicationStart();" resize="onResize(event)">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
import mx.events.ResizeEvent;

public var loginPopUp:login;

private function applicationStart():void
{
loginPopUp = login (PopUpManager.createPopUp( this, login, true));
PopUpManager.centerPopUp(loginPopUp);
}

private function onResize(event:Event):void
{
if(loginPopUp)
{
PopUpManager.centerPopUp(loginPopUp);
}
}
]]>
</mx:Script>

This way, when onResize get's called it does not try to resize a popup that has not been created yet.


Best Regards,
~Aaron