与SWFLoader一起使用时,警报会出现PopUpManager错误

时间:2011-07-13 00:12:19

标签: flex swfloader

我正在使用SWFLoader加载swf文件。代码如下:

<?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:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <mx:SWFLoader source="alerttesting.swf"/>
</s:Application>

并给出了alerttesing.swf代码:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
            width="100%" height="100%" fontFamily="Arial" fontSize="12"
            xmlns:ilog="http://www.ilog.com/2007/ilog/flex"       
            xmlns:local="c7.views.apps.calendar.*"
            backgroundColor="#FFFFFF">

<mx:Script>
    <![CDATA[
        import mx.controls.Alert
        public function testingalerta():void{
            Alert.show("sa;lfks;aljfa;sljf");
        }
    ]]>
</mx:Script>
<mx:Canvas>
    <mx:VBox>
        <mx:Button click="testingalerta()"/>
        <mx:Button label="aslkdfjasj" click="{Alert.show('sdfslfjlsjf;asjfa;sj');}"/>   
    </mx:VBox>
</mx:Canvas>


</mx:Application>

每次点击按钮,我都会收到以下错误:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at mx.managers::PopUpManagerImpl/http://www.adobe.com/2006/flex/mx/internal::createModalWindow()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\PopUpManagerImpl.as:686]
    at mx.managers::PopUpManagerImpl/addPopUp()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\PopUpManagerImpl.as:401]
    at mx.managers::PopUpManager$/addPopUp()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\PopUpManager.as:193]
    at mx.controls::Alert$/show()[E:\dev\4.x\frameworks\projects\framework\src\mx\controls\Alert.as:618]
    at alerttesting/abcd()[C:\Users\zee\Adobe Flash Builder 4.5\calendar\src\alerttesting.mxml:12]
    at alerttesting/___alerttesting_Button1_click()[C:\Users\zee\Adobe Flash Builder 4.5\calendar\src\alerttesting.mxml:16]

您能解释一下我该如何解决这个问题。

此致 Zeeshan

2 个答案:

答案 0 :(得分:5)

杰森很亲密。您不仅需要导入PopUpManager,还必须使用它。

<fx:Script>
    <![CDATA[
        import mx.managers.PopUpManager;
        private var manager:PopUpManager;
    ]]>
</fx:Script>

我找到了答案here

答案 1 :(得分:1)

我认为您只需要导入mx PopUpManager。

尝试向您的应用添加导入功能:

    <fx:Script>
        <![CDATA[
            import mx.managers.PopUpManager;
        ]]>
    </fx:Script>