2011年1月24日 星期一

[AS3] Timer類別_簡易計時器 Timer Clock

Timer()建構函式
public function Timer(delay:Number, repeatCount:int = 0)
參數
delay:Number — 計時器事件彼此之間的延遲時間,以毫秒為單位。不建議使用低於 20 毫秒的 delay。計時器頻率限制在每秒 60 影格,也就是小於 16.6 毫秒的延遲會造成執行階段問題。
repeatCount:int (default = 0) — 指定重複的次數。 如果為零,計時器便會無限次重複。 如果不為零,計時器會在執行指定的次數後停止。
Timer物件.addEventListener(TimerEvent.TIMER, 事件處理函數)
Timer物件.start() - 會啟動計時器 (如果尚未執行)。
timerComplete事件 - 每當完成由 Timer.repeatCount 設定的要求數目時傳送。
事件物件類型: flash.events.TimerEvent
屬性 TimerEvent.type = flash.events.TimerEvent.TIMER_COMPLETE


* Timer() 建構式第 2 個參數忘了設定,仍為預設值的 0 。但因為在count()函數做startNum > 0 才遞減的控制,仍可得到正常的結果
1000123_Timer_1.swf




import flash.utils.Timer;
import flash.events.MouseEvent;
import flash.events.Event;

//關閉start_mc的滑鼠感應
start_mc.mouseEnabled = false;

//宣告startNum文int型別,儲存開始倒數的秒數
//startNum_txt欄位輸入的數值將指定給startNum
var startNum:int;
trace(startNum);

//設定舞台上的TextField → startNum_txt的格式屬性
//這用來輸入開始倒數的秒數
startNum_txt.border = true;
startNum_txt.borderColor = 0x555555;
startNum_txt.background = true;
startNum_txt.backgroundColor = 0xbbccff;

//設定舞台上的TextField → timer_txt的格式屬性
//這用來顯示一開始的設定秒數,及倒數中的遞減數字
timer_txt.background = true;
timer_txt.backgroundColor = 0x0000cc;
timer_txt.text = "0";

//運算計時器顯示數字的遞減
function count(e:TimerEvent):void{
 if(startNum > 0){
  startNum --;
 }
 //int型別的startNum以toString()方轉成String型別
 //並指定給timer_txt的text屬性,即在timer_txt欄位顯示
 timer_txt.text = startNum.toString();
}

//Timer物件的宣告
function startTimer(e:MouseEvent):void{
 //每1000毫秒呼叫count函數一次
 var myTimer:Timer = new Timer(1000, 0);
 myTimer.addEventListener(TimerEvent.TIMER, count);
 //start_mc被按下會來呼叫執行此處的startTimer()函數,
 //當startNum > 0,控制startNum_txt的滑鼠感應為false
 //並且讓Timer物件 myTimer 開始運作
 if(startNum > 0){
  //
  startNum_txt.mouseEnabled = false;
  //呼叫start()方法,於是Timer物件開始運作
  myTimer.start();
  trace(startNum);
 }
 //此處e.currentTarget參照廣播MouseEvent.CLICK事件的start_mc
 e.currentTarget.mouseEnabled = false;
}

//打開start_mc的按鈕模式
start_mc.buttonMode = true;
//start_mc廣播MouseEvent.CLICK事件給startTimer偵聽函數
start_mc.addEventListener(MouseEvent.CLICK, startTimer);
//startNum_txt廣播Event.CHANGE事件給updateTimerTxt偵聽函數
startNum_txt.addEventListener(Event.CHANGE, updateTimerTxt);
//當startNum_txt輸入數字,即將數字存入startNum
//startNum_txt被輸入的數字指定給timer_txt
function updateTimerTxt(e:Event):void{
 startNum = int(startNum_txt.text);
 timer_txt.text = startNum_txt.text;
 trace(startNum);
 //當startNum > 0 ,start_mc的滑鼠感應才生效,其餘狀態則關閉
 if(startNum > 0){
  start_mc.mouseEnabled = true;
 }else{
  start_mc.mouseEnabled = false;
 }
}



**  Timer() 建構式第 2 個參數設為所輸入的開始倒數秒數 startNum
( 因為第一個參數為1000毫秒,即1秒觸發一次,startNum (秒) / 1 (次/秒) = startNum (次) )
● 此檔加了偵聽 TimerEvent.TIMER_COMPLETE 事件,當完成由 Timer.repeatCount 設定的要求數目時觸發
1000123_Timer_2.swf




import flash.utils.Timer;

import flash.events.MouseEvent;

import flash.events.Event;


//

//宣告startNum文int型別,儲存開始倒數的秒數

//startNum_txt欄位輸入的數值將指定給startNum

var startNum:int;

trace(startNum);



//

function ini():void{

 //關閉start_mc的滑鼠感應

 start_mc.mouseEnabled = false;

 //開啟sstartNum_txt 欄位的滑鼠感應

 startNum_txt.mouseEnabled = true;



 //設定舞台上的TextField → startNum_txt的格式屬性

 //這用來輸入開始倒數的秒數

 startNum_txt.border = true;

 startNum_txt.borderColor = 0x555555;

 startNum_txt.background = true;

 startNum_txt.backgroundColor = 0xbbccff;

 startNum_txt.text = "";

 //設定舞台上的TextField → timer_txt的格式屬性

 //這用來顯示一開始的設定秒數,及倒數中的遞減數字

 timer_txt.background = true;

 timer_txt.backgroundColor = 0x0000cc;

 timer_txt.text = "0";

}

ini();



//運算計時器顯示數字的遞減

