WebView加载麻烦,Flash Builder 4.6

时间:2012-03-23 17:41:17

标签: flash flex mobile flash-builder

我是新手,但渴望学习。我目前正在使用以下代码。我的应用程序是从rss feed中提取xml数据。到目前为止,一切都正确显示,除非我按下后退按钮返回到主视图。

返回的加载时间非常慢,我的问题是,如何改善加载时间,使其几乎是即时的,而不是几秒钟?

<fx:Script>
    <![CDATA[
        import mx.graphics.codec.JPEGEncoder;

        import spark.components.Image;
        import spark.events.ViewNavigatorEvent;
        protected function button1_clickHandler(event:MouseEvent):void
        {
            navigator.popView();
        }


        protected function view1_viewActivateHandler(event:ViewNavigatorEvent):void
        {
            webView.loadString(data.description);
        }

        protected function view1_viewDeactivateHandler(event:ViewNavigatorEvent):void
        {
            var bitmap:BitmapData = new BitmapData(webView.webView.viewPort.width, webView.webView.viewPort.height);

            webView.webView.drawViewPortToBitmapData(bitmap);

            webView.webView.stage = null;

            var jpg:JPEGEncoder = new JPEGEncoder();

            var img:Image = new Image();

            img.source = jpg.encode(bitmap);

            img.x = 8;
            img.y = 24;

            addElement(img);
        }

    ]]>
</fx:Script>

<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>

<s:navigationContent>
    <s:Button label="Back" click="button1_clickHandler(event)"/>
</s:navigationContent>

<controls:WebView left="8" right="8" top="24" bottom="8" id="webView"  />

<s:Label x="7" y="7" fontSize="8" text="{data.link}"/>

0 个答案:

没有答案