Flex コンパイラ拡張

2012年4月24日  

Flex SDK 4.6のコンパイラ拡張することができます。
これによって、メタデータによってクラスを自動生成したり
コンパイルの最後に後処理を書いたりすることができます。

拡張ポイント

  • extensions-prelink: SystemManagerサブクラスやFlexInitが生成される前
  • extensions-mxmlc: mxmlcコマンドの終わり
  • extensions-compc: compcコマンドの終わり
  • extensions-application: OEM API アプリケーションコンパイルの終わり
  • extensions-library: OEM API ライブラリコンパイルの終わり
  • extensions-pre-compile: コンパイルの前
  • コンパイラ拡張API

    コンパイラ拡張APIは、 flex2.compiler.extensions パッケージにあります。
    その配下に、拡張ポイント毎にインターフェイスが用意されています。

    コンパイラ拡張java作り方

    拡張ポイント毎にインターフェイスを実装します。

    public class TestPreCompileExtension implements IPreCompileExtension {
    	@Override
    	public void run(FileSpec arg0, SourceList arg1, Collection<Source> arg2,
    			SourcePath arg3, ResourceContainer arg4, ResourceBundlePath arg5,
    			CompilerSwcContext arg6, SymbolTable arg7, Configuration arg8,
    			SubCompiler[] arg9, PreLink arg10, Map arg11, List<Source> arg12) {
    
    		System.out.println("IPreCompileExtension:"+this);
    
    	}
    }
    
    public class TestPreLinkExtension implements IPreLinkExtension {
    
    	@Override
    	public void run(List<Source> arg0, List<CompilationUnit> arg1,
    			FileSpec arg2, SourceList arg3, SourcePath arg4,
    			ResourceBundlePath arg5, ResourceContainer arg6, SymbolTable arg7,
    			CompilerSwcContext arg8, Configuration arg9) {
    		System.out.println("IPreLinkExtension:"+this);
    
    	}
    
    }
    

    コンパイラ拡張jar作り方

    jarの中に入れるMANIFESTを下記のようにします。
    コンパイル拡張するクラスを記述する必要があります。

    Manifest-Version: 1.0
    Sealed: true
    Implementation-Title: Apache Flex SDK - MXML Compiler Extension
    Implementation-Version: 1.0.0
    Implementation-Vendor: AKABANA
    extensions-pre-compile: net.akb7.flex.compiler.ext.TestPreCompileExtension
    extensions-prelink: net.akb7.flex.compiler.ext.TestPreLinkExtension
    

    実行

    mxmlc -compiler.extensions.extension=MXMLExtension.jar Test.mxml
    

    結果

    設定ファイル "C:\Program Files (x86)\Adobe\Adobe Flash Builder 4.6\sdks\4.6.0_AIR33\frameworks\flex-config.xml" をロードしています
    IPreCompileExtension:net.akb7.flex.compiler.ext.TestPreCompileExtension@b86944
    IPreLinkExtension:net.akb7.flex.compiler.ext.TestPreLinkExtension@e69696
    IPreLinkExtension:net.akb7.flex.compiler.ext.TestPreLinkExtension@d85409
    IPreLinkExtension:net.akb7.flex.compiler.ext.TestPreLinkExtension@1cc7e90
    必要な RSL :
        http://fpdownload.adobe.com/pub/swz/flex/4.6.0.23201/framework_4.6.0.23201.swz (1 フェイルオーバー)。
        http://fpdownload.adobe.com/pub/swz/tlf/2.0.0.232/textLayout_2.0.0.232.swz (1 フェイルオーバー)。
        http://fpdownload.adobe.com/pub/swz/flex/4.6.0.23201/spark_4.6.0.23201.swz (1 フェイルオーバー)。
    D:\profile\apache_flex\workspace01\MXMLExtensionTest\Test.swf (41962 バイト)
    IMxmlcExtension:net.akb7.flex.compiler.ext.TestMxmlcExtension@5b04ae
    
     

