May 7 2012

flex library very good, wirte flex application 必備

https://github.com/flex-users/flexlib


Apr 5 2012

unable to bind to property的解决办法

http://bbs.9ria.com/thread-22017-1-1.html

see lower for better solution


Mar 29 2012

Flex alert no button, answer 2 work

http://stackoverflow.com/questions/666317/disable-yes-button-in-flex


Mar 23 2012

[flex] drag drop using list, very quick dev!

http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7cfd.html#WS7d89194359d2921c55a0a0ac1247d0abc10-8000


Mar 20 2012

Learn cairngorm, framework of flex

http://erinylin.blogspot.com/2008/12/flex-cairngorm.html


Mar 20 2012

why SwiftSuspenders and use Inject

http://cookbooks.adobe.com/post_Custom_metadata_in_three_simple_steps_-11907.html


Mar 14 2012

Embed movieClip in flex, on9, u will get error

//[Fault] exception, information=TypeError: Error #1034: Type Coercion failed: cannot convert tex_main_menu@6921e21 to flash.display.MovieClip.

solution 1 : use sprite

or

solution 2 : add one more frame in sprite , then it is movieClip

http://chrismweb.com/2011/03/20/problems-with-embedding-swfs-in-actionscript-or-flex/


Mar 13 2012

[robotlegs][flex] capture the event in command , so i can get the data which is bring by event

http://knowledge.robotlegs.org/discussions/questions/163-mediator-passing-event-to-command-is-null


Mar 13 2012

study 下 swiftsuspenders [as3][flex]

http://www.tillschneidereit.de/2009/09/21/introducing-swiftsuspenders/


Mar 5 2012

FLEX module的使用(转载)

1 ModuleLoader组件概述
1.1Module技术简介
flex的Modules技术是可以被flex程序使用的一个swf文件,它不能脱离程序独立运行,但是多个程序之间可以共享它。
flex的Modules技术将应用程序分割成小块、模块,主程序动态的加载所需要的模块。主程序在启动时并不全部加载所有的模块。当用户和模块没有交互的时候它不需要加载模块,同时它在模块不需要的时候可以卸载模块并释放内存和资源。[1]

flex的Modules技术主要有如下的优点:
让swf文件初始下载尺寸更小
让加载时间更短
对应用程序更好的封装性

1.2ModuleLoader组件功能
ModuleLoader组件是一种可视化的组件,方便开发人员在运行期间动态地加载和卸载module。
注:加载:从服务器下载到浏览器中

1.3 ModuleLoader类的继承关系
包:mx.modules[2]
ModuleLoaderInheritanceVBoxInheritanceBoxInheritanceContainerInheritanceUIComponent
注:ModuleLoader类暂无spark组件

相关类:
* IModuleInfo – module接口,所有的module都实现了此接口,可以提供module信息,比如url 和 加载状态。
* Module – 基于MXML的module的基类
* ModuleBase –基于ActionScript的module基类
* ModuleManager –一个系统只有一个此类,用于管理所有动态加载的module
* ModuleEvent – module相关事件

1.4 相似组件
(1)SWFLoader
ModuleLoader与swfLoader组件功能相同
ModuleLoader要求加载的SWF文件必须实现接口IFlexModuleFactory,这样,ModuleLoader通过工厂模式可以根据需要创建多个实例。
swfLoaderr组件对于SWF文件没有任何要求。

(2)ViewStack
ModuleLoader与ViewStack的作用比较类似,都用于加载多个不同模块。
ModuleLoader只能加载module,而且一次只能从服务器加载一个。ModuleLoader不必在初始化时携带加载所有的孩子组件,节省了下载量。
ViewStack一次加载多个容器,比如panel,cavas,但是可以延时初始化,以提高速度。ViewStack必须下载所有孩子组件后,只对当前使用的孩子组件进行初始化,加快显示速度。

(3)ModuleManager
ModuleLoader组件提供了可视化的加载和卸载module的操作。
ModuleManager类提供了低层次的处理Module的装载卸载以及事件响应等方法。这种方式比起纯粹的 ModuleLoader方式稍微复杂一点,但是ModuleManager提供了比ModuleLoader更加强大的能力来管理Module模块的加 载过程。

(4)RSL
RSL和module都是代码独立和复用机制[3]
Modules被编译到SWF文件内,可以加载和卸载
类库被编译到SWC文件内,可以在编译期间使用并编译到application中,并在application运行前加载

参考文献
[1]Modularapplicationsoverview.http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-799a.html
[2]ModuleLoader类.http://www.adobe.com/devnet/flex/tourdeflex/langref/mx/modules/ModuleLoader.html
[3] Flex Modules . http://www.flexafterdark.com/docs/Flex-Modules

2 ModuleLoader常用属性和方法
@font-face { font-family: “宋体”; }@font-face { font-family: “@宋体”; }p.MsoNormal, li.MsoNormal, div.MsoNormal { margin: 0cm 0cm 0.0001pt; text-align: justify; font-size: 10.5pt; font-family: “Times New Roman”; }div.Section1 { page: Section1; }
名称
分类
说明
applicationDomain
属性
ApplicationDomain类,将你的模块加载到哪个应用域,详见例3.9
url
属性
String类型。要加载的外部MXML module 的url.,详见例3.1和例3.2
loadModule
方法
格式:loadModule (url:String = null, bytes:ByteArray = null):void
加载module,详见例3.2
unloadModule
方法
格式:unloadModule():void
卸载module,释放内存,详见例3.2
error
事件
当module抛出错误时派发,参见例3.3
loading
事件
当ModuleLoader开始根据URL加载module时派发
progress
事件
Module加载过程中以一定的间隔周期派发,参见例3.3
ready
事件
当module完成加载时派发,参见例3.3
setup
事件
当module已下载(通过info()函数访问),但module并没有加载完成时(not ready)派发
unload
事件
当module卸载完成时派发,参见例3.3
urlChanged
事件
当ModuleLoader有了一个新的URL时派发

3 ModuleLoader使用方法
3.1 通过URL自动加载module和Alert使用举例
功能说明
通过loadModule加载外部的WelcomeModule,点击module中的alert,显示欢迎

关键代码
ModuleLoaderExam1.mxml

import mx.managers.PopUpManager;
private var pop:PopUpManager=new PopUpManager();
]]>

creationComplete="module1.applicationDomain=ApplicationDomain.currentDomain"/>

说明:
(1)如果在module中使用Alert,必须声明PopUpManager,并且实例化,原因未知。
(2) creationComplete事件表示,当加载完成时,将当前应用程序的域赋给module1,这个语句可以不加,为防万一,最好加上。

ModuleExam1.mxml
protected function openAlert_clickHandler(event:MouseEvent):void
{
Alert.show(“欢迎”, “欢迎点击Alert”, Alert.OK, this);
}

代码详见:ModuleLoaderExam1.mxml和ModuleExam1.mxml

3.2手工加载和卸载module举例
功能说明
通过设置URL属性,手工加载和卸载module
函数说明:loadModule (url:String = null, bytes:ByteArray = null):void
url:默认为null,表示当前要加载的module的URL,如果ModuleLoader的URL不为null,则该方法无效
bytes:module的SWF文件的字节数,可以通过URLLoader类获取

关键代码
ModuleLoaderExam2.mxml
public function loadModule21():void
{
if(mod_loader.url==null)
mod_loader.url = “example/ModuleExam21.swf”;
}
public function loadModule22():void
{
mod_loader.loadModule(“example/ModuleExam22.swf”);
}
public function unload():void
{
mod_loader.unloadModule();
mod_loader.url = null;//注意,卸载完成后必须设置URL为null,否则内存泄露
}

说明:
(1)mod_loader.url的值被修改后,直接触发重新加载module,不必再调用loadModule方法
(2) mod_loader.url = null;必须在卸载完成后加上,否则内存泄露

代码详见:ModuleLoaderExam2.mxml、ModuleExam21.mxml和ModuleExam22.mxml

3.3 module常用事件举例
功能说明
演示常用事件的处理,module的常用事件包括
Error:加载错误时引发
Ready:加载完成后引发
Progress:加载过程中定时引发
Unload:卸载完成后引发

关键代码
ModuleLoaderExam3.mxml
error="mod_loader_errorHandler(event)"
ready="mod_loader_readyHandler(event)"
progress="mod_loader_progressHandler(event)"
unload="mod_loader_unloadHandler(event)"/>
protected function mod_loader_errorHandler(event:ModuleEvent):void
{
lbRecord.text=lbRecord.text+”\n error:”+event.module.url;
}
protected function mod_loader_readyHandler(event:ModuleEvent):void
{
lbRecord.text=lbRecord.text+”\n ready:”+event.bytesLoaded+”bytes:”+event.bytesTotal;
}
protected function mod_loader_progressHandler(event:ModuleEvent):void
{
lbRecord.text=lbRecord.text+”\n progress:”+event.bytesLoaded+”bytes:”+event.bytesTotal;
}
protected function mod_loader_unloadHandler(event:ModuleEvent):void
{
lbRecord.text=lbRecord.text+”\n unload:”+event.bytesLoaded+”bytes:”+event.bytesTotal;
}
代码详见:ModuleLoaderExam3.mxml、ModuleExam21.mxml和ModuleExam22.mxml

