我的kclyComponent不是胎死腹中,一直有進行中,開發組件中遇到不少問題,這些都是因為Flash太多Undocumented的秘技,什麼都沒有說清楚,使大家白白浪費不少時間,所以我將遇到問題和解決方法整理在此,方便自己和其他人日後參考(由於我平日開發文檔都是英文,沒有時間翻譯,索性Copy and Paste,見諒,以後會陸續更新):
- Why UIObject can call dispatchEvent?
Check mx.core.ext.UIObjectExtensions, it calls UIEventDispatcher.initialize(ui); (line 51), so if your custom component is not UIObject based, you need to do your own EventDispatcher.initialize
- How to enable Live Preview for changing value inside Component Property Panel?
Put [Inspectable] in Getter/Setter Method, not in class property declaration. Check Inspectable Getters and Setters and Live Preview
- If the user resize the component during Live Preview, how to make the component reflect the change?
A method call setSize(w,h) must be defined in the component class or parent class.
- Custom component (not UIObject based) not work in Flash Player 6 when define [Inspectable] in Getter/Setter Method?
- Why multiple component instances of same type of component shared the same property when convert to compiled clip?
It is not that problem, see next question.
- Why attachMovie not work when convert to compiled clip?
All linkage symbol must be Movie Clip, if it is not export in 1st Frame, in Frame 2 of asset layer, the symbol type must be Movie Clip, too.
- Should I use a Button symbol if I need a button in a component?
Button symbol can be set linkage and attached by attachMovie(), however it cannot dynamically add onRelease such event handler.
If you use 4 frames Movie Clip (without 1st frame stop), it can dynamically add onRelease such event handler, "onRollOver frame change effect" will auto triggered, i.e. Movie Clip become a real Button. However, when converted to compiled clip, such "onRollOver frame change effect" will loss. Therefore, you need to handle onRollOver event for moving the Movie Clip to frame 2, also need to make 1st frame stop.
- Then, can I embed a Button inside Movie Clip for attach?
It is not a good solution because it is hard to add action to the Button. You cannot ask the designer to add some pre-defined function call on the Button, or using a pre-defined Button instance name.
|