0

我在 Flash Builder 4.5 上构建了一个简单的基于 Flex 视图状态的视频应用程序。有4个状态。每次我从 State1->State2->State3 或 State1->State2->State4 去时,Internet Explorer 中的内存都会增加,但不会释放。我没有释放什么?

我是否必须为每个状态手动释放每个元素及其事件侦听器?

我安装了 Flash Player 10,2,153,1 版本。

如果您想构建应用程序并运行,请在此处下载源代码。

这是核心代码:

<?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"
               width.State1="1024" height.State1="768"
               width.State2="1024" height.State2="768"
               width.State3="1024" height.State3="768"
               width.State4="1024" height.State4="768">

    <fx:Script>
        <![CDATA[
            protected function button1_clickHandler(event:MouseEvent):void
            {
                // TODO Auto-generated method stub
                currentState='State2';
            }

            protected function button2_clickHandler(event:MouseEvent):void
            {
                // TODO Auto-generated method stub
                currentState='State3';
            }

            protected function button3_clickHandler(event:MouseEvent):void
            {
                // TODO Auto-generated method stub
                currentState='State1';
            }

            protected function button4_clickHandler(event:MouseEvent):void
            {
                // TODO Auto-generated method stub
                currentState='State2';
            }

            protected function button5_clickHandler(event:MouseEvent):void
            {
                // TODO Auto-generated method stub
                currentState='State4';
            }

        ]]>
    </fx:Script>

    <s:states>
        <s:State name="State1" />
        <s:State name="State2"/>
        <s:State name="State3"/>
        <s:State name="State4"/>
    </s:states>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:Button includeIn="State1" x="405" y="175" width="227" height="73" label="Music List"
              click="button1_clickHandler(event)" fontSize="30" itemDestructionPolicy="auto" />
    <s:Label includeIn="State1" x="440" y="61" fontSize="30" text="Main State" itemDestructionPolicy="auto"/>
    <s:Label includeIn="State2" x="409" y="34" fontSize="30" text="Classical Video" itemDestructionPolicy="auto"/>
    <s:Button includeIn="State2" x="328" y="151" width="369" height="91"
              label="Beethoven - &quot;Für Elise&quot;" click="button2_clickHandler(event)"
              fontSize="30"
              itemDestructionPolicy="auto"
              />
    <s:VideoPlayer includeIn="State3,State4" x="0" y="67" width="1024" height="530" autoPlay="false"
                   loop="true" scaleMode="stretch" source="assets/Beethoven__Für_Elise.mp4"
                   source.State4="assets/FOUR_SEASONS_VIVALDI_LANDSCAPES_AND_MUSIC.mp4"
                   itemDestructionPolicy="auto"
                   />
    <s:Button includeIn="State3,State4" x="2" y="14" width="240" height="45" label="Return to Main"
              click="button3_clickHandler(event)" fontSize="30"
              itemDestructionPolicy="auto"
              />
    <s:Button includeIn="State3,State4" x="338" y="629" width="348" height="63" label="Return to classical"
              click="button4_clickHandler(event)" fontSize="30"
              itemDestructionPolicy="auto"
              />
    <s:Button includeIn="State2" x="326" y="287" width="371" height="81"
              label="Vivaldi – “Four Seasons”" click="button5_clickHandler(event)" fontSize="30"
              itemDestructionPolicy="auto"
              />
</s:Application>

从检测游荡对象(http://help.adobe.com/en_US/flashbuilder/using/WSe4e4b720da9dedb5510654d812e4d126514-8000.html#WS6f97d7caa66ef6eb1e63e3d11b6c4d0d21-7ee8)查看 游荡对象视图

从“游荡对象视图”中最顶层对象 的对象引用(http://help.adobe.com/en_US/flashbuilder/using/WSe4e4b720da9dedb5510654d812e4d126514-8000.html#WS6f97d7caa66ef6eb1e63e3d11b6c4d0d21-7eef )查看对象引用视图

我检查了“控制在视图状态下创建的对象的缓存”的文档并设置了 itemDestructionPolicy="auto"。它仍然在缓存对象并且内存没有被释放,如任务管理器中所见。

4

0 回答 0