3.4 Application调用module中的方法举例
功能说明
演示Application程序如何调用module中的方法
Application并不能直接访问module提供的方法,而是通过moduleLoader中的属性child来完成的。

关键代码
ModuleLoaderExam4.mxml

private function getTitle():void {
s = (m1.child as ModuleExam4).getModTitle();
}

ModuleExam4.mxml
public function getModTitle():String {
return “Child Module 1″;
}
说明:
(m1.child as ModuleExam4).getModTitle(),表示将m1中的属性child对应的对象强制转换为ModuleExam4类,再调用这个对象的方法。

代码详见:ModuleLoaderExam4.mxml和ModuleExam4.mxml

3.5 通过ModuleLoader的URL向module传递参数举例
功能说明
通过URL属性向module传递参数
GET参数基本上是这种格式,url=module1.swf?param1=value1&param2=value2

关键代码
ModuleLoaderExam5.mxml
public function submitToModule():void {
var s:String = “example/ModuleExam5.swf?”
+ “firstName=” +ti1.text + “&lastName=” + ti2.text;
m1.url = s;
}

ModuleExam5.mxml
//对参数进行过滤
var myPattern:RegExp = /.*\?/;
var s:String = this.loaderInfo.url.toString();
s = s.replace(myPattern, “”);
// 通过&拆分成数组name=value,保存为String类型数据
var params:Array = s.split(“&”);
// 显示数组中各个元素的值
var keyStr:String;
var valueStr:String;
var paramObj:Object = params;
for (keyStr in paramObj) {
valueStr = String(paramObj[keyStr]);
ta1.text += keyStr + “:” + valueStr + “\n”; //keyStr的值为0。1.2…
}
// 通过=拆分各个元素,并保存到变量salutation中
for (var i:int = 0; i < params.length; i++) {
var tempA:Array = params[i].split("=");
if (tempA[0] == "firstName") {
o.firstName = tempA[1];
}
if (tempA[0] == "lastName") {
o.lastName = tempA[1];
}
}
代码详见:ModuleLoaderExam5.mxml和ModuleExam5.mxml

3.6利用ActionScript接口实现Module与Application数据交互举例
功能说明
对于Module模块和Application对象间的通信,可以定义一个ActionScript接口,Module模块对象实现了这个接口中定义的方 法和属性,那么Application就可以访问这个接口中定义的属性和方法。接口中定义了Module模块对象和Application需要共享的数据 和方法,是两者间共同的一个契约,同时也实现了接口和实现的分离,达到了松耦合的目的。

接口类IModuleInterface.as:
public interface IModuleInterface extends IEventDispatcher {
function getModuleName():String;
function setAdjusterID(s:String):void;
function setBackgroundColor(n:Number):void;
}

ModuleExam6.mxml
模块必须实现以上接口,代码如下
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
implements="IModuleInterface"
layout="vertical" width="60%" height="60%">
public function setAdjusterID(s:String):void {
adjuster = s;
}
public function setBackgroundColor(n:Number):void {
bgcolor = n;
}
public function getModuleName():String {
return “module Insurance”;
}
说明:
这个module实现了接口中的三个方法。

ModuleLoaderExam6.mxml
private function applyModuleSettings(e:Event):void {
// m1.child 是接口IModuleInterface的具体实现对象
//var ichild:* = mod.child as IModuleInterface;
var ichild:IModuleInterface = m1.child as IModuleInterface;
if (m1.child != null) {
ichild.setAdjusterID(myId.text);
ichild.setBackgroundColor(myColor.selectedColor);
}
//从接口获取模块的名称
currentModuleName = ichild.getModuleName();
}
说明:
Application通过接口中的方法setAdjusterID和setBackgroundColor向module传递数据,
Module通过接口中的方法getModuleName向Application传递数据
代码详见:ModuleLoaderExam6.mxml、ModuleExam6.mxml和IModuleInterface.as

3.8 Module与Module之间数据交互举例
功能说明
一个Application如果具有两个Module,这两个Module可以通过Application传递数据。原理如下:




在module1中,你可以通过以下方法访问module2的属性和方法
parentApplication.module2.child.someProperty;
parentApplication.module2.child.someMethod();

关键代码
ModuleLoaderExam7.mxml

ModuleExam71.mxml
[Bindable]
public var m1:String=”module1″;
public function getProperty(event:MouseEvent):void {
lbmodule2.text=parentApplication.module2.child.m2;
}
public function getMethod(event:MouseEvent):void {
lbmodule2.text=parentApplication.module2.child.getModuleName();
}



说明
getProperty函数功能:直接访问module2中的属性m2
getMethod函数功能:通过调用module2中的函数getModuleName获取文本输入框的值

ModuleExam72.mxml
[Bindable]
public var m2:String=”module2″;
public function getModuleName():String {
return lbmodule2.text;
}

说明
m2与lbmodule2之间的绑定是单向的,修改m2的值,则改变lbmodule2的text,修改lbmodule2的值并不影响m2的值
代码详见:ModuleLoaderExam7.mxml、ModuleExam71.mxml和ModuleExam72.mxml

参考文献

Flex Modules . http://www.flexafterdark.com/docs/Flex-Modules

3.9 applicationDomain属性举例
功能说明
ApplicationDomain 类是一个容器,用于管理不同swf的安全域和类之间的关系。它们允许同一个类存在不同的ApplicationDomain。
ApplicationDomain是一个树形结构,Application所在的域(以下简称主域)就是它唯一的子域,使用Loader类加载swf时可以通过指定ApplicationDomain 参数将swf加载到不同的域(Domain)。
ApplicationDomain最根部的是系统域(system domain),主程序所在的域(以下简称主域)就是它唯一的子域。SWF 文件中的所有代码被定义为存在于应用程序域(ApplicationDomain)中。主应用程序在”当前域”中运行。”系统域”中包含所有应用程序域 (包括当前域),也就是,它包含所有 Flash Player 类。
所有应用程序域(除系统域外)都有关联的父域。主应用程序的应用程序域的父域是系统域。已加载的类仅在其父级中没有相关定义时才进行定义。不能用较新的定义覆盖已加载类的定义。

有两种方式可以访问 ApplicationDomain :
(1)ApplicationDomain.currentDomain
currentDomain是ApplicationDomain的静态变量,表示当前代码所在的域。例如:该变量在主程序里指向主域,在加载到子域的模块里和currentDomain则指向该模块所在的子域。
参见例3.1,通过URL自动加载module和Alert使用举例

虽然 ApplicationDomain有个 parentDomain 属性,但子域已经自动获得了父域的类定义,所以通过 ApplicationDomain.currentDomain 就可以获取父域定义了——包括主程序和加载到主域的共享库。(注:系统域不可直接访问,主域和所有新域即系统域子域的parentDomain属性为 null)
参见例3.8,Module与Module之间数据交互举例

(2)LoaderInfo类的applicationDomain属性
此方式可以访问任何方式加载的swf的 ApplicationDomain。对于主程序来说,加载到同域的库定义已经存在于 ApplicationDomain.currentDomain ,而模块的类主程序一般用不到。所以这种方式个人不推荐使用。
使用Loader类加载swf时可以通过指定 ApplicationDomain参数将swf加载到不同的域(Domain):
var loader : Loader = new Loader();
var context : LoaderContext = new LoaderContext();
/* 加载到子域(模块) */
context.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
/* 加载到同域(共享库) */
context.applicationDomain = ApplicationDomain.currentDomain;
/* 加载到新域(独立运行的程序或模块) */
context.applicationDomain = new ApplicationDomain();
loader.load(new URLRequest(“loaded.swf”), context);

(1)加载到子域(module)—参见图中的用法C
类似于“继承”,子域可以直接获得父域所有的类定义,反之父域得不到子域的。和继承关系不同的是,如果子域中有和父域同名的类,子域定义的类会被忽略而使用父域的定义的类。最大特点是可以动态的加载和移除。便于垃圾回收。
context.applicationDomain = new
ApplicationDomain(ApplicationDomain.currentDomain);
说明创建一个新的域,并变成当前域的子域

(2)加载到同域(RSL) —参见图中的用法B
就是在当前的ApplicationDomain添加新的类定义。类似集合里的合并关系。被加载swf里的所有类定义被合并到当前域中可以直接使用。和加载到子域相同,和当前域同名的定义也会被忽略。
context.applicationDomain = ApplicationDomain.currentDomain;

(3)加载到新域(独立运行的程序或模块) —参见图中的用法A
用的不是很多,实际上是单独的创建一个新的域和当前应用程序域平级。作为系统域的真子集。
swf载入指定域之前,先要检查该域及其父域中是否存在同名类,重复定义一概忽略。如果加载别人写的程序,或者使用旧版本的主程序加载新版本的模块,为避免类名冲突就要加载到新域独立运行以使用自己的类。
context.applicationDomain = new ApplicationDomain();
loader.load(new URLRequest(“loaded.swf”), context);
说明:创建了一个新的域,并加载到独立的程序loaded.swf中。

