2014年8月22日金曜日

FlexモバイルプロジェクトでHTMLを表示する方法

前回まではFlush CCを使っていましたが、画面遷移とかスプラッシュ画面とかが面倒なのでFlash CCでの開発はやめて、FlashBuilderを使うことにしました。

今回はFlash上にHTMLを表示する方法について。

<mx:HTML>を使おうとするとエラー
→Flexモバイルでは使えない?
http://help.adobe.com/ja_JP/flex/mobileapps/WSf3db6597adcd110e19124fcb12ab3a1c319-8000.html#WS8b1c39bd7e9fc3643c4a6fa12a8ac8b916-8000

stageWebViewを使うとモバイルアプリケーション内でブラウジング機能を利用することができます。


<?xml version="1.0" encoding="utf-8"?>
<s:View 
xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark" 
actionBarVisible="false" 
creationComplete="IframeHandler(event)" 
title="Map">

<fx:Script>
<![CDATA[
   //HTMLを読み込む
   protected function IframeHandler(event:FlexEvent):void
   {
    var webView:StageWebView = new StageWebView(); webView.viewPort = new Rectangle(0, 430, this.stage.stageWidth, this.stage.stageHeight);
webView.stage = this.stage;
    var htmlString:String = 
    "<!DOCTYPE HTML>" +
    "<html><body>" +
    "<p>てすとです</p>" +
    "</body></html>";
    webView.loadString(htmlString, "text/html");
   }
]]>
</fx:Script>
 (~中略~)
</s:View>

HTMLが表示されました。

0 件のコメント:

コメントを投稿