function count(e:TimerEvent):void{

 if(startNum > 0){

  startNum --;

 }

 //int型別的startNum以toString()方轉成String型別

 //並指定給timer_txt的text屬性,即在timer_txt欄位顯示

 timer_txt.text = startNum.toString();

}



//

function myTimerCom(e:TimerEvent):void{

 ini();

}



//Timer物件的宣告

function startTimer(e:MouseEvent):void{

 //每1000毫秒呼叫count函數一次

 var myTimer:Timer = new Timer(1000, startNum);

 myTimer.addEventListener(TimerEvent.TIMER, count);

 myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, myTimerCom);

 

 //start_mc被按下會來呼叫執行此處的startTimer()函數,

 //當startNum > 0,控制startNum_txt的滑鼠感應為false

 //並且讓Timer物件 myTimer 開始運作

 if(startNum > 0){

  //

  startNum_txt.mouseEnabled = false;

  //呼叫start()方法,於是Timer物件開始運作

  myTimer.start();

  trace(startNum);

 }

 //此處e.currentTarget參照廣播MouseEvent.CLICK事件的start_mc

 e.currentTarget.mouseEnabled = false;

}



//打開start_mc的按鈕模式

start_mc.buttonMode = true;

//start_mc廣播MouseEvent.CLICK事件給startTimer偵聽函數

start_mc.addEventListener(MouseEvent.CLICK, startTimer);

//startNum_txt廣播Event.CHANGE事件給updateTimerTxt偵聽函數

startNum_txt.addEventListener(Event.CHANGE, updateTimerTxt);

//當startNum_txt輸入數字,即將數字存入startNum

//startNum_txt被輸入的數字指定給timer_txt

function updateTimerTxt(e:Event):void{

 startNum = int(startNum_txt.text);

 timer_txt.text = startNum_txt.text;

 trace(startNum);

 //當startNum > 0 ,start_mc的滑鼠感應才生效,其餘狀態則關閉

 if(startNum > 0){

  start_mc.mouseEnabled = true;

 }else{

  start_mc.mouseEnabled = false;

 }

}


2011年1月17日 星期一

[AS3] 目標實體(點陣圖設為內嵌資源類別)的rotationX、rotationY值隨 mouseX、mouseY 與stage寬高中線的正負距離而漸變轉動

※將選用的點陣圖匯入元件庫,設定為內嵌資源類別,類別命名為MyPhoto

1000117_DisplayObject__mouseX_rotationY_3.swf




import flash.ui.Mouse;
import flash.events.MouseEvent;
import caurina.transitions.Tweener;
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.display.Bitmap;
//
var disX:int;
var disY:int;
//
var plane:MovieClip = new MovieClip();
addChild(plane);
var bmd:BitmapData = new MyPhoto();
var bm:Bitmap = new Bitmap(bmd);
plane.addChild(bm);
bm.scaleX = 0.9;
bm.scaleY = 0.9;

//bm左上角原對齊在plane的註冊點(0,0),調整bm中心點位置使對齊plane的註冊點(0,0)
bm.x = - bm.width/2;
bm.y = - bm.height/2;

//由於bm中心點位置經上述調整,正對齊plane的註冊點(0,0),也對齊stage的(0,0)
//想把plane從stage的(0,0)移動stage的中央,必須將stage的寬與高各除以2,指定給plane.x和plane.y
plane.x = stage.stageWidth/2;
plane.y = stage.stageHeight/2;

//
stage.addEventListener(MouseEvent.MOUSE_MOVE, rotateXY);
//
function rotateXY(e:MouseEvent):void{
 disX = mouseX - Math.ceil(stage.stageWidth/2);
 disY = mouseY - Math.ceil(stage.stageHeight/2);
 plane.rotationY = disX/16;
 plane.rotationX = -disY/16;
}

[AS3] 目標實體的rotationX、rotationY值隨 mouseX、mouseY 與stage寬高中線的正負距離而漸變轉動

1000117_DisplayObject__mouseX_rotationY_2.swf






import flash.ui.Mouse;
import flash.events.MouseEvent;
import caurina.transitions.Tweener;
//
var disX:int;
var disY:int;
//
plane.x = stage.stageWidth/2;
plane.y = stage.stageHeight/2;
//
stage.addEventListener(MouseEvent.MOUSE_MOVE, rotateXY);
//
function rotateXY(e:MouseEvent):void{
 disX = mouseX - Math.ceil(stage.stageWidth/2);
 disY = mouseY - Math.ceil(stage.stageHeight/2);
 plane.rotationY = disX/7;
 plane.rotationX = disY/7;
}

[AS3] 因應滑鼠指標mouseX位於stage中線的右或左,使目標實體循Y軸 Tweener 旋轉至特定角度

1000117_DisplayObject__mouseX_rotationY_1.swf




import flash.ui.Mouse;
import flash.events.MouseEvent;
import caurina.transitions.Tweener;
//
var flag:int;
//
plane.x = stage.stageWidth/2;
plane.y = stage.stageHeight/2;
//
this.addEventListener(MouseEvent.MOUSE_MOVE, rotateZ);
this.addEventListener(MouseEvent.ROLL_OUT, zeroY);
//
function rotateZ(e:MouseEvent):void{
 var keyX:Number = stage.stageWidth/2;
 if(mouseX > keyX){
  flag = 1;
  //plane.rotationY = 30;
  rotateTween();
 }else if(mouseX < keyX){
  flag = -1;
  //plane.rotationY = -30;
  rotateTween();
 }
}
//
function rotateTween():void{
 Tweener.addTween(plane, {
  rotationY :flag*30,
  time :1.2
 });
}
//
function zeroY(e:MouseEvent):void{
 Tweener.addTween(plane, {
  rotationY :0,
  time :1
 });
}