模块加载到同域不是一样可以吗?为何要加载到子域呢?
好处就在于,卸载一个加载到子域的模块时,只要确保清除所有到该模块的引用,模块的所有类定义将被垃圾回收(Garbage Collection)。

关键代码
ApplicationDomain中的currentDomain属性使用参见例3.1
ApplicationDomain中的parrentDomain属性使用参见例3.8

参考文献
1. Flex 中ApplicationDomain. http://www.wedoswf.com/questions/935
2. flash 中的 ApplicationDomain . http://chaimzane.javaeye.com/blog/470987
3. AS3应用程序模块化开发与ApplicationDomain . http://hereson.javaeye.com/blog/192337

3.10 module中使用PopUpManager和DragManager异常说明
通常将module加载为主域的一个子域,module里面的类都不属于主域的。比如第一个module载入了类PopUpManager,那么整合到 Application中,它就成了PopUpManager的拥有者,因为像这种manager都是单例的,如果另外一个模块稍后要使用这个 PopUpManager,就会引发运行时异常。
解决办法就是确保这些managers,比如PopUpManager和DragManager或者其他一些共享的服务是在application中定义的,这样就能确保所有模块都能够使用,代码如下:
import mx.managers.PopUpManager;
import mx.managers.DragManager;
private var popUpManager:PopUpManager;
private var dragManager:DragManager;

这项技术同时也被应用到组件中,当module第一次使用组件时,将在它自己的域中拥有这些组件的类定义。如果别的module试图使用这些已经被另一个 module使用的组件,它的定义将会不能匹配到现存的定义中。因此,为了避免组件的定义不匹配,在主应用程序中创建组件的实例,让所有的module去 引用。
但是这个坏处很明显,这些声明看起来莫名其妙,成为了一个个”木偶变量”。另一个解决方法是借助 ApplicationDomain 来共享这些代码和资源。在ModuleLoader 的creationComplete方法中加入moduleLoader.applicationDomain = ApplicationDomain.currentDomain; 表示将其加载到运行时库。对于使用ModuleManager,则可以在IModuleInfo的load方法里指定域。

参见:
flash.system.ApplicationDomain
flash.system.SecurityDomain


Mar 5 2012

Flex, Mate, Modules and GC – another approach

http://mate.asfusion.com/forums/topic.php?id=410


Mar 2 2012

Dump for as3

http://qops.blogspot.com/2007/06/dump-as3.html


Mar 2 2012

When to new your model?

http://joelhooks.com/2011/03/12/an-introduction-to-robotlegs-as3-part-2-models/

you dun need actually
public class AuthorModel extends Actor
{
private var _list:Array;

public function get list():Array
{
if(!_list)
initializeList();
return _list;
}

protected function initializeList():void
{
var twain:Author = new Author(“Twain”);
var poe:Author = new Author(“Poe”);
var plato:Author = new Author(“Plato”);
var fowler:Author = new Author(“Fowler”);

twain.quote = “Why, I have known clergymen, good men, kind-hearted, liberal, sincere” +
“, and all that, who did not know the meaning of a ‘flush.’ It is enough ” +
“to make one ashamed of one’s species.”;
fowler.quote = “Any fool can write code that a computer can understand. ” +
“Good programmers write code that humans can understand.”;
poe.quote = “Deep into that darkness peering, long I stood there, wondering, ” +
“fearing, doubting, dreaming dreams no mortal ever dared to dream before.”;
plato.quote = “All things will be produced in superior quantity and quality, and with greater ease, ” +
“when each man works at a single occupation, in accordance with his natural gifts, ” +
“and at the right moment, without meddling with anything else. “;

_list = [twain,fowler,poe,plato];
}
}

got it ?


Mar 1 2012

solve module load in flex, getStyle problem

Flex App 直接引用外部 Module 的問題
最近同事遇到一個 Flex 問題,只要 Module 內放了其它組件
執行就會出現各種奇怪 Error
後來發現是因為在 Main Application 直接引用編譯到 Module Class
然後又企圖用 ModuleLoader 再載入一次相同的 Module SWF
當然這樣做是錯誤的範例,Flash Builder 也會給予警告

Warning: Mod is a module or application that is directly referenced.
This will cause Mod and all of its dependencies to be linked in with MainApp.
Using an interface is the recommended practice to avoid this.

不要明確引用就正常了
不過還是覺得有點不合理,至少應該能正常執行吧

譬如以下的例子 MainApp.mxml


xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">

Mod;
]]>






直接引用到外部 Module,又企圖載入一次同一個外部 Module – Mod.mxml


xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="100%" height="100%">


隨著 Module 內放置組件不同,可能會得到以下各種錯誤訊息

Main Thread (Suspended: ArgumentError: Error #2004: 有一個參數無效。)
flash.display::Graphics/drawRect [no source]
spark.components.supportClasses::TextBase/updateDisplayList
mx.core::UIComponent/validateDisplayList
mx.managers::LayoutManager/validateDisplayList
mx.managers::LayoutManager/doPhasedInstantiation
mx.managers::LayoutManager/doPhasedInstantiationCallback

Main Thread (Suspended: TypeError: Error #1009: 無法存取 Null 物件參考的屬性或方法。)
mx.core::UIComponent/getStyle
mx.core::UIComponent/getConstraintValue
mx.core::UIComponent/get horizontalCenter
spark.layouts::BasicLayout/measure
spark.components.supportClasses::GroupBase/measure
mx.core::UIComponent/measureSizes
mx.core::UIComponent/validateSize
spark.components::Group/validateSize
mx.managers::LayoutManager/validateSize
mx.managers::LayoutManager/doPhasedInstantiation
mx.managers::LayoutManager/doPhasedInstantiationCallback
Flex ModuleLoader 預設載入外部 Module 時
是會從目前 ApplicationDomain 建立一個 child ApplicationDomain 作為載入之用
也就是說假如 Main App 已經包含一份 Module 定義
再載入同名類別,就會被前面的類別定義覆蓋
實際上,被 new 出來的實體其實是 Main App 內定義的

假如兩份定義完全一樣,應該也是要能正常執行吧
問題就是出在這裡了,用 ASV 分別去觀察兩個 SWF 內的 Module 類別
發現是不一樣的!

當 Flex Module 編譯為獨立 SWF 時
MXMLC Compiler 會塞入一些額外的 Metadata Tag, Code… 做初始化
可是 MainApp 內的 Module 定義少了這些動作,導致無法正常執行

解決的方式不難,ModuleLoader Ready 時
自己手動執行一下關鍵的初始動作就好了 – styleManager.initProtoChainRoots();

xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">

Mod;
]]>




ready="event.target.child.styleManager.initProtoChainRoots();" />


Mar 1 2012

robotlegs in module, 3 種方法解決

1. http://joelhooks.com/2010/05/02/modular-robotlegs/

裝呢個 addon, 共用同一個 injector,
但不能使用 module loader

min code of this method

http://blog.yoz.sk/examples/ModularRobotlegs/srcview/

2. http://labs.riamore.com/content/robotlegs/examples/dynmodules

可以 dynamic 了,但其實是將 module 的 applicationDomain hardcore 同 mainApp 一樣

3. http://ticore.blogspot.com/2011/10/robotlegs-module-issue.html

一人一個獨立 robotlegs,但要 hack 少少 code 先做到,其實都係 override 下 je :)


Feb 29 2012

asynchronous-processes-and-robotlegs [READ pls]

http://alecmce.com/library/asynchronous-processes-and-robotlegs


Feb 28 2012

change the stupid namespace from flashdevelop default template of mx

xmlns:mx=”library://ns.adobe.com/flex/mx”

It state is halo, if u dun change
or u cannot use canvas blah blah blah


Feb 28 2012

get URL by loaderInfo or BrowserManager

http://flexperiential.com/2010/05/06/browsermanager-returns-null/

for loaderInfo , pls see the comment


Feb 26 2012

flex 3 in flex 4

http://cnx.org/content/m34631/latest/


Feb 26 2012

advanced use module in flex, in enterprise scare

http://labs.bsb.com/2011/02/modularity-in-flex-enterprise-applications/


Feb 26 2012

compile module with flashdevelop and some tutorial about modules

http://smithfox.iteye.com/blog/827743

http://www.permadi.com/blog/2010/10/using-modules-in-flex-action-script-projects/

flex-modular-application-development-using-cairngorm-architecture
http://xebee.xebia.in/2010/10/11/flex-modular-application-development-using-cairngorm-architecture/


Feb 25 2012

using flashdevelop to compile module

http://www.ghostwire.com/blog/archives/compiling-module-swfs-using-flashdevelop/


Feb 25 2012

Flex Problem

急急。。。Flex4 Module中不能Alert?

