
1000103_pv3dWorld_2.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();
}
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;
}
}
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;
}
}
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"
});
}
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"
});
}
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"
});
}
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"
});
}
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"
});
}
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"
});
}
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"
});
*/
![]() |
| Tweener Documentation_Special property class__●FilterShortcuts |
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"
});
}
import caurina.transitions.Tweener;
import caurina.transitions.properties.CurveModifiers;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;
CurveModifiers.init();
//
var _mc:MovieClip = new MovieClip();
with (_mc.graphics)
{
beginFill(0xddaa00, 1);
drawCircle(20,20,36);
endFill();
}
addChild(_mc);
//
tween_1();
//
function tween_1():void
{
Tweener.addTween(_mc,
{
x:480,
y:100,
_bezier:{x:250, y:600},
delay:0.5,
time:1.5,
scaleX:1.5,
scaleY:1.5,
transition:"easeInOutQuint",
onComplete:tween_2
}
);
}
//
function tween_2():void
{
Tweener.addTween(_mc,
{
x:30,
y:30,
_bezier:{x:300, y:400},
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;
}
}


●使用類別庫之前,打開Flash軟體,做一些設定


//991228從991130_randomPhoto_1.fla修改
import flash.display.MovieClip;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFormat;
//載入Tweener、ColorShortcuts類別
//請至以下URL下載tweener類別程式庫與說明文件
//http://code.google.com/p/tweener/
import caurina.transitions.Tweener;
import caurina.transitions.properties.ColorShortcuts;
//初始化ColorShortcuts
ColorShortcuts.init();
//****** photo陣列 - push() 加入外部圖檔檔名
var photo:Array = new Array();
photo.push("991130_p1.jpg");
photo.push("991130_p2.jpg");
photo.push("991130_p3.jpg");
photo.push("991130_p4.jpg");
photo.push("991130_p5.jpg");
photo.push("991130_p6.jpg");
//
var pNum:uint = photo.length;
//****** intervalDuration - 換圖秒數(毫秒)
//目前設為 5000豪秒,即 5 秒
var intervalDuration:Number = 5000;
//TextFormat物件設定文字格式
var aTextFormat:TextFormat = new TextFormat();
aTextFormat.size = 18;
aTextFormat.color = 0xffffff;
aTextFormat.leftMargin = 5;
aTextFormat.rightMargin = 5;
//宣告TextField文字欄位類別實體infoTextField
var infoTextField:TextField = new TextField();
infoTextField.x = 15;
infoTextField.y = 15;
infoTextField.background = true;
infoTextField.backgroundColor = 0xff2200;
infoTextField.autoSize = TextFieldAutoSize.LEFT;
//將 infoTextField 加入顯示清單
addChild(infoTextField);
//建構Loader類別實體ldr
var ldr:Loader = new Loader();
//
ini();
//
function ini():void
{
loadPhoto();
}
//
function loadPhoto()
{
//如果photo陣列元素都被移除掉了
//以for迴圈重新加入各元素,即外部檔名,同初始值
if(photo.length == 0){
for (var i:uint=0; i < pNum; i++) { // pNum
photo[i] = "991130_p" + String(i+1) + ".jpg";
}
trace("------------------------------------------");
}
//Math.random() 亂數產生0(含)~1(不含)之浮點數,
//乘以圖檔張數(即photo陣列長度 photo.length),會得到 0(含)~6(不含) 之符點數
//Math.floor - 去掉小數 - 會得到0~5之正整數
var photoRandom:uint = Math.floor(Math.random() * photo.length);
//photo[photoRandom] - 因應亂數,做為陣列索引,指向陣列元素
var photoURL:String = photo[photoRandom];
//splice(起始索引, 刪除數量) - 刪除被選定的陣列元素
//如此在每一循環載入圖檔,才不會重覆
photo.splice(photoRandom, 1);
trace(photoURL);
//將photoURL所存的圖檔檔名字串指定給 infoTextField 文字欄位顯示
infoTextField.text = photoURL;
//setTextFormat()方法,將aTextFormat格式化物件與infoTextField文字欄位關聯
infoTextField.setTextFormat(aTextFormat);
//
//Loader類別實體ldr,以load()方法載入new URLRequest()的相對網址(即圖檔檔名)
ldr.load(new URLRequest(photoURL));
//將Event.COMPLETE事件的偵聽程式onLoaderComplete,附加到Loader類別實體ldr的contentLoaderInfo屬性
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderComplete);
}
//
function onLoaderComplete(e:Event):void
{
addChild(ldr);
//將ldr可視物件實體,以x,y座標控制在舞台中央
ldr.x = (stage.stageWidth - ldr.width) / 2;
ldr.y = (stage.stageHeight - ldr.height) / 2;
//呼叫漸變屬性設定函式tweenPhoto1()
tweenPhoto1();
//setTimeout(closure:Function, delay:Number, ... arguments):uint
//在指定的延遲時間 (以毫秒為單位) 之後執行指定的函數
var intervalId:uint = setTimeout(ini, intervalDuration);
}
//
function tweenPhoto1():void{
Tweener.addTween(ldr, {alpha:0, scaleX:0.9, scaleY:0.9, time:0, onComplete:tweenPhoto2});
}
function tweenPhoto2():void{
Tweener.addTween(ldr, {alpha:1, scaleX:1, scaleY:1, time:1.5});
}
◎另需參閱
指定類別檔路徑 - 以下載及設置Tweener類別庫為例 http://flash.twgogo.org/2010/12/blog-post.html
//匯入Tweener類別;匯入MouseEvent類別
import caurina.transitions.Tweener;
import flash.events.MouseEvent;
//匯入ColorShortcuts類別
import caurina.transitions.properties.ColorShortcuts;
//初始化ColorShortcuts
ColorShortcuts.init();
//
//將 List 組件加入應用程式時,您可以加入下列 ActionScript 程式碼,讓螢幕朗讀程式能夠存取此組件
import fl.accessibility.ListAccImpl;
ListAccImpl.enableAccessibility();
//匯入List類別
import fl.controls.List;
//宣告tranVar為tweenFun2()之漸變參數transition的參數值
var tranVar:String;
//主場景上實體名稱為aList之List組件,addItem()將項目逐一附加至項目清單的結尾
aList.addItem({label:"linearx", data:"linear"});
aList.addItem({label:"easeInSine", data:"easeInSine"});
aList.addItem({label:"easeOutSine", data:"easeOutSine"});
aList.addItem({label:"easeInOutSine", data:"easeInOutSine"});
aList.addItem({label:"easeInCubic", data:"easeInCubic"});
aList.addItem({label:"easeOutCubic", data:"easeOutCubic"});
aList.addItem({label:"easeInOutCubic", data:"easeInOutCubic"});
aList.addItem({label:"easeOutInCubic", data:"easeOutInCubic"});
aList.addItem({label:"easeInQuint", data:"easeInQuint"});
aList.addItem({label:"easeOutQuint", data:"easeOutQuint"});
aList.addItem({label:"easeInOutQuint", data:"easeInOutQuint"});
aList.addItem({label:"easeOutInQuint", data:"easeOutInQuint"});
aList.addItem({label:"easeInCirc", data:"easeInCirc"});
aList.addItem({label:"easeOutCirc", data:"easeOutCirc"});
aList.addItem({label:"easeInOutCirc", data:"easeInOutCirc"});
aList.addItem({label:"easeOutInCirc", data:"easeOutInCirc"});
aList.addItem({label:"easeInBack", data:"easeInBack"});
aList.addItem({label:"easeOutBack", data:"easeOutBack"});
aList.addItem({label:"easeInOutBack", data:"easeInOutBack"});
aList.addItem({label:"easeOutInBack", data:"easeOutInBack"});
aList.addItem({label:"easeInQuad", data:"easeInQuad"});
aList.addItem({label:"easeOutQuad", data:"easeOutQuad"});
aList.addItem({label:"easeInOutQuad", data:"easeInOutQuad"});
aList.addItem({label:"easeOutInQuad", data:"easeOutInQuad"});
aList.addItem({label:"easeInQuart", data:"easeInQuart"});
aList.addItem({label:"easeOutQuart", data:"easeOutQuart"});
aList.addItem({label:"easeInOutQuart", data:"easeInOutQuart"});
aList.addItem({label:"easeOutInQuart", data:"easeOutInQuart"});
aList.addItem({label:"easeInExpo", data:"easeInExpo"});
aList.addItem({label:"easeOutExpo", data:"easeOutExpo"});
aList.addItem({label:"easeInOutExpo", data:"easeInOutExpo"});
aList.addItem({label:"easeOutInExpo", data:"easeOutInExpo"});
aList.addItem({label:"easeInElastic", data:"easeInElastic"});
aList.addItem({label:"easeOutElastic", data:"easeOutElastic"});
aList.addItem({label:"easeInOutElastic", data:"easeInOutElastic"});
aList.addItem({label:"easeOutInElastic", data:"easeOutInElastic"});
aList.addItem({label:"easeInBounce", data:"easeInBounce"});
aList.addItem({label:"easeOutBounce", data:"easeOutBounce"});
aList.addItem({label:"easeInOutBounce", data:"easeInOutBounce"});
aList.addItem({label:"easeOutInBounce", data:"easeOutInBounce"});
//
//aList.selectedItem={label:"easeInOutElastic", data:"easeInOutElastic"};
//將aList組件被選取項目之索引編號設為34
aList.selectedIndex = 34;
//將aList組件捲軸捲動至項目索引編號39
aList.scrollToIndex(34+5);
trace(aList.selectedItem.data);
//將aList組件被選取項目物件的data屬性指定給tranVar
//tranVar為tweenFun2()之漸變參數transition的參數值
tranVar = aList.selectedItem.data;
//aList廣播Event.CHANGE事件給getData偵聽函式
aList.addEventListener(Event.CHANGE, getData);
//
function getData(event:Event) {
//將event.target事件物件的selectedItem物件的data屬性值導入tranVar
tranVar = event.target.selectedItem.data;
}
//宣告oriX和oriY,將a_mc在主場景上的初始位置x及y座標存入
var oriX:Number = a_mc.x;
var oriY:Number = a_mc.y;
//
click_mc.buttonMode = true;
click_mc.addEventListener(MouseEvent.MOUSE_DOWN, tweenFun1)
//定義tweenFun1的內容,a_mc的漸變參數為{x:470, y:80, time:1.5, onComplete:tweenFun2}
//onComplete:tweenFun2將驅使x:470, y:80, time:1.5的漸變完成後,
//呼叫tweenFun2開始執行
//Complete color transformation properties裡的_color參數,其值為16進位數值
//例如0xff0000為紅色
function tweenFun1(e:MouseEvent):void{
Tweener.addTween(a_mc, {x:280, y:50, time:1, _color:0xffff00, onComplete:tweenFun2});
}
//其中transition:"easeOutElastic"定義漸變階段的動作型態,
//可參照Transition Types 之說明。
//_color:null可將_color參數值回歸初始無值狀態。
function tweenFun2(){
Tweener.addTween(a_mc, {x:oriX, y:oriY, time:1.5, delay:0.5, _color:null,transition:tranVar});
}
//
Tweener.addTween(a_mc, {x:470, y:80, time:1.5, _color:0xff0000, delay:1.5, onComplete:tweenFun2});
//或
//
Tweener.addTween(a_mc, { x:470, y:80, time:1.5, _color:0xff0000, delay:1.5, onComplete:tweenFun2});
// var tweeningObj:Object = new Object(); tweeningObj.x = 470; tweeningObj.y = 80; tweeningObj.time = 1.5; tweeningObj._color = 0xff0000; tweeningObj.delay = 1.5; tweeningObj.onComplete = tweenFun2; // Tweener.addTween(a_mc, tweeningObj);
//
var tweeningObj:Object = {x : 470, y : 80, time : 1.5, _color : 0xff0000, delay : 1.5, onComplete : tweenFun2};
//
Tweener.addTween(a_mc, tweeningObj);
// WITH base, using an array of base objects:
import caurina.transitions.Tweener;
import flash.display.MovieClip;
import flash.events.MouseEvent;
var aOri:Object = {x:a_mc.x, y:a_mc.y, transition:"easeInOutBounce", time:2};
var myFade:Object = {x:450, time:1};
Tweener.addTween(a_mc, {base:myFade, y:300});
a_mc.addEventListener(MouseEvent.CLICK, oriFun);
function oriFun(e:MouseEvent){
Tweener.addTween(e.currentTarget, aOri);
}
Tweener是開放源碼的程式庫。
Tweener網址:http://code.google.com/p/tweener/
Tweener類別下載:http://code.google.com/p/tweener/downloads/list
Tweener Documentation:http://hosted.zeh.com.br/tweener/docs/en-us/
tweeningParameters:Object — An object containing various properties of the original object that you want to tween on the original objects, with their final values assigned (some special properties are also allowed), as well as some built-in Tweener properties used when defining tweening parameters. This is like the recipe for the tweening, declaring both what will be tweened, and how.//所以→
Tweener.addTween(目標物件:Object, 漸變參數:Object)
→目標物件可以是影片實體、文字欄位、聲音實體、其它擁有數值屬性的自訂物件。
→漸變參數定義目標物件新的屬性值,漸變過程即原有屬性值到新的屬性值之間的動畫過程。
//匯入Tweener類別;匯入MouseEvent類別
import caurina.transitions.Tweener;
import flash.events.MouseEvent;
//
click_mc.addEventListener(MouseEvent.MOUSE_DOWN, tweenFun)
function tweenFun(e:MouseEvent):void{
//針對a_mc附加漸變動畫,{x:450, y:100, time:1.5}為其漸變參數,物件類型
Tweener.addTween(a_mc, {x:450, y:100, time:1.5});
}
//匯入Tweener類別;匯入MouseEvent類別
import caurina.transitions.Tweener;
import flash.events.MouseEvent;
//宣告oriX和oriY,將a_mc在主場景上的初始位置x及y座標存入
var oriX:Number = a_mc.x;
var oriY:Number = a_mc.y;
//
click_mc.buttonMode = true;
click_mc.addEventListener(MouseEvent.MOUSE_DOWN, tweenFun1)
//定義tweenFun1的內容,a_mc的漸變參數為{x:470, y:80, time:1.5, onComplete:tweenFun2}
//onComplete:tweenFun2將驅使x:470, y:80, time:1.5的漸變完成後,
//呼叫tweenFun2開始執行
function tweenFun1(e:MouseEvent):void{
Tweener.addTween(a_mc, {x:470, y:80, time:1.5, onComplete:tweenFun2});
}
//其中transition:"easeOutElastic"定義漸變階段的動作型態
//可參照Transition Types 之說明
function tweenFun2(){
Tweener.addTween(a_mc, {x:oriX, y:oriY, time:1.5, transition:"easeOutElastic"});
}