2011年1月7日 星期五

[AS3][PV3D][Tweener] pv3dWorld_2 - 使用MovieMaterial材質、內嵌資源類別,Loader + ProgressEvent 逐檔百分比載入外部點陣圖


1000103_pv3dWorld_2.swf

2011年1月5日 星期三

[AS3][Tweener] _bezier - 延著貝茲曲線路徑移動(三) - 亂數產生複數個曲線點,循環播放


1000105_Tweener_CurveModifiers_bezier_3.swf




import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;
import caurina.transitions.Tweener;
import caurina.transitions.properties.CurveModifiers;
import flash.geom.Point;

CurveModifiers.init();

//
var pointNum:int = 6;
var ranX:int;
var ranY:int;
var obj:Object = new Object();
var myPath:Array = new Array();
var _mc:MovieClip = new MovieClip();
var endX:int;
var endY:int;

//
function run():void{
 makeCircle();
 addPoint();
 
}
run();

//
function makeCircle():void{
 //
 with (_mc.graphics)
 {
  beginFill(0xffff00, 1);
  var startX:int = Math.floor(Math.random()*stage.stageWidth/4);
  var startY:int = Math.floor(Math.random()*stage.stageHeight/4);
  var radius:int = Math.floor(Math.random()*30)+10;
  drawCircle(startX ,startY ,radius);
  endFill();
 }
 //
 addChild(_mc);
 _mc.scaleX = 1;
 _mc.scaleY = 1;
}

//
function addPoint():void{
 //
 for(var i:int=0; i < pointNum; i++){
  ranX = Math.floor(Math.random()*stage.stageWidth/1.4);
  ranY = Math.floor(Math.random()*stage.stageHeight/1.4);
  obj = {x:ranX, y:ranY};
  trace("obj.x=" + obj.x + " ; " + "obj.y=" + obj.y);
  myPath.push(obj);
 }
 trace("----------------------------------------");
 //
 endX = Math.floor(Math.random()*stage.stageWidth/4);
 endY = Math.floor(Math.random()*stage.stageHeight/4);
 tween_1();
}

//
function tween_1():void
{
 var scaleXY:Number = Math.floor(Math.random()*3) + 0.3;
 Tweener.addTween(_mc,
 {
 x:endX,
 y:endY, 
 //******將myPath陣列指定給_bezier
 _bezier:myPath,
 delay:0.5,
 time:8,
 scaleX:scaleXY,
 scaleY:scaleXY,
 transition:"easeInOutQuint",
 onComplete:popArr
 }
 );
}

//
function popArr():void{
 for(var i:int=0; i < myPath.length; i++){
  myPath.pop();
 }
 addPoint();
}

//
addChild(click_mc);
click_mc.buttonMode = true;
click_mc.flag = true;
click_mc.addEventListener(MouseEvent.CLICK, removeBall);
function removeBall(e:MouseEvent):void{
 popArr();
}

[AS3][Tweener] _bezier - 延著貝茲曲線路徑移動(二) - 複數個曲線點

1000105_Tweener_CurveModifiers_bezier_1.swf




import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;
import caurina.transitions.Tweener;
import caurina.transitions.properties.CurveModifiers;
CurveModifiers.init();

//
var _mc:MovieClip = new MovieClip();
with (_mc.graphics)
{
 beginFill(0xffff00, 1);
 drawCircle(20,20,18);
 endFill();
}
addChild(_mc);

//
tween_1();
//
function tween_1():void
{
 Tweener.addTween(_mc,
 {
 x:480,
 y:100, 
 _bezier:[{x:150, y:350}, {x:350, y:100}, {x:280, y:330}, {x:100, y:200}],
 delay:0.5,
 time:2,
 scaleX:2,
 scaleY:2,
 transition:"easeInOutQuint",
 onComplete:tween_2
 }
 );
}

//
function tween_2():void
{
 Tweener.addTween(_mc,
 {
 x:30,
 y:30, 
 _bezier:[{x:150, y:350}, {x:350, y:100}, {x:280, y:330}],
 delay:0.5,
 time:3,
 scaleX:1,
 scaleY:1,
 transition:"easeInOutQuint",
 onComplete:tween_1
 }
 );
}

addChild(click_mc);
click_mc.buttonMode = true;
click_mc.flag = true;
click_mc.addEventListener(MouseEvent.CLICK, removeBall);
function removeBall(e:MouseEvent):void{
 if(click_mc.flag){
  removeChild(_mc);
  click_mc.flag = false;
 }else{
  addChild(_mc);
  click_mc.flag = true;
 }
 
}






//******將複數個曲線點存入myPath陣列,做為貝茲的路徑
1000105_Tweener_CurveModifiers_bezier_2.swf




import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;
import caurina.transitions.Tweener;
import caurina.transitions.properties.CurveModifiers;
CurveModifiers.init();

//
var _mc:MovieClip = new MovieClip();
with (_mc.graphics)
{
 beginFill(0xffff00, 1);
 drawCircle(20,20,18);
 endFill();
}
addChild(_mc);

//******將複數個曲線點存入myPath陣列,做為貝茲的路徑
var myPath:Array = new Array();
myPath.push({x:150, y:350});
myPath.push({x:100, y:200});
myPath.push({x:280, y:330});
myPath.push({x:300, y:20});
myPath.push({x:350, y:50});

//
tween_1();
//
function tween_1():void
{
 Tweener.addTween(_mc,
 {
 x:480,
 y:100, 
 //******將myPath陣列指定給_bezier
 _bezier:myPath,
 delay:0.5,
 time:3,
 scaleX:2,
 scaleY:2,
 transition:"easeInOutQuint",
 onComplete:tween_2
 }
 );
}