http://bbs.airia.cn/thread-10383-1-1.html

ModuleLoader.loadPolicy
http://www.tink.ws/blog/flex-4-modules/

A flex code example using module
http://www.riameeting.com/examples/parsley_module/srcview/index.html

Create an ActionScript-Based Module
http://mijimiji.com/blog/?p=54


Feb 25 2012

good comment in a flex problem

http://flexbugs.wordpress.com/2010/06/18/flex-4-modules-bug/


Feb 17 2012

keep-generated-actionscript -> mxml to as3

http://saravananrk.wordpress.com/2008/05/26/keep-generated-actionscript-in-flex/


Feb 16 2012

unload module effectively FLEX

http://blogs.adobe.com/tomsugden/2010/02/how_to_unload_modules_effectively.html


Feb 16 2012

[FLEX] modular robotlegs !

http://joelhooks.com/2010/05/02/modular-robotlegs/


Feb 15 2012

view states using AS3 only, no mxml

http://www.digitalprimates.net/author/tapper/2006/03/14/creating-view-states-purely-in-as3/


Feb 15 2012

flex minimal

http://stackoverflow.com/questions/141288/possible-to-use-flex-framework-components-without-using-mxml


Feb 8 2012

as3 funny class as function, use a function to return a Class

http://jacksondunstan.com/articles/398


Feb 8 2012

trick on as2

dynamic new a movieClip with init var
http://www.jonnyreeves.co.uk/2007/05/movieclips-and-object-scope-in-as2/

WORTH to read, many FAQ about as2
http://www.senocular.com/flash/tutorials/faq/#newmovieclip

event receive and dispatch and delegate example
http://flash-creations.com/notes/asclass_eventdispatcher.php

hope example help
http://www.bit-101.com/blog/?page_id=1164

reference will be missed at first explanation
http://stackoverflow.com/questions/896335/referencing-movie-clip-class-instances-immediately-in-actionscript-2

EventDispatcher instantiate methods
http://archive.darronschall.com/weblog/2004/03/the-many-faces-of-eventdispatcher.html

container constructor first -> button constructor
container constructor want to call button stuff, but button hvnt construct
http://www.kirupa.com/forum/showthread.php?241544-AS2-0-Linkage-and-attachMovie-Woe


Feb 7 2012

open source as2 compiler

http://www.mtasc.org/


Jan 12 2012

wtf bitmapData

SWF 13+ (Flash Player 11, AIR 3) the practical limit is the amount of memory available. (The theoretical limit to width or height is the largest positive integer — divided by 20 to allow for twips, but you will hit memory limits long before reaching this size.)
SWF 10 (Flash Player 10, AIR 1.5) the maximum size for a BitmapData object is 8,191 pixels in width or height, and the total number of pixels cannot exceed 16,777,215 pixels. (So, if a BitmapData object is 8,191 pixels wide, it can only be 2,048 pixels high.)
SWF 9 (Flash Player 9, AIR 1.1) the limitation is 2,880 pixels in height and 2,880 pixels in width. If you specify a width or height value that is greater than 2880, a new instance is not created.

Flash Player 11 is very good :)
Flash Player 10 need alchemy :(
Flash Player 9 no byteArray, so no need think of playing dynamic image processing :( (


Jan 10 2012

WTF Flex 4.5.1 eat shit SDK for UIComponent

TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/addChildAt()
at fl.controls::BaseButton/drawBackground()
at fl.controls::LabelButton/draw()
at fl.core::UIComponent/drawNow()
at fl.controls::ScrollBar/draw()
at fl.core::UIComponent/callLaterDispatcher()

I know u meet this error

i know you read this:

http://joshblog.net/2008/02/10/how-to-use-the-flash-cs3-component-set-in-a-flex-builder-actionscript-project/

or this

http://de-co-de.blogspot.com/2008/03/wheres-my-skin.html

but still cant play the UIScrollbar
What i think is, i the past, i use this method still can use, i think it is the issue of flex sdk, okok,

i got it

// trick to bring in the skins for the button
sb.setStyle( “ScrollArrowDown_downSkin”, new ScrollArrowDown_downSkin());
sb.setStyle( “ScrollArrowDown_overSkin”, new ScrollArrowDown_overSkin());
sb.setStyle( “ScrollArrowDown_upSkin”, new ScrollArrowDown_upSkin());
sb.setStyle( “ScrollArrowUp_disabledSkin”, new ScrollArrowUp_disabledSkin());
sb.setStyle( “ScrollArrowUp_downSkin”, new ScrollArrowUp_downSkin());
sb.setStyle( “ScrollArrowUp_overSkin”, new ScrollArrowUp_overSkin());
sb.setStyle( “ScrollArrowUp_upSkin”, new ScrollArrowUp_upSkin());
sb.setStyle( “ScrollBar”, new ScrollBar());
sb.setStyle( “ScrollTrack_skin”, new ScrollTrack_skin());
sb.setStyle( “ScrollThumb_downSkin”, new ScrollThumb_downSkin());
sb.setStyle( “ScrollThumb_overSkin”, new ScrollThumb_overSkin());
sb.setStyle( “ScrollThumb_upSkin”, new ScrollThumb_upSkin());
sb.enabled = true;
sb.visible = true;

add this, where sb is the scrollbar object :)


Jan 9 2012

by pass as3 8191px problem

Core Concept : Dun draw in bitmap

Example:
in urUploader, Thumbnail can over 8191px, loadBytes is according to file size, so if file size too large, yr machine will hang.

private function genThumbnail():void {
			var l:Loader = new Loader();
			l.loadBytes(transcodeManager.baAlchemy);
			l.contentLoaderInfo.addEventListener(Event.COMPLETE, onThumbnailComplete);
		}

		private function onThumbnailComplete(e:Event):void {
			var b:Bitmap = MCUtil.scaledImage(Bitmap(e.target.content).bitmapData, new ThumbnailLayout().width);
			_thumbnail.addChild(b);

			var data:Object = { uploadJob : this };
			dispatchEvent(new UploadJobEvent(UploadJobEvent.THUMBNAIL_GENERATED, data));
		}

This is the scale function, so after scale to small size, now can draw :)

public static function scaledImage(bd:BitmapData, s:Number = 120) : Bitmap
        {
            var newWidth:Number;
            var newHeight:Number;
            var result:BitmapData;
            var bitmap:BitmapData = bd;
            var size:Number = s;
            var matrix:Matrix = new Matrix();
            try
            {
                if (bitmap.width > bitmap.height)
                {
                    newWidth = size;
                    newHeight = bitmap.height * (size / bitmap.width);
                }
                else
                {
                    newHeight = size;
                    newWidth = bitmap.width * (size / bitmap.height);
                }
                matrix.scale(newWidth / bitmap.width, newHeight / bitmap.height);
                result = new BitmapData(newWidth, newHeight);
                result.draw(bitmap, matrix);
                bitmap.dispose();
                return new Bitmap(result);
            }
            catch (e:Error)
            {
                trace("Scaled image error");
            }
            return null;
        }// end function

ref: photobox photobook program


Jan 5 2012

alchemy error : if range invalid …

http://forums.adobe.com/thread/37528

Ans:

4. Sep 23, 2010 5:30 AM (in response to boris.reitman)
Re: Range Error 1506 when CLibInit.init()
Dont init CLibInit twice. Insted use static value to hold it for reuse and refer to it. Worked for me.


Dec 27 2011

read write bytearray use in alchemy

http://blog.debit.nl/2009/03/using-bytearrays-in-actionscript-and-alchemy/


Dec 24 2011

alchemy gluegen : link C library to as3 :)

http://segfaultlabs.com/devlogs/alchemy-round-two


Dec 24 2011

advance alchemy article : about memory

http://bruce-lab.blogspot.com/2011/01/adobe-alchemy-hacks-access-memory-and.html


Dec 23 2011

gstate: alchemy memory

http://jasonbshaw.com/?p=183


Dec 23 2011

super strong flash guy

http://blog.tweenpix.net/


Dec 22 2011

alchemy, libjpeg ref

日文翻譯文,教你裝同 run
http://www.4ucode.com/Study/Topic/678551

http://www.4ucode.com/Study/Topic/677284

原文,日文
http://d.hatena.ne.jp/amachang/20081118/1227005285

教你用 libjpeg
http://blog.csdn.net/achellies/article/details/4238056

MUST WATCH
Blog
http://www.websector.de/blog/2009/06/21/speed-up-jpeg-encoding-using-alchemy/

config alchemy
http://wiki.zeropointnine.com/?n=FlashPlatform.Alchemy

how to include jconfig.h, jpeglib.h …
http://forums.adobe.com/message/1059134#1059134

using alchemy to do bubble sort
http://blog.comtaste.com/2010/07/adobe_alchemy_a_comparative_ex.html


Dec 22 2011

setup alchemy environment

http://blog.flexmaniak.pl/flex-libraries/alchemy/alchemy-installation-guide-for-windows

http://labs.adobe.com/wiki/index.php/Alchemy:Documentation:Getting_Started


