facebook twitter hatena line email

Flash/flex4

提供: 初心者エンジニアの簡易メモ
2015年5月20日 (水) 03:17時点における127.0.0.1 (トーク)による版 (ページの作成:「==リファレンス== http://help.adobe.com/ja_JP/AS3LCR/Flex_4.0/ ==sperkタグリファレンス== http://help.adobe.com/ja_JP/AS3LCR/Flex_4.0/spark/components/packag...」)

(差分) ←前の版 | 最新版 (差分) | 次の版→ (差分)
移動: 案内検索

リファレンス

http://help.adobe.com/ja_JP/AS3LCR/Flex_4.0/

sperkタグリファレンス

http://help.adobe.com/ja_JP/AS3LCR/Flex_4.0/spark/components/package-detail.html

mxタグリファレンス

http://help.adobe.com/ja_JP/AS3LCR/Flex_4.0/mx/controls/package-detail.html

helloworld

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
         xmlns:s="library://ns.adobe.com/flex/spark"
         xmlns:mx="library://ns.adobe.com/flex/mx"
         minWidth="550" minHeight="400" creationComplete="initApp()">
  <fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
  </fx:Declarations>
  <fx:Script>
    <![CDATA[
    import flash.events.Event;
    public var items:Array = new Array();
    public function initApp():void {
    }
    private function click1(event:Event):void {
      trace("test");
    }
    ]]>
  </fx:Script>
  <s:Label text="helloworld" />
  <s:Button label="click1" click="click1(event)" y="20" />
</s:Application>

グループ分け

<s:VGroup x="50" y="50">
       <s:VGroup>
               <s:Button label="縦方向ボタン1" />
               <s:Button label="ボタン2" />
               <s:Button label="ボタン3" />
       </s:VGroup>
       <mx:HRule width="100%"/>
       <s:HGroup>
               <s:Button label="横方向ボタン4" />
               <s:Button label="ボタン5" />
               <s:Button label="ボタン6" />
       </s:HGroup>
</s:VGroup>

グループを非表示

<s:VGroup visible="false">
</s:VGroup>

外部as使用

Main.mxml
<fx:Script source="Main.as" />

Main.as
import flash.events.Event;
private function click1(event:Event):void {
 trace("test");
}

タグの属性をasから変更する

<s:Label id="l1" text="off" />
this.l1.text="on";

applicationにアクセス

import mx.core.FlexGlobals;
FlexGlobals.topLevelApplication.buttonid1.label = "test";

Main.mxmlのthisのクラス名

var _stage:Main = this; // main.mxmlで呼び出したas内に記述

デフォルトのフォント変更

fontFamily="MS Pゴシック"を<s:Application>タグに追加

パネルにスクロールの付いたエリアを用意する

<mx:Panel id="panel1" title="" width="410" height="450">
 <s:Scroller id="scroller1" minViewportInset="0" width="401" height="401">
   <s:Group id="group1" width="100%" height="100%" />
 </s:Scroller>
</mx:Panel>

OK,Cancelボタン

// 警告
import mx.controls.Alert;
// 警告イベント
import mx.events.CloseEvent;
private function _onPressBtn(event:Event):void
{
  Alert.show("body", "title", Alert.OK | Alert.CANCEL, this, _alertBtn);
}
private function _alertBtn(event:CloseEvent):void
{
  if (event.detail == Alert.OK) {
    trace("OK");
  } else if (event.detail == Alert.CANCEL) {
    trace("CANCEL");
  }
}

ウィンドウサイズに合わせてスケール変更

<mx:Application>タグに追加します。
initialize="systemManager.stage.scaleMode=StageScaleMode.SHOW_ALL"