3

Flex Mobile 4.6 (Flash Builder 4.6) で StageWebView を表示する際に問題が発生しました。動的に作成すると、イベントは適切に呼び出されますが、何も表示されません。コードは次のとおりです。

<components:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
             xmlns:s="library://ns.adobe.com/flex/spark" 
             xmlns:components="spark.components.*" 
             actionBarVisible="false"
             title="ActivityView"
             creationComplete="init()"
             >
<components:layout>
    <s:BasicLayout/>
</components:layout>
<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
    <![CDATA[
        private var webView:StageWebView;

        protected function init():void {
            webView = new StageWebView();
            webView.stage = this.stage;
            webView.viewPort = new Rectangle(5, 20, screen.width-10, screen.height-40);
            webView.addEventListener(Event.COMPLETE, onURLLoadComplete);
            webView.addEventListener(LocationChangeEvent.LOCATION_CHANGE, onLocationChange);
            webView.loadURL("http://google.com");
        }

        protected function onURLLoadComplete(event:Event):void
        {
            trace("Load Complete");
        }

        protected function onLocationChange(event:LocationChangeEvent):void
        {
            trace("Location change: " + event.location);
        }

    ]]>
</fx:Script>
</components:View>
4

5 に答える 5

0

StageWebView を追加する最も安全な方法は、createdChildren() (親ビューの幅と高さが 0 になるため、Web ビューの幅と高さを手動で定義する必要があります) または viewActiveEvent 状態で StageWebView を追加することだと思います。

Judah は、非常に使いやすい非常に優れた WebView クラスを作成しましたhttp://www.judahfrangipane.com/blog/2011/01/16/stagewebview-uicomponent/

お役に立てれば

于 2013-12-19T23:53:43.610 に答える
0

このようにステージを追加できます...

private var _stage : Stage;

private function added_to_stage_handler():void
{
     _stage = this.stage;
     initStage();
}
private function initStage() : void
{
     webView.stage = _stage;
}
于 2014-03-29T18:24:57.633 に答える
0

代わりに FlexGlobals.topLevelApplication.stage を使用できます。

webView.stage = FlexGlobals.topLevelApplication.stage;

于 2013-04-04T15:05:51.467 に答える
0

webView.stage = this.stage;

creationCompleteイベント ハンドラーにある場合は、this.stageまだ null です。

イベントハンドラーのinit()内部に配置する必要があります。addedToStage

于 2013-01-19T01:53:16.597 に答える