Dec 21 2011

Super strong as3 developer! see his project for some hints to difficult problem

http://segfaultlabs.com/


Dec 19 2011

as3 <--> bridge <--> as2

http://www.jumpeyecomponents.com/Flash-Components/Various/ActionScript-Bridge-91/

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/LocalConnection.html

http://gskinner.com/blog/archives/2007/07/swfbridge_easie.html


Dec 15 2011

flash is suck in urlStream or fileRef.upload

urlStream is always good, it trigger the browser request to server, but very raw and cannot detect the upload progress (no progress event fire during upload) ( cal the speed and use Timer to pretend the progress bar )

but fileRef.upload is really poor, it use its user agent, so it is independent to browser, so no session can be save, it make a new session i think

judge yourself use which class then :)


Dec 12 2011

URL request in Flash

IE -> 用 domain 做 base-path
Firefox, chrome -> 用 swf 個 file 個 location 做 base-path

okok, 唔好煩,用死 absolute path, server_url + relative_url 好無 ?

Note Update :

用呢個 “.” d swf location 就會係 swf 個個位置


Nov 7 2011

as2 or other graphics technique, set Bounds in short code

if (_bounds != undefined) {
mc._x = Math.max(_bounds.xMin, Math.min(mc._x, _bounds.xMax));
mc._y = Math.max(_bounds.yMin, Math.min(mc._y, _bounds.yMax));
}


Nov 4 2011

as2 can do addEventListener and dispatchEvent too

normal use method:
http://flash-creations.com/notes/asclass_eventdispatcher.php

package method:
http://www.sakri.net/blog/2007/02/20/using-eventdispatcher-in-as2-the-as3-way/


Nov 3 2011

[as2] shadow filter in as2

http://www.webwasp.co.uk/tutorials/214/F8-click-by-click/index.php


Nov 3 2011

[as2] graphics algorithm in as2

http://www.video-animation.com/mx2k_01.shtml


Nov 2 2011

[as2] kill a mouse event function

_handle_layer.onMouseMove = undefined;


Nov 2 2011

[as2] onMouseDown和onMouseUp则不管鼠标在什么地方

http://hi.baidu.com/billypc/blog/item/ccbc97efcb981b212cf5341c.html


Nov 2 2011

[as2] some movieClip property you may always need

	function resetStartProps():Void {
		delete _startProps; //Aids in memory management
		_startProps = {};
		var sp = _startProps;
		var axisPoint_obj = this.axisPoint;
		var mdx = _targetObject._parent._xmouse - axisPoint_obj.x; //Distance to mouse along the x-axis
		var mdy = axisPoint_obj.y - _targetObject._parent._ymouse; //Distance to mouse along the y-axis
		var md = Math.sqrt(mdx * mdx + mdy * mdy); //Total distance to mouse
		var angleAxisToMouse = Math.atan2(mdy, mdx);

		var rdx = _targetObject._x - axisPoint_obj.x; //Distance between axis point and registration along the x-axis
		var rdy = axisPoint_obj.y - _targetObject._y; //Distance between axis point and registration along the y-axis

		var angle = _targetObject._rotation * (Math.PI / 180); //rotation translated to radians
		var rAngleAxisToMouse = angleAxisToMouse + angle; //Rotated (corrected) angle to mouse (as though we tilted everything including the mouse position so that the _targetObject is at a 0 degree angle)

		sp.centerX = this.centerX;
		sp.centerY = this.centerY;
		sp.axisX = axisPoint_obj.x;
		sp.axisY = axisPoint_obj.y;
		sp._x = _targetObject._x;
		sp._y = _targetObject._y;
		sp._xscale = _targetObject._xscale;
		sp._yscale = _targetObject._yscale;
		sp._rotation = _targetObject._rotation;
		sp.angle = angle;
		sp._xmouse = _targetObject._parent._xmouse;
		sp._ymouse = _targetObject._parent._ymouse;
		sp.angleAxisToMouse = (angleAxisToMouse + Math.PI * 2) % (Math.PI * 2);
		sp.distAxisToMouseX = Math.cos(rAngleAxisToMouse) * md;
		sp.distAxisToMouseY = Math.sin(rAngleAxisToMouse) * md;
		sp.distAxisToMouse = md;
		sp.distRegToCenterX = _targetObject._x - sp.centerX;
		sp.distRegToCenterY = _targetObject._y - sp.centerY;
		sp.distAxisToReg = Math.sqrt(rdx * rdx + rdy * rdy);
		sp.angleAxisToReg = Math.atan2(rdy, rdx);

		if (_bounds.xMax != undefined) { //If we need to constrain dragging to stay within a rectangle...
			var bnds = _targetObject.getBounds(_targetObject._parent);
			sp.xMin = _bounds.xMin + (_targetObject._x - bnds.xMin) + 1;
			sp.xMax = _bounds.xMax - (bnds.xMax - _targetObject._x) - 1;
			sp.yMin = _bounds.yMin + (_targetObject._y - bnds.yMin) + 1;
			sp.yMax = _bounds.yMax - (bnds.yMax - _targetObject._y) - 1;

			sp.angleAxisToTL = (Math.atan2(_bounds.yMin - axisPoint_obj.y, _bounds.xMin - axisPoint_obj.x) + (Math.PI * 4)) % (Math.PI * 2);
			sp.angleAxisToTR = (Math.atan2(_bounds.yMin - axisPoint_obj.y, _bounds.xMax - axisPoint_obj.x) + (Math.PI * 4)) % (Math.PI * 2);
			sp.angleAxisToBR = (Math.atan2(_bounds.yMax - axisPoint_obj.y, _bounds.xMax - axisPoint_obj.x) + (Math.PI * 4)) % (Math.PI * 2);
			sp.angleAxisToBL = (Math.atan2(_bounds.yMax - axisPoint_obj.y, _bounds.xMin - axisPoint_obj.x) + (Math.PI * 4)) % (Math.PI * 2);
		}

	}
/**********************************************/
    /*      get-set Function                      */
    /**********************************************/
     function get centerX():Number {
		return this.centerPoint.x;
	 }
	 function get centerY():Number {
		return this.centerPoint.y;
	 }
     function get centerPoint():Object {
		var p = {x:_localCenterX, y:_localCenterY};
		_targetObject.localToGlobal(p);
		_targetObject._parent.globalToLocal(p);
		return p;
	}
	function get axisX():Number {
		return this.axisPoint.x;
	}
	function get axisY():Number {
		return this.axisPoint.y;
	}
	function get axisPoint():Object {
		var p = {x:_localAxisX, y:_localAxisY};
		_targetObject.localToGlobal(p);
		_targetObject._parent.globalToLocal(p);
		return p;
	}

/*****************************************************************************/
    /*                                                                           */
    /*      This is the function to find the relative center Point               */
    /*                                                                           */
    /*****************************************************************************/
    function resetCenterPoint():Void {
		var rotation_num = _targetObject._rotation;
		_targetObject._rotation = 0; //We need to straighten it temporarily to measure accurately...
		var bounds_obj = _targetObject.getBounds(_targetObject._parent);
		var x1 = (bounds_obj.xMax + bounds_obj.xMin) / 2; //Find the center x-coordinate when the rotation is 0
		var y1 = (bounds_obj.yMax + bounds_obj.yMin) / 2; //Find the center y-coordinate when the rotation is 0
		var dx = x1 - _targetObject._x; //distance between the _targetObject's registration point and center point along the x-axis
		var dy = _targetObject._y - y1; //distance between the _targetObject's registration point and center point along the y-axis
		var radius = Math.sqrt((dx * dx) + (dy * dy)); //Find the distance between the _targetObject's registration point and the center point.
		var angle1_num = Math.atan2(dy, dx);
		var angle = (rotation_num * (Math.PI / 180)) - angle1_num; //Total angle that we're adding/moving (we have to subtract the original angle to just get the difference)
		var x = _targetObject._x + (Math.cos(angle) * radius);
		var y = _targetObject._y + (Math.sin(angle) * radius);
		_targetObject._rotation = rotation_num; //Re-apply the rotation since we removed it temporarily.
		var p = {x:x, y:y};
		_targetObject._parent.localToGlobal(p);
		_targetObject.globalToLocal(p);
		_localCenterX = p.x;
		_localCenterY = p.y;
	}

	/*****************************************************************************/
    /*                                                                           */
    /*      This is the function to find the relative X Y                        */
    /*                                                                           */
    /*****************************************************************************/
	function setAxis(x:Number, y:Number):Void { //x and y according the the _targetObject._parent's coordinate space!
		var p = {x:x, y:y}; //Make a point so that we can do localToGlobal()
		_targetObject._parent.localToGlobal(p); //Translates the coordinates to global ones (based on _root)
		_targetObject.globalToLocal(p); //Translates the coordinates to local ones (based on _targetObject)
		_localAxisX = p.x;
		_localAxisY = p.y;
	}

Sep 25 2011

[as3] quite good tutorial for learning vector, velocity, direction