//匯入Tweener類別;匯入MouseEvent類別
import caurina.transitions.Tweener;
import flash.events.MouseEvent;
//匯入ColorShortcuts類別
import caurina.transitions.properties.ColorShortcuts;
//初始化ColorShortcuts
ColorShortcuts.init();
//宣告oriX和oriY,將a_mc在主場景上的初始位置x及y座標存入
var oriX:Number = a_mc.x;
var oriY:Number = a_mc.y;
//
click_mc.buttonMode = true;
click_mc.addEventListener(MouseEvent.MOUSE_DOWN, tweenFun1)
//定義tweenFun1的內容,a_mc的漸變參數為{x:470, y:80, time:1.5, onComplete:tweenFun2}
//onComplete:tweenFun2將驅使x:470, y:80, time:1.5的漸變完成後,
//呼叫tweenFun2開始執行
//Complete color transformation properties裡的_color參數,其值為16進位數值
//例如0xff0000為紅色
function tweenFun1(e:MouseEvent):void{
Tweener.addTween(a_mc, {x:470, y:80, time:1.5, _color:0xff0000, onComplete:tweenFun2});
}
//其中transition:"easeOutElastic"定義漸變階段的動作型態,
//可參照Transition Types 之說明。
//_color:null可將_color參數值回歸初始無值狀態。
function tweenFun2(){
Tweener.addTween(a_mc, {x:oriX, y:oriY, time:5, _color:null,transition:"easeOutElastic"});
}
//
import caurina.transitions.Tweener;
import flash.display.MovieClip;
import caurina.transitions.properties.FilterShortcuts;
//
FilterShortcuts.init();
//var bX:Number = _Blur_blurX;
//var bY:Number = _Blur_blurY;
//
var clip_mc:MovieClip = new ClipMC();
clip_mc.x = 0;
clip_mc.y = 200;
clip_mc.scaleX = 0.5;
clip_mc.scaleY = 0.5;
addChild(clip_mc);
//
var obj:Object = new Object();
obj.x = 400;
obj.y = 200;
obj.time = 2;
obj.transition = "easeOutBounce";
obj._Blur_blurX = 10;
obj._Blur_blurY = 10;
obj.alpha = 0.2;
obj.scaleX = 0.8;
obj.scaleY = 0.8;
//
clip_mc.buttonMode = true;
clip_mc.addEventListener(MouseEvent.MOUSE_DOWN, function(){
Tweener.addTween(clip_mc, obj);
})