2008年1月23日 星期三

Use Script to control Tweening Motion

Not only click button do tweening motion. You may try to use "ActionScript to do" . It is more flexiable to control "movieClip" SPEED. Hope to enjoy my video.



enter_btn.onRelease = function(){ easex(ball_mc, 400, 90); };

function easex(mc, targetX, targetY){ mc.onEnterFrame = function(){ var distanceX:Number = targetX - this._x; var distanceY:Number = targetY - this._y; this._x = this._x + distanceX / 5; this._y = this._y + distanceY / 5; };

2008年1月10日 星期四

Stop & Play Button

Play & Stop Button

This is simple btn to do stop and play in Flash. Enjoy it. * how to add sound in btn? will demo it later :)




ActionScipt :
stopbtn.onRelease=function(){ _root.gotoAndStop(2);}
playbtn.onRelease=function(){ _root.gotoAndStop(1);
}

FREE download sourceCode : http://swfsolution.googlepages.com/stopandstartBTN.fla

2008年1月3日 星期四

Flash Search Engine

自製有型 Search 引擎 ! (Create your own Search Engine in Flash )
可能網友見過此search 功能,但幾實用又簡單。 所以錄製下來給我的朋友。 有興趣歡迎瀏覽 ~


Demo: http://swfsolution.googlepages.com/searchengine.html

Sourcecode : http://swfsolution.googlepages.com/searchengine.fla

ActionScript: on (release) { getURL("http://www.google.com/search", "_blank", "GET");}



2007年12月25日 星期二

Create own video player

自家製影片播放器 (Advanced Flash)








Demo : http://annwongfresh.googlepages.com/ownVideoPlayer.html
Souce code : http://annwongfresh.googlepages.com/ownVideoPlayer.fla
Testing Material : http://annwongfresh.googlepages.com/testvideo8.flv


Actionscript :

stop();
var connect_nc:NetConnection = new NetConnection();

connect_nc.connect(null);

var stream_ns:NetStream = new NetStream(connect_nc);
myVideo.attachVideo(stream_ns);stream_ns.play("XXXXXx.flv"); // FILL YOUR VIDEO NAME

stream_ns.onStatus = function(infoObject:Object)
{ if (infoObject.code == "NetStream.Play.StreamNotFound")
{ trace("Could not find video file."); }}

pausebtn.onRelease = function(){ stream_ns.pause(true);}
playbtn.onRelease = function(){ stream_ns.pause(false); }




Dynamic Magic Rings

Create Magic Rings in Flash

用 ActionScript 自動產出 random rings







Demo : http://annwongfresh.googlepages.com/duplicateRing.html
(soucecode : duplicateRing.fla)

ActionScript:
frame 1 :
var i:Number =0; // start number for looping
var max:Number =30; // dupliate maximum number
ring0._visible =0; // hidden the 1st ring


frame 2 :
duplicateMovieClip("ring0","ring" +i,900-i);
// duplicateMovieClip( target , newname , depth )

this["ring" +i]._x = Math.random()*400; // 400 is the stage width
this["ring" +i]._y = Math.random()*300;
this["ring" +i]._xscale = i*5; // enlarge 5 times
this["ring" +i]._yscale = i*5;
this["ring" +i]._alpha = Math.random()*100; //random 0 <= n < 1 , 0-100% Alpha
i = i+1;


frame 3:
if(i<=max){
gotoAndPlay(_currentframe -1);
}



Create 1,000 Christmas trees

Hey, it is fun to create ONE trees and easy to become 1,000 more!







Demo : http://annwongfresh.googlepages.com/duplicateTree2.html
Source : http://annwongfresh.googlepages.com/duplicateTree2.fla
YouTube : http://www.youtube.com/watch?v=dmLAFsrS7qg


ActionScipt :
for(var i = 1; i<100; i++){

tree_mc.duplicateMovieClip("tree"+i,i);
this["tree"+i]._x =(400-1)*Math.random()+1;
this["tree"+i]._y =(300-1)*Math.random()+1;
}


Explain :

for(var i = 1; i<100; i++){ .... } // duplicate 99times

Math.random() // Method; returns n, where 0 <= n < 1
eg. may have 0, 0.5 , 0.2 ... etc.

tree_mc.duplicateMovieClip("tree"+i,i); // duplicate MovieClip

doucment size is 400w x 300h , so _x and _y should be between them.




YouTube : http://www.youtube.com/annwongfresh
Yahoo Blog : http://hk.myblog.yahoo.com/annwongfresh/







Drag & Drop a Star

Drag & Drop a Star (中級 Flash)





Demo : http://annwongfresh.googlepages.com/startDrag.html















Download Source : http://annwongfresh.googlepages.com/startDrag.fla
YouTube : http://www.youtube.com/watch?v=1nMXy-sqbtY

ActionScript :


star_mc.onPress = function() {
startDrag(this);
};
star_mc.onRelease = function() {
stopDrag();
};