http://active.tutsplus.com/tutorials/animation/learn-about-linear-kinematics/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+Flashtuts+%28Activetuts%2B%29


Jul 22 2011

Pushbutton Engine and Haxe: a natural fit

http://dionamago.net/?p=386


Jul 8 2011

Zinc, f-in-box 之 Z-drive 之謎?

flash流媒体播放器;讨论以内存流方式播放FLASH的技术

flash流媒体播放器:讨论以内存流方式播放FLASH的技术可行性?
来源: 发布时间:星期三, 2008年9月24日 浏览:44次 评论:0
这样可以实现保护flash文件,而且用flash做界面发布时不要带swf文件,很方便,国外有一个 Control 可以实现,大家一起来讨论一下这样实现的技术方案.
告诉你一个最简单的Method
前面步骤和播放文件一样设置
ShockwaveFlash1.Movie = ‘c:\temp\temp.swf ‘;

ShockwaveFlash1.EmbedMovie = True
ShockwaveFlash1.Movie = ‘-_-!! ‘;
这样swf就含在窗体文件(dfm)中了
发布的时候不用单独带swf文件

这样是可以了,如果想把一个SWF文件做成资源,启动时再载入怎么实现呢?
创建一个不可见、只能当前句柄的program可访问的虚拟硬盘

[轉載]
flashplayercontrol貌似就是以这种方式实现的
虚拟硬盘 这个玩大了
这样就必须用到驱动 flashplayercontrol用驱动不可能吧
反汇编 跟踪 发现真的搞了一个虚拟硬盘,生成了一个临时文件Z:\FromMemory\46A10F369771449587DE913EFC0A258C\1\E4ED7C01D28A43418DBF2CB92CC35E56.swf

http://www.plm.hk/Phpgm/archiver/tid-638.html


May 27 2011

Optimizing content for Apple iOS devices [其實 d skill desktop version 都用得著]

http://www.adobe.com/devnet/flash/articles/optimize_content_ios.html


May 13 2011

[as3] Unicode range of Flash

睇睇 flex4 sdk / frameworks 裡面 flash-unicode-table.xml


May 9 2011

[as3] 唔勁,但可以睇下

http://randomcodescraps.tumblr.com/


May 4 2011

Push Button Engine and the console!

http://blog.natebeck.net/2009/11/developing-games-with-pushbutton-engine-using-the-console/


May 4 2011

[as3] 畫圖形的 library

tutorial

http://active.tutsplus.com/tutorials/actionscript/quick-tip-easy-shape-creation-with-uniqueshape/

Library

http://www.libspark.org/wiki/UniqueShape

Shape 之一覽

http://whirlpower.net/documents/uniqueshape/document.html

 

當然可以 extend 佢 d 野 畫d 複雜d 既野~


May 3 2011

[box2d][as3] multiple gravity

http://www.emanueleferonato.com/2009/07/17/managing-multiple-gravities-with-box2d/


May 3 2011

[box2d][as3] 睇下 tutorial

Beginner 教程

http://langrisser1981.blogspot.com/2008/02/hello-box2d.html
http://www.emanueleferonato.com/2010/02/19/box2d-flash-game-creation-tutorial-part-1/
http://plasticsturgeon.com/2010/08/making-an-as3-game-in-box2d-flash-version-2-0-hello-world-box2d/2/
http://www.emanueleferonato.com/2009/07/06/platform-engine-using-box2d/

直接睇 wiki

http://code.google.com/p/pushbuttonengine/wiki/Index?tm=6


May 3 2011

[as3] blog, 講 flash games, 幾過癮既

http://plasticsturgeon.com/


May 3 2011

box2d as3 的一般 tutorial

http://www.p-boy.cn/?p=473


May 3 2011

[web] flv movieplayer for web

http://flowplayer.org/
http://www.longtailvideo.com/players/jw-flv-player/


May 1 2011

[as3] Copying Timeline Animation into a Class

http://active.tutsplus.com/tutorials/animation/quick-tip-copying-timeline-animation-into-a-class/


Apr 13 2011

[pbe][as3]既然玩緊 push button,就睇埋呢個。

http://pushbuttonlabs.com/


Apr 11 2011

[PBE][AS3] Article Studies

http://www.adobe.com/newsletters/edge/august2010/articles/article6/index.html?trackingid=HRTDN

http://www.bukisa.com/articles/228717_making-a-space-invaders-clone-with-pushbutton-the-first-enemy

http://www.brighthub.com/hubfolio/matthew-casperson/blog/archive/2010/01/06/pushbutton-engine-tutorials.aspx


Apr 7 2011

[pbe] Push Button Engine 入門

http://blog.163.com/free_art/blog/static/14156662009111485516228/


Apr 7 2011

[pbe][AS3] Experiment: Using SWF MovieClips in PushButton Engine

http://shikii.net/blog/experiment-using-swf-movieclips-in-pushbutton-engine/


Mar 14 2011

[as3]八個我最常用的AS3開源類庫(轉載)

http://fan.renren.it/a/bianchengyuyan/Flashbiancheng/20100926/38134.html


Mar 14 2011

[as3]What can you do with bytes ?

http://www.bytearray.org/?p=711


Mar 10 2011

[AIR][AS3] Playing around silent install AIR

Cmd 教你裝
http://stackoverflow.com/questions/821531/how-can-the-adobe-air-installer-itself-require-air

官方教你裝
http://help.adobe.com/en_US/air/build/WS789ea67d3e73a8b22388411123785d839c-8000.html

一炮過 setup.exe
http://bishoponvsto.wordpress.com/2010/03/10/deploying-air-application-with-air-runtimeredistributable-in-single-exe/

forum discuss about this
http://forums.adobe.com/message/1998708


Mar 10 2011

[adobe] a blog of adobe news

http://www.webkitchen.be/


Mar 10 2011

[as3] readObject, writeObject of ByteArray, good for save 低 d野~

http://ted.onflash.org/2007/11/abcs-of-amf.php


Mar 7 2011

[as3]使用ByteArray做一些基本的檔案保護

http://blog.iamjason.com/2010/08/bytearray.html


Mar 7 2011

[as3] fscommand fix

fscommand(“exec”, “abc.exe”)
呢個你識用啦,將個 abc.exe 放係 fscommand 既 folder 到
好啦,但係好大問題就係 你想入 argument 入去 係唔 work
fscommand(“exec”, “abc.exe argu1″),無呢回事
咁點算好!

solution:

System.setClipBoard(cmd);

再用 C++ 寫個小 program
個 program 就係貼上 clipBoard 既字再 run
咁就乜 seven 都 run 到啦!
唔洗下下用 C++ 自己寫 flash player 或者 d zinc framework 咁煩~


Mar 7 2011

[as3] 搵左咁耐終於有教,d 網只係教人爆 zip,唔教人 zip 野

FZip
http://lucamezzalira.com/2010/04/13/working-with-zip-files-and-flash-platform/

或者用 nochump
http://pradeek.blogspot.com/search/label/nochump


Mar 3 2011

[AS3][JQuery] jotaquery, as3 直 call jquery 既 script

http://code.google.com/p/jotaquery/


Feb 23 2011

[as3] Generative Art in Flash

tutorial
a href=”http://active.tutsplus.com/tutorials/design/creating-generative-art-with-hype/”>http://active.tutsplus.com/tutorials/design/creating-generative-art-with-hype/

Framework
http://www.hypeframework.org/


Feb 21 2011

[as3] Polygon area calculation

http://ricombination.wordpress.com/2008/11/06/actionscript-3-polygon-area-calculation/


Feb 18 2011

[as3] Displacement filter, 可以玩放大,mapping 等等

放大
http://www.emanueleferonato.com/2009/08/12/pure-as3-magnifying-effect-using-displacement-map-filter/
mapping
http://www.emanueleferonato.com/2007/12/03/understanding-flash-displacement-map-filter/


Feb 14 2011

[C++][AS3] C++ insert Flash

http://www.n8lm.cn/blog/archives/200910/40/


Feb 8 2011

[AS3] Zinc 夾 GAIA, d path 錯曬!

http://www.designdisclosure.com/2009/07/make-mdm-zinc-applications-with-the-gaia-framework-for-adobe-flash/
Solution here~

July 5, 2009 by Alistair Stead in ActionScript, Flash Comments ( 3 )
The Gaia Framework for Adobe Flash is a something I have been using for some time. It is one of the most useful frameworks I have found for use with Flash. It adds a great deal of useful functionality and can generate large swathes of source code that you would otherwise need to write from scratch. However it is a very lightweight and unobtrusive ActionScript framework, you are still free to build your flash application in the same way you always have. You can continue to use your existing workflow but also take advantage of the framework features such as scaffolding, swfAddress, SEO optimization and asset loading and pre-loading.

With all this said when using the Gaia Framework with MDM Zinc application wrapper you have a couple of issues to resolve.

File paths and references from the application executable.
External Interface calls.
Most flash developers are likely unfamiliar with developing installable applications so these issues may be daunting when first encountered. However once explained there are simple solutions to both these issues that I will explain in detail.

