/**
* author: shinder lin
* email: shinder.lin@gmail.com
*/
class SDDump {
static var n:Number = 0;
static var str:String = '';
static function echo(a) {
trace(go(a));
}
static function go(a) {
str = '';
dumpIt(a);
str = str.slice(0, str.length-1);
return str;
}
static function dumpIt(a) {
if (a instanceof Array) {
dumpArray(a);
} else if (a instanceof Object) {
dumpObject(a);
} else {
appendStr(a);
}
}
static function dumpArray(ar:Array):Void {
n++;
for (var o in ar) {
if (ar[o] instanceof Object) {
appendStr("["+o+"]:");
dumpIt(ar[o]);
} else {
appendStr("["+o+"]:"+ar[o]);
}
}
n--;
}
static function dumpObject(obj:Object):Void {
n++;
for (var o in obj) {
if (obj[o] instanceof Object) {
appendStr(o+":");
dumpIt(obj[o]);
} else {
appendStr(o+":"+obj[o]);
}
}
n--;
}
static function appendStr(s):Void {
str += getSpaces()+s+'\n';
}
static function getSpaces():String {
var s:String = '';
for (var i = 1; i < n; i++) {
s += " ";
}
return s;
}
}
2007-06-13
SDDump - Dump 的 AS2 版
原始檔 SDDump.as
2007-06-12
Adobe AIR beta
之前代號為 Apollo, 現在正式稱為 Adobe AIR
釋出 public beta Adobe Integrated Runtime (AIR)
相關新聞: Adobe推Apollo平台測試版 正名AIR
Flex 3 也 beta 了, 請看 Adobe Labs
釋出 public beta Adobe Integrated Runtime (AIR)
相關新聞: Adobe推Apollo平台測試版 正名AIR
Flex 3 也 beta 了, 請看 Adobe Labs
AS3 frame actions 可以定義 setter/getter functions
Flash CS3 AS3 的 frame actions 可以用 setter/getter 囉
雖然不能使用 private 宣告變數
但是可以定義 setter/getter functions 就很方便了
雖然不能使用 private 宣告變數
但是可以定義 setter/getter functions 就很方便了
var t:Number = 10;
function set test(n:Number):void {
t=n;
}
function get test():Number {
return t;
}
trace('t='+t);
test = 99;
trace('t='+t);
2007-06-11
The rules of frame actions converting to a class definition ?
承上一篇: Frame Action 的 Function literal 裡的 Scope
個人「純猜測」可能轉換成類別定義:
然而 frame1 應該不是 class member, 所以應該比較像這樣:
紅色字的部份應該是在 addFrameScript() 裡面運作
個人「純猜測」可能轉換成類別定義:
package {
import flash.display.MovieClip;
public class TestMC8 extends MovieClip {
public var me:Object = this;
public var o:Object = {};
public var i:Number = 6;
public function TestMC8() {
addFrameScript(0, frame1);
}
internal function frame1():void {
o.a = function():void{
this.c = function():void{
};
};
o.b = function():void{
trace(i);
trace(this.i);
trace(me.i);
};
o.a();
o.b();
}
}
}
然而 frame1 應該不是 class member, 所以應該比較像這樣:
package {
import flash.display.MovieClip;
public class TestMC8a extends MovieClip {
public var me:Object = this;
public var o:Object = {};
public var i:Number = 6;
public function TestMC8a() {
function frame1():void{
o.a = function():void{
this.c = function():void{
};
};
o.b = function():void{
trace(i);
trace(this.i);
trace(me.i);
};
o.a();
o.b();
trace(this);
}
addFrameScript(0, function(){
frame1.apply(me);
});
}
}
}
紅色字的部份應該是在 addFrameScript() 裡面運作
Frame Action 的 Function literal 裡的 Scope
之前在 mmug 的討論: Flash CS3 - AS3 又一影格程式問題
老方式用 describeType() 去檢查. 以 literal 方式定義的 function objects, 其內部的變數若不是以 this 為開頭, 皆會被轉換為 影格所在MovieClip 物件的屬性。
Frame Actions:
結果:
老方式用 describeType() 去檢查. 以 literal 方式定義的 function objects, 其內部的變數若不是以 this 為開頭, 皆會被轉換為 影格所在MovieClip 物件的屬性。
Frame Actions:
var me:Object = this;
var o:Object = {};
o.a = function():void{
var i:Number = 6;
this.c = function():void{
var k;
};
};
o.b = function():void{
trace(i);
trace(this.i);
trace(me.i);
};
o.a();
o.b();
trace(describeType(this));
結果:
6
undefined
6
...
<variable name="k" type="*"/>
<variable name="i" type="Number"/>
<variable name="me" type="Object"/>
<variable name="o" type="Object"/>
...
MainTimeline Frame Functions -> Class Methods
Flash CS3 裡 MainTimeline frame actions 定義的 functions (not literal)
如何轉換成 class methods 的定義呢 ?
測試了一下, 無論在哪一格定義, 全都變成 public class methods
Frame 1:
Frame 6:
輸出結果:
如何轉換成 class methods 的定義呢 ?
測試了一下, 無論在哪一格定義, 全都變成 public class methods
Frame 1:
b();
a();
function a():void {
trace('a');
}
Frame 6:
stop();
function b():void {
trace('b');
}
trace(describeType(this));
輸出結果:
b
a
<type name="Untitled_fla::MainTimeline" base="flash.display::MovieClip" isDynamic="true" isFinal="false" isStatic="false">
...
<method name="a" declaredBy="Untitled_fla::MainTimeline" returnType="void"/>
<method name="b" declaredBy="Untitled_fla::MainTimeline" returnType="void"/>
...
2007-06-10
AS3 未公開的類別和方法
網路上的資源:
Ticore's Blog: ActionScript 3.0 未公開的函式 AVM1Movie.call、addCallback, ActionScript 3.0 未公開的函式 MovieClip.addFrameScript
Experimenting with AS3 ,Apollo and HaXe: ActionScript3中未公开的一些方法和类
在 Flash CS3 開個 AS3 新文件, 輸入 Frame Actions
得到的結果, 可以找到
依照 metadata 標籤又可以找到
addFrameScript 和 AccessibilityImplementation 都是 undocumented.
Ticore's Blog: ActionScript 3.0 未公開的函式 AVM1Movie.call、addCallback, ActionScript 3.0 未公開的函式 MovieClip.addFrameScript
Experimenting with AS3 ,Apollo and HaXe: ActionScript3中未公开的一些方法和类
在 Flash CS3 開個 AS3 新文件, 輸入 Frame Actions
trace(describeType(this));
得到的結果, 可以找到
<method name="addFrameScript" declaredBy="flash.display::MovieClip" returnType="void">
<metadata name="Inspectable">
<arg key="environment" value="none"/>
</metadata>
</method>
依照 metadata 標籤又可以找到
<accessor name="accessibilityImplementation" access="readwrite" type="flash.accessibility::AccessibilityImplementation" declaredBy="flash.display::InteractiveObject">
<metadata name="Inspectable">
<arg key="environment" value="none"/>
</metadata>
</accessor>
addFrameScript 和 AccessibilityImplementation 都是 undocumented.
Colin Moock - actionscript 3.0 and flash cs3
Colin Moock - 演講大綱
actionscript 3.0 and flash cs3
explains how to integrate ActionScript 3.0 code with content created in the flash cs3 authoring tool.
actionscript 3.0 and flash cs3
explains how to integrate ActionScript 3.0 code with content created in the flash cs3 authoring tool.
AS3 與 AMFPHP 1.2 part 3 - Credentials
AS3 沒有 setCredentials() 了
而是利用 NetConnection.addHeader(), 下兩行是 Help 裡說明
Adds a context header to the AMF packet structure.
This header is sent with every future AMF packet.
Flash AS3:
而是利用 NetConnection.addHeader(), 下兩行是 Help 裡說明
Adds a context header to the AMF packet structure.
This header is sent with every future AMF packet.
Flash AS3:
var nc:NetConnection = new NetConnection();
nc.objectEncoding = ObjectEncoding.AMF0;
nc.connect('http://localhost/amfphp/gateway.php');
nc.addHeader("Credentials", false,
{userid:'kitty', password:'kitty'});
var responder:Responder = new Responder(onResult, onError);
nc.call('myremoting.DataOp_6.isLogin', responder);
function onResult(re:Object):void {
QopDump.echo(re);
}
function onError(er:Object):void {
QopDump.echo(er);
}
AS3 與 AMFPHP 1.2 part 2
後台傳送資料表至前端的「格式」
DataOp_2.php 原始碼
Flash AS3
正常執行的結果:
方法名稱錯誤的結果:
DataOp_2.php 原始碼
< ?php
class DataOp_2
{
var $dbhost = "localhost";
var $db = "test";
var $table = "tbl_address_book";
var $user = "root";
var $password = "admin";
function DataOp_2(){
mysql_connect($this->dbhost, $this->user, $this->password);
mysql_query("SET NAMES 'utf8'");
mysql_select_db($this->db);
$this->methodTable = array(
"getAllData"=>array(
"access"=>"remote"
)
);
}
function getAllData(){
$sql = sprintf("select * from `%s`", $this->table);
return mysql_query($sql);
}
}
?>
Flash AS3
import QopDump; // just prompt
var nc:NetConnection = new NetConnection();
nc.connect('http://localhost/amfphp/gateway.php');
var responder:Responder = new Responder(onResult, onError);
nc.call('myremoting.DataOp_2.getAllData', responder);
function onResult(re:Object):void {
QopDump.echo(re);
}
function onError(er:Object):void {
QopDump.echo(er);
}
正常執行的結果:
serverInfo:
version:1
id:
serviceName:PageAbleResult
initialData:
[0]:
[0]:3
[1]:哈利
[2]:0987654321
[3]:台北市大安區
[1]:
[0]:4
[1]:凱蒂貓
[2]:0987654322
[3]:宜蘭縣礁溪鄉
[2]:
[0]:6
[1]:小叮噹
[2]:0987654323
[3]:台東縣知本溫泉旁
columnNames:
[0]:id
[1]:name
[2]:phone
[3]:address
cursor:1
totalCount:3
方法名稱錯誤的結果:
line:171
description:The method {getAll} was not declared in the meta data for class {DataOp_2}.
level:User Error
details:C:\wamp163\www\amfphp\amf-core\app\Actions.php
code:AMFPHP_UNDECLARED_METHOD
訂閱:
文章 (Atom)