//
function tween_2():void
{
 Tweener.addTween(_mc,
 {
 x:30,
 y:30, 
 _bezier:[{x:150, y:350}, {x:350, y:100}, {x:280, y:330}],
 delay:0.5,
 time:3,
 scaleX:1,
 scaleY:1,
 transition:"easeInOutQuint",
 onComplete:tween_1
 }
 );
}

addChild(click_mc);
click_mc.buttonMode = true;
click_mc.flag = true;
click_mc.addEventListener(MouseEvent.CLICK, removeBall);
function removeBall(e:MouseEvent):void{
 if(click_mc.flag){
  removeChild(_mc);
  click_mc.flag = false;
 }else{
  addChild(_mc);
  click_mc.flag = true;
 }
 
}


[AS3][Tweener] Special property class_FilterShortcuts_ConvolutionFilter

1000104_Tweener_FilterShortcuts_ConvolutionFilter_1.swf




import caurina.transitions.Tweener;
import caurina.transitions.properties.FilterShortcuts;
FilterShortcuts.init();

//
click_mc.addEventListener(MouseEvent.ROLL_OVER, onEventRollOver);
click_mc.addEventListener(MouseEvent.ROLL_OUT, onEventRollOut);
//
function onEventRollOver(e:MouseEvent = null):void{
 Tweener.addTween(e.currentTarget,
 {
  scaleX:2.5,
  scaleY:2.5,
  //
  _Convolution_alpha:0.3,
  _Convolution_bias:150,
  _Convolution_clamp:true,
  _Convolution_color:0x00aaff,
  //_Convolution_color_r:255,
  //_Convolution_color_g:255,
  //_Convolution_color_b:255,
  //_Convolution_matrixX:255,
  //_Convolution_matrixY:255,
  _Convolution_preserveAlpha:true,
  //
  time   :2,
  transition :"easeOutExpo"
 });
}
//
function onEventRollOut(e:MouseEvent = null):void{
 Tweener.addTween(e.currentTarget,
 {
  scaleX:1.7,
  scaleY:1.7,
  //
  _Convolution_alpha:0.3,
  _Convolution_bias:80,
  _Convolution_clamp:true,
  _Convolution_color:0x00aaff,
  //_Convolution_color_r:255,
  //_Convolution_color_g:255,
  //_Convolution_color_b:255,
  //_Convolution_matrixX:255,
  //_Convolution_matrixY:255,
  _Convolution_preserveAlpha:true,
  //
  time   :2,
  transition :"easeOutExpo",
  onComplete:nextTween
 });
}
//
function nextTween():void{
 Tweener.addTween(click_mc,
 {
  scaleX:1.2,
  scaleY:1.2,
  //
  _Convolution_alpha:0.3,
  _Convolution_bias:0,
  _Convolution_clamp:true,
  _Convolution_color:0x00aaff,
  //_Convolution_color_r:255,
  //_Convolution_color_g:255,
  //_Convolution_color_b:255,
  //_Convolution_matrixX:255,
  //_Convolution_matrixY:255,
  _Convolution_preserveAlpha:true,
  //
  delay:0.5,
  time   :1,
  transition :"easeOutExpo"
 });
}


[AS3][Tweener] Special property class_FilterShortcuts_GrowFilter

1000104_Tweener_FilterShortcuts_GlowFilter_1.swf




import caurina.transitions.Tweener;
import caurina.transitions.properties.FilterShortcuts;
FilterShortcuts.init();

//
click_mc.addEventListener(MouseEvent.ROLL_OVER, onEventRollOver);
click_mc.addEventListener(MouseEvent.ROLL_OUT, onEventRollOut);
//
function onEventRollOver(e:MouseEvent = null):void{
 Tweener.addTween(e.currentTarget,
 {
  scaleX:2.5,
  scaleY:2.5,
  //
  _Glow_alpha:0.5,
  _Glow_blurX:120,
  _Glow_blurY:120,
  _Glow_color:0xffff88,
  //_Glow_color_r:255,
  //_Glow_color_g:255,
  //_Glow_color_b:255,
  //_Glow_inner:true,
  //_Glow_knockout:true,
  _Glow_quality:6,
  _Glow_strength:4,
  //
  time   :2,
  transition :"easeOutExpo"
 });
}
//
function onEventRollOut(e:MouseEvent = null):void{
 Tweener.addTween(e.currentTarget,
 {
  scaleX:1.7,
  scaleY:1.7,
  //
  _Glow_alpha:0.5,
  _Glow_blurX:90,
  _Glow_blurY:90,
  _Glow_color:0xffff99,
  //_Glow_color_r:255,
  //_Glow_color_g:255,
  //_Glow_color_b:255,
  //_Glow_inner:true,
  //_Glow_knockout:true,
  _Glow_quality:6,
  _Glow_strength:4,
  //
  time   :2,
  transition :"easeOutExpo",
  onComplete:nextTween
 });
}
//
function nextTween():void{
 Tweener.addTween(click_mc,
 {
  scaleX:1.2,
  scaleY:1.2,
  //
  _Glow_alpha:0.6,
  _Glow_blurX:120,
  _Glow_blurY:120,
  _Glow_color:0xffff88,
  //_Glow_color_r:255,
  //_Glow_color_g:255,
  //_Glow_color_b:255,
  //_Glow_inner:true,
  //_Glow_knockout:true,
  _Glow_quality:8,
  _Glow_strength:5,
  //
  delay:0.5,
  time   :1,
  transition :"easeOutExpo"
 });
}








1000104_Tweener_FilterShortcuts_GlowFilter_2.swf