Flex Mobile View Events

2012年4月12日  

Flex MobileにおいてViewがインスタンス化されて画面遷移する際のイベントです。

pushView()呼び出し後

Viewインスタンス後

{31}[Event type="tabFocusEnabledChange" ]
{31}[Event type="enabledChanged" ]

表示リストに追加

[31][Event type="added" bubbles=true cancelable=false eventPhase=2]

{31}[Event type="preinitialize"]
[31]createChildren()呼び出し
{31}[Event type="skinChanged"]
[31][Event type="added" bubbles=true cancelable=false eventPhase=3] skin
[31][Event type="added" bubbles=true cancelable=false eventPhase=3] skin.contentGroup
{31}[Event type="partAdded"]
[31][Event type="added" bubbles=true cancelable=false eventPhase=3] .skin.contentGroup.Button
{31}[Event type="contentCreationComplete"]
[31]childrenCreated()呼び出し
{31}[Event type="initialize"]
{31}[Event type="elementAdd"]navigator
[31]commitProperties()呼び出し
[31]measure()呼び出し
[31]updateDisplayList()呼び出し
{31}[Event type="creationComplete" ]

画面遷移エフェクト開始

{33}[Event type="effectStart"]

画面遷移エフェクト停止

{41}[Event type="effectEnd"]

[42]commitProperties()呼び出し

この二つはcommitPropertiesによって必要であれば呼び出されます
[42]measure()呼び出し
[42]updateDisplayList()呼び出し

popView()呼び出し後

{114}[Event type="_navigationChange_"]
{115}[Event type="includeInLayoutChanged"]

画面遷移エフェクト開始

{117}[Event type="effectStart"]

画面遷移エフェクト停止

{124}[Event type="effectEnd"]
{125}[Event type="includeInLayoutChanged"]
{125}[Event type="elementRemove"]navigator

表示リストから削除

[125][Event type="removed" bubbles=true cancelable=false eventPhase=2]

government,politics news,politics news,politics
 

Apache Flex – modules

2012年4月12日  

Adobe Flex から Apache Flexとなり下記で管理されるようになりました。
http://incubator.apache.org/flex/

その中でも今回はmodulesについてみていきましょう。

trunk/modules

modulesには下記のようなサブプロジェクトがあります。
もちろん、それらのソースとテストが入っています。
Apacheライセンスで修正したり改造したりできます。

  • antTasks
    FlexのコマンドをANTで使うためのflexTasks.tasks
  • asc
    ActionScriptコンパイラー
  • compiler
    mxmlcやcompcやasdocの大元となるmxmlc.jar
  • debugger
    Flex Debugerのfdb.jar
  • fxgutils
    fxgを扱うユーティリティ
  • swfutils
    SWFを扱うユーティリティ

情熱がとまりません。

government,politics news,politics news,politics
 

AIR 3.3 Beta – Simulator Support

2012年4月6日  

Adober AIR 3.3 で追加された Simulator Support 機能を使ってみましょう。

この機能はiOSのiPhoneSimulatorアプリを使うことで実機に転送せずにデバックできます。
なお、ネイティブ拡張のデバックはできません。

Simulator用パッケージ

パッケージのターゲットが増えました。
ipa-text-interpreter-simulator
ipa-debug-interpreter-simulator

イメージは今までの高速パッケージのipaがSimulatorで動きます。

_AIR33/bin/adt
 -package
 -target ipa-debug-interpreter-simulator
 -provisioning-profile ../Team.mobileprovision
 -storetype pkcs12
 -keystore my.p12 TestAIR33.app TestAIR33-app.xml TestAIR33.swf

Simulatorへインストール

Simulatorにインストールするには下記のようなコマンドになります。

device ios-simulatorは必ず付けます
platformsdkにはiPhoneSimulator用のSDKを指定します。

_AIR33/bin/adt
 -installApp
 -platform ios
 -platformsdk /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/
 -device ios-simulator
 -package TestAIR33.app

Simulatorで実行

