Flex AIR Android 開発 トレーニングセミナー

2011年8月11日  
  • iOSアプリ開発のトレーニングセミナー
  • Androidアプリ開発のトレーニングセミナー
  • Flex4のカスタムコンポーネントのトレーニングセミナー
  • FlexやAIRのアプリケーション開発のトレーニングセミナー
  • AIR 3 Native Extension を使ったアプリケーション開発のトレーニングセミナー

申し込みはこちらから http://www.akabana.net

government,politics news,politics news,politics
 

Adobe Flash Player 11.2 beta 4 & AIR 3.2 beta 4

2012年1月20日  

Flash Player 11.2 beta 4
http://labs.adobe.com/technologies/flashplatformruntimes/flashplayer11-2/

AIR 3.2 beta 4
http://labs.adobe.com/technologies/flashplatformruntimes/air3-2/

playerglobal.swc
http://download.macromedia.com/pub/labs/flashplatformruntimes/flashplayer11-2/flashplayer11-2_p4_playerglobal_011912.swc

government,politics news,politics news,politics
 

Unity と Flashの連携

2011年12月24日  

Unity と Flashの連携させるために相互のメソッドを呼び出す方法があります。

ActionScript → Unity
GameObjectに対してsendMessageを呼び出せます。
※現状、引数をいれるとエラーになります。引数なしならOK

・Unity側の関数定義

function MethodName(data){
	_message = data;
}

・ActionScript側からの呼び出し

unityContent.sendMessage("GameObjectName","MethodName",data);

参考URL:GameObject.SendMessage
http://unity3d.com/support/documentation/ScriptReference/GameObject.SendMessage.html

Unity → ActionScript
Unityの中からActionScriptのメソッドも呼び出せます。

・ActionScript側での関数定義
IUnityContentHostを実装したクラスに関数型の変数を用意します。

public var MyFunction1:Function = _MyFunction1;

private function _MyFunction1(...args):void
{
}

・Unity側から呼び出し

Application.ExternalCall ("MyFunction1");

参考URL:Application.ExternalCall
http://unity3d.com/support/documentation/ScriptReference/Application.ExternalCall.html

government,politics news,politics news,politics
 

Unity GUI

2011年12月24日  

Unity は、GUI Scripting Guideというものがあります。
http://unity3d.com/support/documentation/Components/GUI%20Scripting%20Guide.html

下記のような感じで、ボタンやラベルなどが生成できます。

function OnGUI () {
	GUI.Box (Rect (10,10,100,90), "Loader Menu");

	if (GUI.Button (Rect (20,40,80,20), "Level 1")) {
		Application.LoadLevel (1);
	}

	if (GUI.Button (Rect (20,70,80,20), "Level 2")) {
		Application.LoadLevel (2);
	}
}

これをFlashコンテンツにしてAIRに入れると下記のようになります。

簡単なUIはそろっているのでSkinを変えたりすれば実用レベルだ。

簡単な作り方
1. [File]メニュー→[New Project]でプロジェクト作成
2. [Assets]メニュー→[Create]→[JavaScript]でスクリプトを定義
3. [GameObject]メニュー→[Create Empty]で左下の[Hierarchy]に追加
4. [Hierarchy]ビューに追加したGameObjectを選択する
5. [Component]メニュー→[Script]→[NewBehaviourScript]を選択
6. 右の[Inspector]ビューに[NewBehaviourScript]が追加
7. [Inspector]タブの[NewBehaviourScript]の歯車をクリックして[Edit Script]で編集可能
8. 上部真ん中の再生ボタンを押して実行

government,politics news,politics news,politics
 

Unity 3.5 Developer Preview

2011年12月24日  

Unity 3.5 Developer Previewが公開されました。
http://unity3d.com/unity/preview/

このリリースでは、Flash deployment アドオンが試すことができます。
UnityのコンテンツをFlashのStage3Dを使ったコンテンツとしてビルドすることができます。
サンプルで試してみましょう。
Unity 公式サイト サンプル
下記よりサンプルがダウンロードできます。Flashコンテンツに変換してみましょう。
http://unity3d.com/support/resources/example-projects/

