Showing posts with label tutorial. Show all posts
Showing posts with label tutorial. Show all posts

5/12/2009

flex DragManager

在flex 裡面要做drag,除了幾個原來就有implement drag的controller以外,
還可以利用DragManager來處理

假設物件A要拖到容器B裡面,用Drag Manager的話,最基本的用法就是:

  1. B listen DRAG_ENTER 事件
  2. B listen DRAG_DROP 事件
  3. A listen MOUSE_MOVE 事件
我在網路上找到了一個很好sample code: flex 2 Drag and Drop 練習

然而實作的時候卻發現一個大問題
假設我的容器B長這樣:
<mx:Canvas id="playground" width="300" height="300"></mx:Canva>
測試時發現, DRAG_ENTER完全沒有被觸發!!!不死心繼續找,終於在某次發現是background,是background啊!!

只要在attribute裡面設定了backgroundColor或backgroundImage,就可以讀得到了!!!
如果不設background只設border,那只有在經過border(有畫出來的時候)才會觸發DRAG_ENTER event!!!!


所以這時候就出現一個問題了,如果我就是不要background怎麼辦,
目前我只能用繞道的方式解決,也就是除了設定background以外,另外再加上:
backgroundAlpha="0"

呼!!

7/23/2008

[flex] 設定LinkBar跟ToggleBar中中label的字型

參考網址: (link)

在flex 2中,設定linkbar的字型只需要使用如下的CSS:
LinkBar {
  fontWeight: normal;
}

但是同樣方法在flex 3中一直不work,找了好久才在adobe的bug report中找到
新版flex 設定方式如下:
LinkBar {
  linkButtonStyleName: regularFontWeight;
}
.regularFontWeight {
  fontWeight: normal;
}


也就是說多加一層的連結方式,在bar底下設定button對應的CSS style name,
大概是希望讓Bar跟Button的工作分得更清楚吧(不過我比較喜歡flex2的作法就是了:P)

7/16/2008

flex 學習筆記(一) - MXML

MXML架構:
與XML大致相同 -
1. 由一個root node開始:
2. 需要有完結的註記,如: 或是

NameSpace:
跟C++、Java的name space 一樣,不過MXML 將使用的Name Space定義在
<NameSpace: ComponentName></NameSpace: ComponentName>
如果不寫的話表示使用預設的Name Space,也就是mx

Component:
幾乎都包含id這個attribute ,以達到data binding或用ActionScript控制目的,id的命名原則與一般變數命名原則相同

Event Handler:
inline event handler ,如:<mx:button id="sampleButton" Click="處理的事件"/>

Data Binding:
用{id_Name.attributeName}將某欄位的值與另一個component的值Bind住,
如:
<mx:Application>
<mx:TextInput id="input"/>
<mx:Text id="output" text="{input.text}"/>
</mx:Application>