import caurina.transitions.Tweener;
import caurina.transitions.properties.FilterShortcuts;
FilterShortcuts.init();

//
click_mc.addEventListener(MouseEvent.ROLL_OVER, onEventRollOver);
click_mc.addEventListener(MouseEvent.ROLL_OUT, onEventRollOut);
//
function onEventRollOver(e:MouseEvent = null):void{
 Tweener.addTween(e.currentTarget,
 {
  scaleX:2.5,
  scaleY:2.5,
  rotationX:180,
  rotationY:180,
  rotationZ:180,
  //
  _Glow_alpha:0.5,
  _Glow_blurX:120,
  _Glow_blurY:120,
  _Glow_color:0xffff88,
  //_Glow_color_r:255,
  //_Glow_color_g:255,
  //_Glow_color_b:255,
  //_Glow_inner:true,
  //_Glow_knockout:true,
  _Glow_quality:6,
  _Glow_strength:4,
  //
  time   :2,
  transition :"easeOutExpo"
 });
}
//
function onEventRollOut(e:MouseEvent = null):void{
 Tweener.addTween(e.currentTarget,
 {
  scaleX:1.7,
  scaleY:1.7,
  //
  _Glow_alpha:0.5,
  _Glow_blurX:90,
  _Glow_blurY:90,
  _Glow_color:0xffff99,
  //_Glow_color_r:255,
  //_Glow_color_g:255,
  //_Glow_color_b:255,
  //_Glow_inner:true,
  //_Glow_knockout:true,
  _Glow_quality:6,
  _Glow_strength:4,
  //
  time   :2,
  transition :"easeOutExpo",
  onComplete:nextTween
 });
}
//
function nextTween():void{
 Tweener.addTween(click_mc,
 {
  scaleX:1.2,
  scaleY:1.2,
  rotationX:360,
  rotationY:360,
  rotationZ:360,
  //
  _Glow_alpha:0.6,
  _Glow_blurX:120,
  _Glow_blurY:120,
  _Glow_color:0xffff88,
  //_Glow_color_r:255,
  //_Glow_color_g:255,
  //_Glow_color_b:255,
  //_Glow_inner:true,
  //_Glow_knockout:true,
  _Glow_quality:8,
  _Glow_strength:5,
  //
  delay:0.5,
  time   :2,
  transition :"easeOutExpo"
 });
}


2011年1月4日 星期二

[AS3][Tweener] Special property class_FilterShortcuts_GradientBevelFilter

Tweener Documentation_Special property class__●FilterShortcuts
GradientBevelFilter 有三個屬性目前不能使用,但也許後續能再度支援。

1000104_Tweener_FilterShortcuts_GradientBevelFilter_1.swf




import caurina.transitions.Tweener;
import caurina.transitions.properties.FilterShortcuts;
FilterShortcuts.init();

//
click_mc.addEventListener(MouseEvent.ROLL_OVER, onEventRollOver);
click_mc.addEventListener(MouseEvent.ROLL_OUT, onEventRollOut);
//
function onEventRollOver(e:MouseEvent = null):void{
 Tweener.addTween(e.currentTarget,
 {
  scaleX:2.5,
  scaleY:2.5,
  _GradientBevel_angle:300,
  _GradientBevel_blurX:15,
  _GradientBevel_blurY:15,
  _GradientBevel_distance:20,
  _GradientBevel_quality:1,
  _GradientBevel_strength:4,
  //_GradientBevel_type:"inner",
  //
  _DropShadow_alpha:0.25,
  _DropShadow_angle:120,
  _DropShadow_blurX:80,
  _DropShadow_blurY:80,
  _DropShadow_color:0x222222,
  _DropShadow_distance:20,
  _DropShadow_quality:1,
  _DropShadow_strength:2,
  //_DropShadow_hideObject:true,
  _DropShadow_inner:false,
  //_DropShadow_knockout:true,
  //
  time   :2,
  transition :"easeOutExpo"
 });
}
//
function onEventRollOut(e:MouseEvent = null):void{
 Tweener.addTween(e.currentTarget,
 {
  scaleX:1.7,
  scaleY:1.7,
  //
  _GradientBevel_angle:120,
  _GradientBevel_blurX:40,
  _GradientBevel_blurY:40,
  _GradientBevel_distance:40,
  _GradientBevel_quality:1,
  _GradientBevel_strength:3,
  //_GradientBevel_type:"inner",
  //
  _DropShadow_alpha:0.25,
  _DropShadow_angle:120,
  _DropShadow_blurX:40,
  _DropShadow_blurY:40,
  _DropShadow_color:0x222222,
  _DropShadow_distance:20,
  _DropShadow_quality:1,
  _DropShadow_strength:2,
  //_DropShadow_hideObject:true,
  _DropShadow_inner:false,
  //_DropShadow_knockout:true,
  //
  time   :2,
  transition :"easeOutExpo",
  onComplete:nextTween
 });
}
//
function nextTween():void{
 Tweener.addTween(click_mc,
 {
  scaleX:1.2,
  scaleY:1.2,
  //
  _GradientBevel_angle:240,
  _GradientBevel_blurX:10,
  _GradientBevel_blurY:10,
  _GradientBevel_distance:10,
  _GradientBevel_quality:1,
  _GradientBevel_strength:4,
  //_GradientBevel_type:"inner",
  //
  _DropShadow_alpha:0.3,
  _DropShadow_angle:120,
  _DropShadow_blurX:40,
  _DropShadow_blurY:40,
  _DropShadow_color:0x222222,
  _DropShadow_distance:8,
  _DropShadow_quality:1,
  _DropShadow_strength:3,
  //_DropShadow_hideObject:true,
  _DropShadow_inner:false,
  //_DropShadow_knockout:true,
  //
  delay:0.5,
  time   :1,
  transition :"easeOutExpo"
 });
}

