Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
Adobe Flex SDK Previous
-
Affected OS(s): All OS Platforms
Affected OS(s): All OS Platforms
Browser: Internet Explorer 8.x
Language Found: English
Description
Steps to reproduce:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.managers.PopUpManager;
protected function button1_clickHandler(event:MouseEvent):void
]]>
</fx:Script>
<s:Button click="button1_clickHandler(event)"/>
<s:TitleWindow id="w" bottom="10"/>
</s:Application>
1. using PopUpManager
Error in the code:
public function centerPopUp(popUp:IFlexDisplayObject):void
{
if (popUp is IInvalidating)
IInvalidating(popUp).validateNow();
const o:PopUpData = findPopupInfoByOwner(popUp);
// If we don't find the pop owner or if the owner's parent is not specified or is not on the
// stage, then center based on the popUp's current parent.
var popUpParent:DisplayObject = (o && o.parent && o.parent.stage) ? o.parent : popUp.parent;
if (popUpParent)
{
var systemManager:ISystemManager = o.systemManager;
.
.
.
.
If const "o" is null, popUpParent is set to popUp.parent as stated by condition above.
However in next step you assume that const "o" exists because you're asking for o.systemManager, but o is null.
Therefore: TypeError: Error #1009: Cannot access a property or method of a null object reference
Fix:
public function centerPopUp(popUp:IFlexDisplayObject):void
{
if (popUp is IInvalidating)
IInvalidating(popUp).validateNow();
const o:PopUpData = findPopupInfoByOwner(popUp);
var popUpParent:DisplayObject = (o && o.parent && o.parent.stage) ? o.parent : popUp.parent;
if (popUpParent)
{
var systemManager:ISystemManager;
if (o != null)
else if (popUpParent.hasOwnProperty("systemManager"))
{ systemManager = popUpParent["systemManager"]; }else if (popUpParent is ISystemManager)
{ systemManager = popUpParent as ISystemManager; } if (!systemManager)
return; // or throw exception maybe ?
.
.
.
.