File Paths and References

When Flash is used within a website it is served by a webserver and files can always be referenced from the root of the website e.g. /flv/example-video.flv or relative to the location of the .swf e.g. flv/example-video.flv.

However when your .swf is running inside the MDM Zinc wrapper it can no longer reliably reference files using the absolute path from root or a relative path. To resolve this you will need to evaluate the location that the application is running at before creating a path to the files based on this computed path.

Zinc Context Object

To solve this problem I have created a singleton context object. This object allows me to run the required application setup code and access the application properties from everywhere within my Gaia based application.

package com.designdisclosure.utils.mdm
{
import mdm.*;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.display.*;

public class ZincContext extends Sprite
{
private static var _instance:ZincContext;
public var zincGlobals:ZincGlobals;

/**
* Public static method to instantiate the ZincContext object.
* @return ZincContext Object Instance
*/
public static function get instance():ZincContext
{
if(_instance === null)
{
_instance = new ZincContext(new SingletonEnforcer());
}

return _instance;
}

public function ZincContext(pvt:SingletonEnforcer):void
{
if(pvt == null)
{
throw new Error(“Error: Instantiation failed: Use ZincContext.instance instead of new.”);
}

// Initialize an MDMZinc application and create a callback method for when this is completed
mdm.Application.init(this, onMDMinit);
}

private function onMDMinit():void
{
// Use this method to setup your Zinc application
// This is the same as applicationDidFinishLaunching from cocoa
}

/**
* Get the absolute path to the application and its files.
* I use a VMWare machine during testing and found
* that the application path is alittle un-reliable
* and needs modification when running in the VM.
*/
public function getApplicationPath():String
{
var path:String = mdm.Application.path;

return path;
}

public function get isZincApplication():Boolean
{
return (getApplicationPath.length)? true : false;
}
}
}

internal class SingletonEnforcer {}
This object can be used to obtain the application path, an absolute location at which the Zinc application is running. The can then be used in any function the loads external resources. However here is the main problem within the Gaia framework. It is possible to update the path to the site.xml file that is loaded in main.as but even if you load the file from an absolute path the framework does not update the paths used to load any assets referenced in the xml file its self.

Fixing the file paths

Although my next suggestion is not by any means ideal as it involves modifying the framework, I have yet to find a better solution. This obviously will lead to problems when updating the framework to future revisions. However these changes re fairly limited in scope as it is only a single file SiteModel.as. Here are my modifications that inject the application path if it exists into any location where external files are loaded.

public function load(path:String):void
{
if (path == null) path = “site.xml”;
if (path != “xml/site.xml” && path != “site.xml”) GaiaDebug.log(“site.xml path = ” + path);
var request:URLRequest = new URLRequest(CacheBuster.create(ZincContext.instance.getApplicationPath()+path));
loader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onLoadComplete);
loader.load(request);
}
private function parseSite():void
{
_title = _xml.@title || “”;
_preloader = _xml.@preloader || ZincContext.instance.getApplicationPath()+”preload.swf”;
_menu = (_xml.@menu == “true”);
_delimiter = _xml.@delimiter || “: “;
_routing = !(_xml.@routing == “false”);
_history = !(_xml.@history == “false”);
_indexFirst = (_xml.@indexFirst == “true”);
_assetPath = _xml.@assetPath || ZincContext.instance.getApplicationPath();
// preloaderDepth
var depth:String = String(_xml.@preloaderDepth).toLowerCase();
if (depth == Gaia.MIDDLE || depth == Gaia.BOTTOM) _preloaderDepth = depth;
else _preloaderDepth = Gaia.TOP;
// preloaderDomain
var domain:String = String(_xml.@preloaderDomain).toLowerCase();
if (domain == Gaia.DOMAIN_CURRENT || domain == Gaia.DOMAIN_NEW) _preloaderDomain = domain;
else _preloaderDomain = Gaia.DOMAIN_NULL;
// defaultFlow
var flow:String = String(_xml.@flow).toLowerCase();
if (flow == Gaia.PRELOAD || flow == Gaia.REVERSE || flow == Gaia.CROSS) _defaultFlow = flow;
else _defaultFlow = Gaia.NORMAL;
if (_routing) _routes = {};
}
private function parsePage(node:XML, parent:PageAsset = null):PageAsset
{
validateNode(node, true);
var isIndex:Boolean = (node.@id == _indexID);
var page:PageAsset = new PageAsset();
page.node = node;
page.id = node.@id;
page.src = ZincContext.instance.getApplicationPath()+node.@src;
page.title = node.@title;
page.bytes = node.@bytes;
page.assetPath = ZincContext.instance.getApplicationPath()+node.@assetPath || _assetPath;

page.preloadAsset = true;
page.menu = (node.@menu == “true”);
if (page.menu && page.title.toLowerCase() == “about”) GaiaDebug.warn(‘* Warning * “About” is not permitted in Flash context menus’);
if (page.menu && page.title.length > 0) _menuArray.push(page);
page.landing = (node.@landing == “true”);
// domain
var domain:String = String(node.@domain).toLowerCase();
if (domain == Gaia.DOMAIN_NEW || domain == Gaia.DOMAIN_CURRENT) page.domain = domain;
// depth
var depth:String = String(node.@depth).toLowerCase();
if (!isIndex)
{
page.setParent(parent);
page.external = (node.@src.split(“.”).pop() != “swf” || node.@src.indexOf(“javascript”) > -1);
if (page.external) page.window = node.@window || “_self”;
if (depth == Gaia.TOP || depth == Gaia.BOTTOM || depth == Gaia.NESTED) page.depth = depth;
else page.depth = Gaia.MIDDLE;
}
else
{
if (depth == Gaia.TOP || depth == Gaia.MIDDLE) page.depth = depth;
else page.depth = Gaia.BOTTOM;
}
// flow
var flow:String = String(node.@flow).toLowerCase();
if (flow == Gaia.NORMAL || flow == Gaia.PRELOAD || flow == Gaia.REVERSE || flow == Gaia.CROSS) page.flow = flow;
// assets
if (node.asset.length() > 0 || node.@seo != undefined) page.assets = parseAssets(node.asset, page, node.@seo, int(node.@seoBytes));
// child pages
if (node.page.length() > 0)
{
page.defaultChild = node.@defaultChild;
page.children = parseChildren(page, node.page);
if (!page.children.hasOwnProperty(page.defaultChild)) page.defaultChild = node.page[0].@id;
}
// terminal page
else
{
if (page.src.substr(page.src.length – 4) == “.swf”) page.landing = true;
if (isIndex) GaiaSWFAddress.isSinglePage = true;
}
// only add terminal and landing pages to routes
if (_routing && page.landing)
{
var route:String = node.@route || page.title;
if (isIndex) route = route || page.id;
page.route = getValidRoute(route, page.id).toLowerCase();
_routes[page.route] = page.branch;
}
return page;
}
These changes allow you to test your application within the flash authoring environment as the application path will be empty and it will load the files with local references. If you run the application inside a Zinc wrapper the files will be references with an absolute path.

External Interface calls

In order for flash applications to communicate with the browser they use External Interface. This is used extensively within the Gaia framework for logging and also search engine optimization with swfAddress. However MDM Zinc does not handle these calls particularly gracefully and as it is not possible to turn this functionality off within the framework we again need to make a couple of modifications.

Blocking external calls

Inside SWFAdress.as there is a test for ExternalInterface.available however inside Zinc this will incorrectly report true. The only fix for this is as follows:

private static var _availability:Boolean = false; // used to be ExternalInterface.available;
Conclusion

The solutions I have proposed here will resolve the issues the prevent you from using Gaia within a Zinc application. However I believe that these issues could be resolved in a number of ways within the respective products.

MDM Zinc need resolve the issue with ExternalInterface and the its incorrect implementation as this is essentially a bug in the platform.

The issues with the Gaia framework can not be considered bugs as the framework does exactly what it was intended to do. However I would suggest that the framework would be greatly improved if additional configuration were made available to users. Being able to turn off the SEO modules such as SWFAddress and external calls would be very helpful. Not only for use within MDM Zinc but also in situations where the flash application is not the entire web page. If you use Gaia to be build a smaller component within a page the SWFAddress calls can also cause problems.

The loading of assets would also be greatly improved if it were possible to update their paths at run time. Obviously this is not a common requirement but it would make the framework much more flexible and far more useful.


Jan 28 2011

[AS3] 似曾相識的錯,tweenlite removeTint re 極都 re 唔到

TweenPlugin.activate([TintPlugin]);
TweenLite.to(mc, 1, {removeTint:true});

我跟足你做,點解有時唔得?

TweenPlugin.activate([RemoveTintPlugin, TintPlugin]);
funny, 原來有 RemoveTintPlugin =x=

PS
我知啦! 原來舊版本先係咁
成日用 gaia framework 又 update 下個 tweenlite =x=


Jan 27 2011