Simulatorにインストールして実行するには下記のようなコマンドになります。
Simulator上から実行することも可能です。

device ios-simulatorは必ず付けます
platformsdkにはiPhoneSimulator用のSDKを指定します。
debuggerPortを指定するとFlashBuilderでデバックすることもできます。
appidは、AIRのアプリケーション記述ファイルのアプリのidを使用します。

_AIR33/bin/adt
 -launchApp
 -platform ios
 -platformsdk /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/
 -device ios-simulator
 -debuggerPort 7935
 -appid TestAIR33.debug

Simulatorへアンインストール

Simulatorからアンインストールするには下記のようなコマンドになります。
Simulator上から実行することも可能です。

device ios-simulatorは必ず付けます
platformsdkにはiPhoneSimulator用のSDKを指定します。
appidは、AIRのアプリケーション記述ファイルのアプリのidを使用します。

_AIR33/bin/adt
 -uninstallApp
 -platform ios
 -platformsdk /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/
 -device ios-simulator
 -appid TestAIR33.debug

Simulator用のネイティブ拡張

Simulator用にネイティブライブラリを作成して
extension.xmlのプラットフォームをiPhone-x86にします。

</extension>
    </platforms>
      <platform name="iPhone-x86">
...
      </platform>
    </platforms>
</extension>

government,politics news,politics news,politics
 

AIR 3.3 Beta – USB debugging for AIR iOS

2012年4月6日  

Adober AIR 3.3 で追加された USB debugging for AIR iOS 機能を使ってみましょう。
現状は、FDB による USB 経由のリモートデバッグが行えます。

デバッグ接続用TCP ポートの指定

adtを使ってパッケージする際に-listen オプションを使って
デバッグ接続に使用する TCP ポートを指定します。

adt -package -target apk-debug -listen 7936 -storetype pkcs12

実機にインストール

USB経由で実機にインストールします。
iTune,Organizer,構成ユーティリティなどでインストールします。

idbの起動

AIR 3.3から追加されたidbというプログラムを使用して
デバイスまたはエミュレーターからデスクトップコンピューターに TCP ポートに転送します。

idbは、AIR3.3/lib/aot/idb/idb にあります。

まず、接続した実機のデバイスハンドルを調べます。

> AIR3.3/lib/aot/idb/idb -devices

List of attached devices
Handle    UUID
    3    903ejk443jk43k434c0ef35c6da9342k33cef746289ba

UUIDを確認してデバイスハンドルが決まります。

次に、転送の設定を行います。
idb -forwardの引数はローカルポート リモートポート ハンドルです。
ローカルポート:fdbで接続するポート
リモートポート:デバッグ接続に使用する TCP ポート
デバイスハンドル:デバイスを識別する数字(idb -devicesで調べる)

> AIR3.3/lib/aot/idb/idb -forward 7935 7936 3

fdbの起動

fdbを使ってidbで開いたポート経由でアプリケーションに接続するために
まずは下記のコマンドを入力します。

fdb -p 7936

次に、fdbウインドでrunコマンドを入力します。

Adobe fdb (Flash Player Debugger) [build 14159]
Copyright (c) 2004-2007 Adobe, Inc. All rights reserved.
(fdb) run

そうするとアプリケーションに接続を試みます。
接続が成功すると下記のようになりますので、continueを入力して
アプリケーションをデバック実行します。

(fdb) run
Player connected; session starting.
Set breakpoints and then type 'continue' to resume the session.
[SWF] DebugExample.swf - 32,235 bytes after decompression
(fdb) continue

参考URL

コマンドラインデバッガの使用
http://livedocs.adobe.com/flex/3_jp/html/help.html?content=debugging_03.html

FDB による USB 経由のリモートデバッグ
http://help.adobe.com/ja_JP/air/build/WS901d38e593cd1bac7b2281cc12cd6bced97-8000.html

fdbデバッガの使い方
http://d.hatena.ne.jp/octech/20080410

government,politics news,politics news,politics