[AS3][Tweener] Special property class_FilterShortcuts_DrapShadowFilter

Tweener Documentation_Special property class__●FilterShortcuts


1000104_Tweener_FilterShortcuts_DropShadowFilter_1.swf




import caurina.transitions.Tweener;
import caurina.transitions.properties.FilterShortcuts;
FilterShortcuts.init();

//
click_mc.addEventListener(MouseEvent.ROLL_OVER, onEventRollOver);
click_mc.addEventListener(MouseEvent.ROLL_OUT, onEventRollOut);
//
function onEventRollOver(e:MouseEvent = null):void{
 Tweener.addTween(e.currentTarget,
 {
  scaleX:2.5,
  scaleY:2.5,
  _DropShadow_alpha:0.3,
  _DropShadow_angle:60,
  _DropShadow_blurX:10,
  _DropShadow_blurY:10,
  _DropShadow_color:0x222222,
  _DropShadow_distance:15,
  _DropShadow_quality:1,
  _DropShadow_strength:3,
  //_DropShadow_hideObject:true,
  _DropShadow_inner:true,
  //_DropShadow_knockout:true,
  //
  time   :2,
  transition :"easeOutExpo"
 });
}
//
function onEventRollOut(e:MouseEvent = null):void{
 Tweener.addTween(e.currentTarget,
 {
  scaleX:1.5,
  scaleY:1.5,
  _Bevel_angle:320, 
  _Bevel_blurX:15, 
  _Bevel_blurY:15, 
  _Bevel_distance:8, 
  //
  _Bevel_highlightColor:0xffffff, 
  _Bevel_highlightAlpha:1, 
  
  _Bevel_knockout:false, 
  _Bevel_quality:2, 
  //
  _Bevel_shadowColor:0x000000, 
  _Bevel_shadowAlpha:1, 
  
  _Bevel_strength:1, 
  _Bevel_type:"inner", 
  //
  time   :2,
  transition :"easeOutExpo",
  onComplete:nextTween
 });
}
//
function nextTween():void{
 Tweener.addTween(click_mc,
 {
  scaleX:1,
  scaleY:1,
  _Bevel_angle:0, 
  _Bevel_blurX:0, 
  _Bevel_blurY:0, 
  _Bevel_distance:0, 
  //
  _Bevel_highlightColor:0xffffff, 
  _Bevel_highlightAlpha:0.6, 
  
  _Bevel_knockout:false, 
  _Bevel_quality:2, 
  //
  _Bevel_shadowColor:0x000000, 
  _Bevel_shadowAlpha:0.6, 
  
  _Bevel_strength:0, 
  _Bevel_type:"inner", 
  //
  delay:0.5,
  time   :1,
  transition :"easeOutExpo"
 });
}





1000104_Tweener_FilterShortcuts_DropShadowFilter_2.swf




import caurina.transitions.Tweener;
import caurina.transitions.properties.FilterShortcuts;
FilterShortcuts.init();

//
click_mc.addEventListener(MouseEvent.ROLL_OVER, onEventRollOver);
click_mc.addEventListener(MouseEvent.ROLL_OUT, onEventRollOut);
//
function onEventRollOver(e:MouseEvent = null):void{
 Tweener.addTween(e.currentTarget,
 {
  scaleX:2.5,
  scaleY:2.5,
  _DropShadow_alpha:0.3,
  _DropShadow_angle:120,
  _DropShadow_blurX:20,
  _DropShadow_blurY:20,
  _DropShadow_color:0x222222,
  _DropShadow_distance:30,
  _DropShadow_quality:1,
  _DropShadow_strength:4,
  //_DropShadow_hideObject:true,
  _DropShadow_inner:true,
  //_DropShadow_knockout:true,
  //
  time   :2,
  transition :"easeOutExpo"
 });
}
//
function onEventRollOut(e:MouseEvent = null):void{
 Tweener.addTween(e.currentTarget,
 {
  scaleX:1.7,
  scaleY:1.7,
  _DropShadow_alpha:0.3,
  _DropShadow_angle:20,
  _DropShadow_blurX:10,
  _DropShadow_blurY:10,
  _DropShadow_color:0x222222,
  _DropShadow_distance:15,
  _DropShadow_quality:1,
  _DropShadow_strength:3,
  //_DropShadow_hideObject:true,
  //_DropShadow_inner:true,
  //_DropShadow_knockout:true,
  //
  time   :2,
  transition :"easeOutExpo",
  onComplete:nextTween
 });
}
//
function nextTween():void{
 Tweener.addTween(click_mc,
 {
  scaleX:1.2,
  scaleY:1.2,
  _DropShadow_alpha:0.3,
  _DropShadow_angle:320,
  _DropShadow_blurX:10,
  _DropShadow_blurY:10,
  _DropShadow_color:0x222222,
  _DropShadow_distance:10,
  _DropShadow_quality:1,
  _DropShadow_strength:3,
  //_DropShadow_hideObject:true,
  //_DropShadow_inner:true,
  //_DropShadow_knockout:true,
  //
  delay:0.5,
  time   :1,
  transition :"easeOutExpo"
 });
}





1000104_Tweener_FilterShortcuts_DropShadowFilter_3.swf




import caurina.transitions.Tweener;
import caurina.transitions.properties.FilterShortcuts;
FilterShortcuts.init();

