2007/8/28

Matrix的重新設定

運用Matrix的identity()方法,可以將Matrix重設回初始設定值,也就是沒有變形功能的Matrix

程式碼:
var m:Matrix=new Matrix();
trace(m.toString());
m.scale(0.5,0.5);
trace(m.toString());
m.identity();
trace(m.toString());
結果:
(a=1, b=0, c=0, d=1, tx=0, ty=0)
(a=0.5, b=0, c=0, d=0.5, tx=0, ty=0)
(a=1, b=0, c=0, d=1, tx=0, ty=0)

2007/8/23

php for flash 的小問題

發現設定輸入文字欄位時,如果動態微調打勾
傳直到php時,似乎會失敗,目前原因不太曉得,再研究看看

get_magic_quotes_gpc與addslashes

get_magic_quotes_gpc()
取得伺服器的magic_quotes_gpc的設定值,當 magic_quotes_gpc 為true時,所有的 ' (單引號), " (雙引號), \ (反斜線) and 空字元會自動轉為含有反斜線的溢出字元。

參考網址
http://member.ettoday.com/book/function.php-get_magic_quotes_gpc.htm

addslashes($var)
將變數中的如雙引號、單引號、反斜線等等加上斜線成為溢出字元。

參考網址
http://member.ettoday.com/book/function.php-AddSlashes.htm

兩個函式配合則為

$var=(get_magic_quotes_gpc())? $var :addslashes($var)

依伺服器設定決是$var是否需要加上溢出字元

2007/8/21

loadVariables函式的用途


loadVariables函式
可用來與php、asp、cgi、perl、coldfusion等動態網頁語言做為連繫

loadVariables(url:String, target:Object, [method:String]) : Void

loadVariables

import_request_variables函式

php 4.0多了一種新方法,透過import_request_variables 函式,可以不用像以前設register_globals設定成on就可以存取get、post、cookie的傳來資料

import_request_variables("gp", "rvar_");

gp是指get跟post得到的變數,如gpc就是指三個資料都接收
rvar_則是前置綴詞,如原本user_name就變成了
rvar_user_name

http://www.php.net/manual/zh/function.import-request-variables.php

2007/8/19

小試了一下php for flash

最近買了一本書, 『Php For Flash網站開發手扎』,作者是張亞飛,主要是已經過php的經驗,加上目前都在研究flash上面相關的應用與測試,還有一些過去未完成的心願,等等,畢盡多媒體與程式的整合才是我目前該做的事

書藉相關資料:
http://findbook.tw/book/9789867199812/basic

目前看了一點點,以這種進度來看似乎太摱了些,需要再加點油。

這種flash--php--mysql三者的連接,運用完全flash開發介面,php除理程式邏輯,mysql處理資料庫,感覺上是完全分工了,不會像以前寫php網頁跟程式攪在一點,不過flash似手也不是太理想的介面,雖然很好看,不過網頁處理速度、還好一些小功能,等等這些卻不是flash可以達成的,又有java script在。不知道程式在flash上是否有他的發展之路?

可拖曳、破撞的物件

這次是可拖曳、碰撞的物件,繼承了之前的拖曳類別,再加上碰撞的功能,可以與自已同類別的物件相互碰撞,產生動作

package {

import flash.display.*;
import flash.events.*;
public class myHitObj extends myDrawObj {

static public var dispatcher:EventDispatcher=new EventDispatcher();

public function myHitObj(my_name:String,r:uint,color:uint) {
this.name=my_name;

this.graphics.beginFill(color);
this.graphics.drawCircle(0,0,r);
this.graphics.endFill();

this.addEventListener(MouseEvent.MOUSE_DOWN,start_hit);
this.addEventListener(MouseEvent.MOUSE_UP,stop_hit);

dispatcher.addEventListener("hittest",hittest);
}
public function start_hit(e:MouseEvent):void {
this.addEventListener(Event.ENTER_FRAME,send_hit_test);
}
public function stop_hit(e:MouseEvent):void {
this.removeEventListener(Event.ENTER_FRAME,send_hit_test);
}
public function send_hit_test(e:Event):void {
dispatcher.dispatchEvent(new HitEvent("hittest",this));
}
public function hittest(e:HitEvent):void {
//trace("sender is "+e.sender.name+" , i am "+this.name);
if (this!=e.sender) {
//被碰撞後的動作
if (this.hitTestObject(DisplayObject(e.sender))) {
//trace("hit");
dispatcher.removeEventListener("hittest",hittest);//記得要先移除,不然還是會繼續聽事件
//this.parent.removeChild(this);//trace(this.parent);
this.addEventListener(Event.ENTER_FRAME,have_hit);
}
}
}
public function have_hit(e:Event):void {
scaleX+=0.05;
scaleY+=0.05;
if (scaleX>=2) {
this.removeEventListener(Event.ENTER_FRAME,have_hit);
}

}
}
}
import flash.events.*;
class HitEvent extends Event {
private var _sender:Object;
public function HitEvent(type:String,the_sender:Object) {
_sender=the_sender;
//trace("sender is "+sender.name);
super(type);
}
public function get sender():Object {
return _sender;
}
}

2007/8/8

as3的拖曳物件

好像跟as2沒太大不同,事件管理變嚴謹了,但也變麻煩了。可能是我還不夠熟練的關系吧

package
{
import flash.display.Sprite;
import flash.events.MouseEvent;
public class myDrawObj extends Sprite
{
public function myDrawObj():void
{
this.addEventListener(MouseEvent.MOUSE_DOWN,mouse_down_handler);
this.addEventListener(MouseEvent.MOUSE_UP,mouse_up_handler);
}
public function mouse_down_handler(e:MouseEvent):void
{
this.startDrag();
}
public function mouse_up_handler(e:MouseEvent):void
{
this.stopDrag();
}
}
}

2007/8/7

Timer與TimerEvent

Timer計時器的使用
可以每幾秒執行一個函式

import flash.events.TimerEvent;
import flash.utils.Timer;

var timer:Timer=new Timer(1000,0);
//毫秒,次數,0代表無限次

timer.addEventListener(TimerEvent.TIMER,onTick);
//事件名稱,執行函式或方法

timer.start();
//開始


ps~
TimerEvent.TIMER 計時器事件
TimerEvent.TIMER_COMPLETE 最後一次計時器事件