[AS3] Signal 野: Signal VS DeluxeSignal

http://insideria.com/2010/10/an-introduction-to-as3-signals.html
睇左先
up 一大春英文,搞咩,超簡單
signal 係可以 pass parameter,但 pass 個個 object 就係個個 object 囉

DeluxeSignal 就勁啦,係 pass event
event signal 都識 pass 啦,咁你就錯
呢個 event 係 as3 d fd,你 pass 左,過到去,有翻曬你以前 event 玩既野
例如 event.currentTaret, event.type, event.target 咁
咁咪開心又興奮囉~


Jan 26 2011

[AS3] 兩個 SWF event 傳黎傳去既方法

你仲想利用個 event 傳data ?

mother.addEventListener(CustomEvent.MODULE_CLOSE, onModuleClose)

function onModuleClose(e:*):void {

var data = e.data;

}

var data = {a:1, b:"hello"};

swf.dispatchEvent(new CustomEvent(CustomEvent.MODULE_CLOSE, data));

PS

如果要玩 bubbling: 記得 extend 個陣 要 override 埋 clone 呢個 function!


Jan 26 2011

[AS3] Loading SWFs into AIR 1.5.X and LoaderInfo.sharedEvents

http://richardleggett.co.uk/blog/index.php/2009/04/02/loading-swfs-into-air-1-5-and-loaderinfo

我見佢打散個 swf 做 byteArray ,再用 loader 砌翻埋佢


Jan 26 2011

[AS3] GAIA Framework, 自己整 custom attribute for site.xml ,這世界突然美好了。

http://www.dustypixels.com/blog/2010/03/17/gaia-accessing-custom-page-attributes-from-site-xml/


Jan 25 2011

[AS3] 又黎一d framework

Swiz is a framework for Adobe Flex and ActionScript that aims to bring complete simplicity to RIA development.

http://swizframework.org/

話勁過快過 event 既 singal
https://github.com/robertpenner/as3-signals


Jan 13 2011

[AS3] Hit on hitTestObject

hitTestObject is always use

but do u know:

mc.hitTestObject(target)

if target.visible = false and target.alpha =0

其實都 hit 中 return true

小心d 啦~ 最好加多個 condition

mc.hitTestObject(target) && target.visible


Jan 13 2011

[AS3] SWF Sheet, flash mc -> sequence img format, good for iphone!

http://www.bit-101.com/blog/?p=2939


Jan 10 2011

[AS3] Generate Pdf by AS3 Library

http://alivepdf.bytearray.org/


Dec 29 2010

[AS3] Concept of display list

http://www.oreillynet.com/pub/a/oreilly/digitalmedia/helpcenter/actionscript30cookbook/chapter6.html

Highlight : Stage -> Main -> DisplayObject(s) -> …


Dec 29 2010

[AS3][Function]Anonymous, inline, and named functions in ActionScript

what is inline function …

http://www.darronschall.com/weblog/2004/08/anonymous-inline-and-named-functions-in-actionscript.cfm


Dec 29 2010

[AS3] Flash Tips (MUST READ)

Flash Tips
http://haxe.org/doc/flash/cheatsheet


Dec 7 2010

[AS3] Mac Dock Style Flash

http://jrgraphix.net/r/Flash7_Dock/

read this more happi

http://active.tutsplus.com/tutorials/actionscript/create-a-mac-dock-style-menu-with-as3/


Dec 6 2010

[AS3] 搵翻 GAIA 唔洗 FLASH,用 ANT 都得!

http://kevincao.com/2010/03/workflow-robotgaiaant/


Dec 2 2010

[AS3] Flex no MXML using Application

package
{
	import mx.core.Application;
	import mx.events.FlexEvent;
	import mx.styles.StyleManager;
	import mx.styles.CSSStyleDeclaration;
	import mx.controls.Button;
	import mx.skins.halo.HaloBorder;
	import flash.display.Bitmap;

	public class Main extends Application
	{
		[Embed(source="../library/up.png")]
		public var UpState		: Class;
		[Embed(source="../library/over.png")]
		public var OverState	: Class;
		[Embed(source="../library/down.png")]
		public var DownState	: Class;

		public function Main()
		{
			super();

			this.layout = "absolute";
			this.addEventListener(FlexEvent.CREATION_COMPLETE, handleComplete);

			setupStyles();
		}

		private function setupStyles() : void
		{
			var style:CSSStyleDeclaration = new CSSStyleDeclaration();
			style.setStyle( "borderSkin", mx.skins.halo.HaloBorder );
			StyleManager.setStyleDeclaration( "Application", style, false );

			style = new CSSStyleDeclaration();
			style.setStyle( "textAlign", "left" );
			style.setStyle( "fontAntiAliasType", "advanced" );
			style.setStyle( "fontGridFitType", "pixel" );
			style.setStyle( "paddingLeft", 10 );
			style.setStyle( "paddingRight", 10 );
			style.setStyle( "paddingTop", 5 );
			style.setStyle( "paddingBottom", 5 );
			style.setStyle( "horizontalCenter", 0 );
			style.setStyle( "verticalCenter", 0 );
			style.setStyle( "upSkin", UpState );
			style.setStyle( "overSkin", OverState );
			style.setStyle( "downSkin", DownState );

			StyleManager.setStyleDeclaration( "Button", style, false );
		}

		private function handleComplete( event : FlexEvent ) : void
		{
			var button : Button = new Button();
			button.label = "labelBtn";
			addChild( button );
		}
	}
}

Nov 23 2010

[AS3] 靚波請睇

http://tukuru296.com/labo/

d 波點做?
一個波其實好多 point 組成,再用 curve 連成
wave effect 係 叫d point 郁少少 x 同 郁少少 y


Nov 22 2010

[AS3] Open source Page Flip Engine

http://www.megazine3.de/


Nov 15 2010

[CSS] 將網頁分割,放棄 960 grid 的一個原因

http://lessframework.com/


Nov 10 2010

[AS3] Saving file by FileReference

FileReference.save()

http://blog.everythingflex.com/2008/10/01/filereferencesave-in-flash-player-10/

API

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/FileReference.html#save%28%29

(題外話,講 load 的)

叫你注意 loader.dataFormat = URLLoaderDataFormat.BINARY;

http://www.actionscript.org/forums/showthread.php3?t=187580

如果 advance d coding的話,用 fscommand出一個小exe將 bytearray -> jpg都得。


Nov 9 2010

[AS3/Flex] Start Module Programming!

http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7f22.html


Oct 28 2010

[AS3] AS3 Framework / API Collection

Adobe APIs
corelib, mappr, flickr, youtube and more.
http://labs.adobe.com/wiki/index.php…apis:libraries
APE (Actionscript Physics Engine)
http://www.cove.org/ape/
as3awss3lib
ActionScript 3.0 library for interacting with Amazon S3
http://code.google.com/p/as3awss3lib/
as3soundeditorlib
Actionscript 3.0 library for sound editing
http://code.google.com/p/as3soundeditorlib/
as3ds
AS3 Data Structures For Game Developers
http://code.google.com/p/as3ds/
ASCOLLADA
http://code.google.com/p/ascollada/
As3Crypto
ActionScript 3 Cryptography Library
http://crypto.hurlant.com/
asinmotion
Animation Library for AS3
http://code.google.com/p/asinmotion/
Away3d
http://code.google.com/p/away3d/
ebay API
http://code.google.com/p/as3ebaylib/
facebook-as3
AS3 API to access Facebook’s Platform API
http://code.google.com/p/facebook-as3/
flest
Flest Framework for Adobe Flex and ActionScript3 Applications
http://code.google.com/p/flest/
FZip
Actionscript 3 class library to load standard ZIP archives and extract/decompress contained files.
http://codeazur.com.br/lab/fzip/
lastfm-as3
Actionscript 3.0 library to access the Last.fm web services
http://code.google.com/p/lastfm-as3/
MapQuest
http://company.mapquest.com/mqbs/4a.html
mecheye-as3-libraries
A set of ActionScript 3 Libraries, primarily for Flash game development.
http://code.google.com/p/mecheye-as3-libraries/
Papervision3D
http://code.google.com/p/papervision3d/
Salesforce Flex Toolkit
http://wiki.apexdevnet.com/index.php/Flex_Toolkit
Tweener
Full featured animation library
http://code.google.com/p/tweener/
Twitter AS3 API
http://twitter.com/blog/2006/10/twitter-api-for-flash-developers.html
uicomponents-as3
Lightweight AS3 UI component library
http://code.google.com/p/uicomponents-as3/
XIFF
XMPP client library
http://svn.igniterealtime.org/svn/repos/xiff/branches/xiff_as3_flexlib_beta1/
Yahoo AS3 APIs
http://developer.yahoo.com/flash/as3_api_libraries.html


Oct 21 2010

[Flash] Hacking SWF – Everything You Never Wanted To Know About Shapes In Flash

http://wahlers.com.br/claus/blog/hacking-swf-1-shapes-in-flash/

must read item!!!!!!!!!!!!!