//
click_mc.addEventListener(MouseEvent.ROLL_OVER, onEventRollOver);
click_mc.addEventListener(MouseEvent.ROLL_OUT, onEventRollOut);
//
function onEventRollOver(e:MouseEvent = null):void{
 Tweener.addTween(e.currentTarget,
 {
  scaleX:2.5,
  scaleY:2.5,
  _DropShadow_alpha:0.2,
  _DropShadow_angle:120,
  _DropShadow_blurX:40,
  _DropShadow_blurY:40,
  _DropShadow_color:0x222222,
  _DropShadow_distance:40,
  _DropShadow_quality:1,
  _DropShadow_strength:1.5,
  //_DropShadow_hideObject:true,
  _DropShadow_inner:false,
  //_DropShadow_knockout:true,
  //
  time   :2,
  transition :"easeOutExpo"
 });
}
//
function onEventRollOut(e:MouseEvent = null):void{
 Tweener.addTween(e.currentTarget,
 {
  scaleX:1.7,
  scaleY:1.7,
  _DropShadow_alpha:0.25,
  _DropShadow_angle:120,
  _DropShadow_blurX:40,
  _DropShadow_blurY:40,
  _DropShadow_color:0x222222,
  _DropShadow_distance:20,
  _DropShadow_quality:1,
  _DropShadow_strength:2,
  //_DropShadow_hideObject:true,
  _DropShadow_inner:false,
  //_DropShadow_knockout:true,
  //
  time   :2,
  transition :"easeOutExpo",
  onComplete:nextTween
 });
}
//
function nextTween():void{
 Tweener.addTween(click_mc,
 {
  scaleX:1.2,
  scaleY:1.2,
  _DropShadow_alpha:0.3,
  _DropShadow_angle:120,
  _DropShadow_blurX:40,
  _DropShadow_blurY:40,
  _DropShadow_color:0x222222,
  _DropShadow_distance:8,
  _DropShadow_quality:1,
  _DropShadow_strength:3,
  //_DropShadow_hideObject:true,
  _DropShadow_inner:false,
  //_DropShadow_knockout:true,
  //
  delay:0.5,
  time   :1,
  transition :"easeOutExpo"
 });
}


[AS3][Tweener] Special property class_FilterShortcuts_BevelFilter

Tweener Documentation_Special property class__●FilterShortcuts


1000104_Tweener_FilterShortcuts_BevelFilter_1.swf




import caurina.transitions.Tweener;
import caurina.transitions.properties.FilterShortcuts;
FilterShortcuts.init();

//
click_mc.addEventListener(MouseEvent.ROLL_OVER, onEventRollOver);
click_mc.addEventListener(MouseEvent.ROLL_OUT, onEventRollOut);
//
function onEventRollOver(e:MouseEvent = null):void{
 Tweener.addTween(e.currentTarget,
 {
  scaleX:1.8,
  scaleY:1.8,
  _Bevel_angle:60, 
  _Bevel_blurX:15, 
  _Bevel_blurY:15, 
  _Bevel_distance:10, 
  //
  _Bevel_highlightColor:0xffffff, 
  _Bevel_highlightAlpha:1, 
  
  _Bevel_knockout:false, 
  _Bevel_quality:2, 
  //
  _Bevel_shadowColor:0x000000, 
  _Bevel_shadowAlpha:0.8, 
  
  _Bevel_strength:1.5, 
  _Bevel_type:"inner", 
  //
  time   :2,
  transition :"easeOutExpo"
 });
}
//
function onEventRollOut(e:MouseEvent = null):void{
 Tweener.addTween(e.currentTarget,
 {
  scaleX:1.5,
  scaleY:1.5,
  _Bevel_angle:320, 
  _Bevel_blurX:15, 
  _Bevel_blurY:15, 
  _Bevel_distance:8, 
  //
  _Bevel_highlightColor:0xffffff, 
  _Bevel_highlightAlpha:1, 
  
  _Bevel_knockout:false, 
  _Bevel_quality:2, 
  //
  _Bevel_shadowColor:0x000000, 
  _Bevel_shadowAlpha:1, 
  
  _Bevel_strength:1, 
  _Bevel_type:"inner", 
  //
  time   :2,
  transition :"easeOutExpo",
  onComplete:nextTween
 });
}
//
function nextTween():void{
 Tweener.addTween(click_mc,
 {
  scaleX:1,
  scaleY:1,
  _Bevel_angle:0, 
  _Bevel_blurX:0, 
  _Bevel_blurY:0, 
  _Bevel_distance:0, 
  //
  _Bevel_highlightColor:0xffffff, 
  _Bevel_highlightAlpha:0.6, 
  
  _Bevel_knockout:false, 
  _Bevel_quality:2, 
  //
  _Bevel_shadowColor:0x000000, 
  _Bevel_shadowAlpha:0.6, 
  
  _Bevel_strength:0, 
  _Bevel_type:"inner", 
  //
  delay:0.5,
  time   :1,
  transition :"easeOutExpo"
 });
}



看看以下屬性說明
/*
Tweener.addTween(e.currentTarget,
{
_Bevel_angle:60, //The angle of the effect, in degrees. A number from 0 to 360.
_Bevel_blurX:15, //The amount of horizontal blur, in pixels. A number from 0 to 255.
_Bevel_blurY:15, //The amount of vertical blur, in pixels. A number from 0 to 255.
_Bevel_distance:10, //The offset distance of the effect, in pixels. Any number.
//
_Bevel_highlightColor:0xffffff, //The highlight color of the bevel. Any color formatted as a number (for example, 0xffgg33).
_Bevel_highlightAlpha:1, //The alpha transparency value of the highlight color. A number from 0 to 1.

_Bevel_knockout:false, //If true, applies a knockout effect, which effectively makes the object's fill transparent and reveals the background color of the document. true or false.
_Bevel_quality:2, //The quality of the filter, which means the number of times to apply it to the object. A number from 0 (low quality) to 1 (medium quality) and above.
//
_Bevel_shadowColor:0x000000, //The shadow color of the bevel. Any color formatted as a number (for example, 0xffgg33).
_Bevel_shadowAlpha:0.8, //The alpha transparency value of the shadow color. A number from 0 to 1.

_Bevel_strength:2, //The strength of the imprint or spread. A number from 0 to 255.
_Bevel_type:"inner", //The placement of the filter effect on the object. "inner", "outer", "full"
//
time   :2,
transition :"easeOutExpo"
});

*/

