Monthly ArchiveJuly 2006
Action Script 21 Jul 2006 08:44 am
Slide Show Class for Dynamic Image Gallery updated
May be you already read my post about Slide Show Class for Dyanmic Image Gallery.
Now the class is update which are now has horizontal and vertical slide fx available.
-
//
-
// Slide Show Tween Class V2
-
//
-
class janumedia.fx.tween {
-
-
private var mc:MovieClip; // target mc
-
private var mask1:MovieClip; // mask1
-
private var mask2:MovieClip; // mask2
-
private var img1:MovieClip; // mc1
-
private var img2:MovieClip; // mc2
-
private var border:MovieClip; // border mc
-
private var width:Number; // width
-
private var height:Number // height
-
private var orientation:String; // slide orientation
-
private var data:Array; // image gallery
-
private var speed:Number; // tween speed interval
-
private var cur:Number; // current play
-
private var tw:Boolean; // tween status
-
private var intervalID;
-
-
function tween(t:MovieClip,d:Array,s:Number,o,w:Number,h:Number){
-
// t = movieclip target ; d = image list in array ; s = swening speed interval in sec ;
-
// o = orientation --> available : "alpha" => alpha, "x" => horizontal, "y" => vertical
-
// w = witdh , h = height
-
mc = t.createEmptyMovieClip("mainSlide",t.getNextHighestDepth());;
-
data = d;
-
speed = s;
-
cur = 0;
-
tw = false;
-
width = w;
-
height = h;
-
orientation = o == undefined ? "alpha" : o;
-
prepared();
-
}
-
private function prepared(){
-
img1 = mc.createEmptyMovieClip("img1",10);
-
img2 = mc.createEmptyMovieClip("img2",9);
-
img1.createTextField("status",10,200,125,10,10);
-
img2.createTextField("status",10,200,125,10,10);
-
-
// set masking if the value is available
-
if(width != undefined and height != undefined) addMask(mc,0,0,width,height);
-
-
if(data.length>= 1){
-
var theImg = nextImage();
-
if(theImg != "" && theImg != undefined ){
-
deleteNoImage(img1);
-
loadImage(img1,theImg);
-
} else {
-
noImage(img1);
-
}
-
}
-
-
if(data.length>= 2){
-
var theImg = nextImage();
-
if(theImg != "" && theImg != undefined ){
-
deleteNoImage(img2);
-
loadImage(img2,theImg);
-
} else {
-
noImage(img2);
-
}
-
}
-
-
}
-
private function beginTween(n:MovieClip){
-
clearInterval(intervalID);
-
//trace("begin tween "+n);
-
-
switch(n){
-
case img1 :
-
img2.owner = this;
-
img2.onEnterFrame = function(){ this.owner.doSlide(this); }
-
break
-
case img2 :
-
img1.owner = this;
-
img1.onEnterFrame = function(){ this.owner.doSlide(this); }
-
break;
-
}
-
}
-
-
private function doSlide(t:MovieClip){
-
-
switch(orientation){
-
case "alpha":
-
//trace("tween for "+t._name);
-
t._x = 0;
-
t._y = 0;
-
t._alpha -= speed;
-
var otherImg = eval( t._name == "img1" ? img2 : img1 );
-
with(otherImg){
-
_x = 0;
-
_y = 0;
-
}
-
if(t._alpha <= 0) {
-
t.swapDepths(9);
-
otherImg.swapDepths(10);
-
delete t.onEnterFame;
-
var theImg = nextImage();
-
if(theImg != "" && theImg != undefined ){
-
deleteNoImage(t);
-
loadImage(t,theImg);
-
} else {
-
noImage(t);
-
}
-
}
-
break;
-
case "x":
-
t._y = 0;
-
t._x -= speed;
-
t._alpha = 100;
-
var otherImg = eval( t._name == "img1" ? img2 : img1 );
-
with(otherImg){
-
_x = t._x + t._width;
-
_y = 0;
-
_alpha = 100;
-
}
-
if(t._x <= - t._width ) {
-
delete t.onEnterFame;
-
var theImg = nextImage();
-
if(theImg != "" && theImg != undefined ){
-
deleteNoImage(t);
-
loadImage(t,theImg);
-
} else {
-
noImage(t);
-
}
-
}
-
break;
-
case "y":
-
t._x = 0;
-
t._y -= speed;
-
t._alpha = 100;
-
var otherImg = eval( t._name == "img1" ? img2 : img1 );
-
with(otherImg){
-
_x = 0;
-
_y = t._y + t._height;
-
_alpha = 100;
-
}
-
-
if(t._y <= - t._height ) {
-
delete t.onEnterFame;
-
var theImg = nextImage();
-
if(theImg != "" && theImg != undefined ){
-
deleteNoImage(t);
-
loadImage(t,theImg);
-
} else {
-
noImage(t);
-
}
-
}
-
break;
-
}
-
}
-
-
private function nextImage():String{
-
var n = cur;
-
cur++;
-
cur = cur>= data.length ? 0 : cur;
-
//trace("cur : "+cur+" : "+data[n]);
-
return data[n];
-
}
-
-
private function loadImage(t:MovieClip,img){
-
//trace("load : "+img+" to : "+t);
-
-
t._parent.status.autoSize = "center";
-
t._parent.status.embedFonts = true;
-
var fmt:TextFormat = new TextFormat();
-
fmt.font = "Arial"
-
t._parent.status.setTextFormat(fmt);
-
-
var my_mcl = new MovieClipLoader();
-
var myListener = new Object();
-
myListener.owner = this;
-
myListener.onLoadComplete = function (tmc:MovieClip, bytesLoaded:Number, bytesTotal:Number) {
-
tmc._alpha = 100;
-
if(this.owner.tw) this.owner.intervalID = setInterval(this.owner,"beginTween",speed * 1000,tmc);
-
this.owner.tw = true;
-
}
-
myListener.onLoadProgress = function(tmc:MovieClip, bytesLoaded:Number, bytesTotal:Number) {
-
var a = Math.round((bytesLoaded/bytesTotal)*100);
-
t._parent.status.text = a+"%";
-
//trace("load progress ");
-
}
-
my_mcl.addListener(myListener);
-
my_mcl.loadClip(img, t);
-
}
-
-
private function deleteNoImage(t:MovieClip){
-
removeMovieClip(t.noimage);
-
}
-
-
private function noImage(t:MovieClip){
-
// trace("no image");
-
var x = 0;
-
var y = 0;
-
var w = 399;
-
var h = 250;
-
t.createEmptyMovieClip("noimage", 123456);
-
var mc = t.noimage;
-
with(mc){
-
beginFill(0xFFFFFF);
-
lineStyle(0, 0xC9C9C9);
-
moveTo(x, y);
-
lineTo(w, y);
-
lineTo(w, h);
-
lineTo(x, h);
-
lineTo(x, y);
-
endFill();
-
}
-
mc.createTextField("status",10,mc._width/2,(mc._height/2)-14,10,10);
-
with(mc.status){
-
autoSize = "center";
-
text = "no image";
-
embedFonts = true;
-
selectable = false;
-
textColor = 0xC9C9C9;
-
}
-
-
var fmt:TextFormat = new TextFormat();
-
with(fmt){
-
font = "Arial";
-
size = 14;
-
}
-
mc.status.setTextFormat(fmt);
-
}
-
-
private function addMask(t:MovieClip,x,y,w:Number,h:Number){
-
-
var mask = t.createEmptyMovieClip("mask_mc", t.getNextHighestDepth());
-
with(mask){
-
beginFill(0xFF0000);
-
moveTo(x, y);
-
lineTo(w, y);
-
lineTo(w, h);
-
lineTo(x, h);
-
lineTo(x, y);
-
endFill();
-
}
-
t.setMask(mask);
-
}
-
-
public function move(x:Number,y:Number):Void{
-
mc._x = x;
-
mc._y = y;
-
}
-
-
public function set mode(t:String){
-
orientation = t;
-
}
-
-
public function drawBorder(s:Number,w:Number,h:Number,c):Void{
-
border = mc.createEmptyMovieClip("border_mc", mc.getNextHighestDepth());
-
with(border){
-
lineStyle(s,c);
-
moveTo(0, 0);
-
lineTo(w, 0);
-
lineTo(w, h);
-
lineTo(0, h);
-
lineTo(0, 0);
-
}
-
}
-
-
public function clearBorder(s:Number,w:Number,h:Number,c):Void{
-
border.clear();
-
}
-
}
How to use it? Simple is much the same as the old version all you need to add is the fx / orientation, also add masking if you want it.
-
// sample 1 vertical slide show
-
var slideShow = new janumedia.fx.tween(this,["image1.jpg","image2.jpg"],1,"y",320,250);
-
// sample 2 horisonal slide show
-
var slideShow = new janumedia.fx.tween(this,["image1.jpg","image2.jpg"],1,"x",320,250);
-
// sample 3 alpha fx slide show
-
var slideShow = new janumedia.fx.tween(this,["image1.jpg","image2.jpg"],1,"alpha",320,250);
Online example and get source
Flash Games 21 Jul 2006 01:46 am
Flash Games Programming Wiki
http://fgpwiki.corewatch.net/wiki/Main_Page
One of the best resources for Flash Games Developer. You can find a lot information there.
Uncategorized 18 Jul 2006 02:17 am
Lagi, Gempa Bumi & Tsunami
Duh, apa gerangan dosa bangsa ini sehingga ibu pertiwi seperti tiada habis murkanya.
Sejak tsunami yg melanda Aceh hampir 2 tahun lalu sepertinya bencana ga ada habisnya.
Di saat masyarakat Jogja was-was pada meletusnya Gunung Merapi malah tak dinyana ada gempa hebat melanda Jogja trutama Bantul yg mendapat efek paling parah. Belum selesai berita di media-media tentang gempa Jogja, kini (kemarin 17/7/2006) gempa dgn skala ricther rata-2 6 sebanyak tiga kali terjadi di beberapa wilayah Jawa (Jakarta, Jawa Barat, Jawa Tengah) yg kemudian disusul tsunami menimpa pesisir selatan Jawa dengan lokasi paling parah di pantai Pangindaran , Jawa Barat. Setidaknya 110 nyawa melayang.
Sebuah info jg menyebutkan bahwa gempa akan merembet ke Bali yg dalam beberapa tahun terakhir tertimpa bencana bom 2x. Duh sampai kapan bencana akan melanda Indonesia. Kapan bangsa ini mau bertobat dari segala sifat keserakahan, kekerasan yg seperti tiada berujung.