1. Unityを起動します。

2. [File]メニューから[Build Settings...]をクリック

3. [Build Settings]ウィンド

4. Platformで[Flash Player]を選択

5. ビルド&実行
[Build]は、SWFファイル作成のみ
[Build And Run]は、SWFファイル作成してブラウザを起動

6. ブラウザのFlashPlayerで動作確認

7. Flashコンテンツに変換したフォルダを確認
下記に生成されたSWFファイルなどが入っています。
C:\Users\Public\Documents\Unity Projects\AngryBots
次に、そのサンプルをAIRで動かしてみましょう。
UnityShared.swcというActionScriptライブラリも自動生成されています。
このUnityShared.swcの中にあるクラスでUnityコンテンツSWFをロードします。

8. UnityShared.swcの中

  • com.unity.IUnityContent
    Unityコンテンツを表すインターフェイスです。
    このインターフェイスを通してUnityコンテンツにアクセスすることができます。
  • com.unity.IUnityContentHost
    Unityエンジン初期化の開始と完了をハンドリングできます。
  • com.unity.UnityContentLoader
    Unityコンテンツの専用ローダーです。
  • com.unity.UnityContentParams
    Unityコンテンツの専用ローダーのパラメータです。

9. UnityShared.swcの使い方
AIRプロジェクトを作成してlibsにUnityShared.swc入れます。
src配下にUnityコンテンツSWFを置きます。今回は、UnityコンテンツSWFをMain.swfです。

ポイント

  • backgroundAlpha=”0″
    Stage3Dは最背面にあるので、アプリケーションの背景は透明にします。

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                       xmlns:s="library://ns.adobe.com/flex/spark"
                       xmlns:mx="library://ns.adobe.com/flex/mx"
                       applicationComplete="init()"
                       backgroundAlpha="0"
                       implements="com.unity.IUnityContentHost">
    <fx:Script>
        <![CDATA[
            import com.unity.UnityContentLoader;
            import com.unity.UnityLoaderParams;

            import mx.core.UIComponent;
            import mx.events.FlexEvent;

            public var loader:UnityContentLoader;

            protected function init():void
            {
                var holder:UIComponent=new UIComponent();

                //Unityを読み込み設定
                var params:UnityLoaderParams=new UnityLoaderParams(
                    false, //scaleToStage
                    systemManager.stage.stageWidth, //unity width
                    systemManager.stage.stageHeight, //unity height
                    true, //usePreloader
                    true, //autoInit
                    true //catchGlobalErrors
                );

                loader=new UnityContentLoader("Main.swf", this, params);
                holder.addChild(loader);
                addElement(holder);
            }

            public function unityInitStart():void
            {
                //TODO
            }

            public function unityInitComplete():void
            {
                //TODO
            }
        ]]>
    </fx:Script>
</s:WindowedApplication>

10. AIRの実行
Stage3Dコンテンツなので、アプリケーション記述ファイルを下記のように修正します。

<renderMode>direct</renderMode>

government,politics news,politics news,politics
 

AIR for Android コンテンツルートViewの取得

2011年12月22日  

Android アプリのルートViewの取得

ViewGroup decor = (ViewGroup)this.getWindow().getDecorView();

Android アプリのコンテンツルートViewの取得

ViewGroup contentRoot = (ViewGroup)this.findViewById(android.R.id.content);

AIR for Android アプリのコンテンツルートViewの取得

ViewGroup contentRoot = (ViewGroup)activity.findViewById(android.R.id.content);
ViewGroup airContentGroup = (ViewGroup)contentRoot.getChildAt(0);

AIR for Android アプリのコンテンツルートViewの子供たち
たぶんAIRのアプリがここにおかれそう。

AIRWindowSurfaceView view =(AIRWindowSurfaceView)airContentGroup.getChildAt(0);

たぶんこのほかにもStageなんたらってクラスはここにViewが置かれると推測されます。

自前Stageなんたらって作るならこのairContentGroup に置きましょう。

government,politics news,politics news,politics