[AS3][Tweener] Special property class_FilterShortcuts_BlurFilter

Tweener Documentation_Special property class__●FilterShortcuts

1000104_Tweener_FilterShortcuts_BlurFilter_1.swf




import caurina.transitions.Tweener;
import caurina.transitions.properties.FilterShortcuts;
FilterShortcuts.init();

//
click_mc.addEventListener(MouseEvent.ROLL_OVER, onEventRollOver);
click_mc.addEventListener(MouseEvent.ROLL_OUT, onEventRollOut);
//
function onEventRollOver(e:MouseEvent = null):void{
 Tweener.addTween(e.currentTarget,
 {
  _Blur_blurX :60,
  //_Blur_blurY :60,
  time   :1,
  transition :"easeOutExpo"
 });
}
//
function onEventRollOut(e:MouseEvent = null):void{
 Tweener.addTween(e.currentTarget,
 {
  _Blur_blurX :0,
  _Blur_blurY :60,
  time   :1,
  transition :"easeOutExpo",
  onComplete:nextTween
 });
}
//
function nextTween():void{
 Tweener.addTween(click_mc,
 {
  _Blur_blurX :0,
  _Blur_blurY :0,
  delay   :0.3,
  time   :1,
  transition :"easeOutExpo"
 });
}

[AS3][PV3D] 使用MovieMaterial類別 + 內嵌資源類別 + Loader預載百分比,載入外部點陣圖為Plane材質 + 滑鼠press與plane互動,切換轉動軸向

1000103_pv3d_MovieMaterial_2.swf

2011年1月3日 星期一

[AS3][PV3D] 使用MovieMaterial類別 + 內嵌資源類別 + Loader預載百分比,載入外部點陣圖為Plane材質

1000103_pv3d_MovieMaterial_1.swf

[AS3][PV3D] 000101_pv3dWorld_1.swf

1000101_pv3dWorld_1.swf

2011年1月1日 星期六

flash.utils套件__getDefinitionByName()函數 - 傳回所指定之類別的類別物件參照

getDefinitionByName()函數
public function getDefinitionByName(name:String):Object
傳回 name 參數所指定之類別的類別物件參照。
參數
name:String — 類別的名稱。
傳回值
Object — 會傳回 name 參數所指定之類別的類別物件參照。
擲回值
ReferenceError — 具有指定之名稱的公用定義不存在。




991231_GetDefinitionByName_1.swf



package  {
 import flash.utils.getDefinitionByName;
 import flash.display.Bitmap;
 import flash.display.BitmapData;
 import flash.display.Bitmap;
 import flash.display.Loader;
 //import flash.display.MovieClip;
 import flash.display.Sprite;
 import flash.net.URLRequest;
 import flash.events.Event;
 import flash.events.ProgressEvent;
 import flash.text.TextField;
 import flash.text.TextFieldAutoSize;
 //import flashx.textLayout.formats.FormatValue;
 import flash.text.TextFormat;

 public class GetDefinitionByName_1_991231 extends Sprite{
  //
  private var urlString:String = "991230_GetDefinitionByName_1.jpg";
  //
  //getDefinitionByName函數傳回flash.display.Loader類別的參照,指定給Class型別的classReference變數。
  private var classReference:Class = getDefinitionByName("flash.display.Loader") as Class;
  //new 運算子建構classReference類別實體,指定給Object型別的ldr變數。ldr已經參照了Loader類別。
  private var ldr:Object = new classReference();
  private var tf:TextField = new TextField();
  //
  public function GetDefinitionByName_1_991231() {
   setTextField();
   ldrFun();
  }
  
  //
  function setTextField():void{
   //
   var format:TextFormat = new TextFormat();
   with(format){
    color = 0xffffff;
    size = 86;
    font = "Arial";
   }
   //
   addChild(tf);
   with(tf){
    defaultTextFormat = format;
    x = 0;
    y = stage.stageHeight/2 -50 ;
    width = stage.stageWidth;
    autoSize = TextFieldAutoSize.CENTER;
   }
  };
  
  //
  private function ldrFun():void{
   ldr.load(new URLRequest(urlString));
   trace(urlString);
   ldr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoaderProgress);
   ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
  }
  
  //
  private function onLoaderProgress(e:ProgressEvent):void{
   tf.text = String(Math.floor(e.bytesLoaded/e.bytesTotal*100));
  }
  
  //
  private function onComplete(e:Event):void{
   trace(ldr); // [object LoaderInfo]
   var ldrBm:Bitmap = e.currentTarget.content as Bitmap;
   var bmd :BitmapData = ldrBm.bitmapData;
   var bm:Bitmap = new Bitmap(bmd);
   trace(bmd); // [object BitmapData]
   addChild(bm);
   bm.x = 50;
   bm.y = 30;
  }

 }
 
}


適用於 Adobe Flash Professional CS5 的 ActionScript 3.0 參考__●flash.utils_getDefinitionByName()函數