Trailer : Adobe flash cs4 website tutorial: 0109 XML Image Gallery
* Fla Timeline code :
var xml:XML = new XML();
var img_count:uint;
var loader:URLLoader = new URLLoader();
var img_holder:Sprite=new Sprite();
var sw:Number=stage.stageWidth;
addChild(img_holder);
function xmlloaded(e:Event):void {
xml=XML(e.target.data);
img_count = xml.img.length()-1;
* createThumb Class :
/*
VERSION: 0.1
DATE: 6/27/2009
ACTIONSCRIPT VERSION: 3.0
UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.onenterflash.com
DESCRIPTION:
Loads and displays a thumb and main picture on click of thumb image.
EXAMPLES:
**
var img_holder:Sprite=new Sprite();
var thumb:Sprite=new createThumb(img_holder,'smallimage/file.png','largeimage/file.png');
thumb.x=205*i;
img_holder.addChild(thumb);
addChild(img_holder);
**
CODED BY: Waarith Abdul-Majeed, questions@onenterflash.com
Copyright 2009, OnEnterFlash
*/
package {
import flash.display.Loader;
import flash.display.Sprite;
import flash.display.Bitmap;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.net.URLRequest;
public class createThumb extends Sprite {
private var arraytween:Array = new Array();
private var thumb_loader:Loader;
private var photo_loader:Loader;
private var thumb_url:String;
private var photo_url:String;
private var thumb_bit:Bitmap;
private var photo_bit:Bitmap;
private var mother:Sprite;
private var thumb_btn:Sprite;
public function createThumb(childof:Sprite,thumburl:String,photourl:String) {
mother=childof;
thumb_url=thumburl;
photo_url=photourl;
loadthumb();
}
private function loadthumb():void {
thumb_loader = new Loader();
thumb_loader.load(new URLRequest(thumb_url));
thumb_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,displaythumb);
}
private function displaythumb(e:Event):void {
thumb_btn = new Sprite();
thumb_bit= new Bitmap();
thumb_btn.graphics.beginFill(0x000000,0);
thumb_btn.graphics.drawRect(0,0,200,200);
thumb_btn.graphics.endFill();
thumb_bit=e.target.content as Bitmap;
thumb_btn.width=thumb_btn.height=thumb_bit.width=thumb_bit.height=200;
thumb_bit.smoothing=true;
addChild(thumb_bit);
addChild(thumb_btn);
thumb_btn.addEventListener(MouseEvent.CLICK,loadphoto);
}
private function loadphoto(e:Event):void {
arraytween.push(new Tween(mother,"y",Regular.easeOut,mother.y,400,.5,true));
photo_loader = new Loader();
photo_loader.load(new URLRequest(photo_url));
photo_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,displayphoto);
}
private function displayphoto(e:Event):void {
stage.addEventListener(MouseEvent.CLICK,closephoto);
photo_bit= new Bitmap();
photo_bit=e.target.content as Bitmap;
photo_bit.smoothing=true;
photo_bit.x=(stage.stageWidth-photo_bit.width)/2;
photo_bit.y=(stage.stageHeight-photo_bit.height)/2;
stage.addChild(photo_bit);
}
private function closephoto(e:Event):void {
arraytween.push(new Tween(mother,"y",Strong.easeOut,mother.y,0,.5,true));
arraytween[arraytween.length-1].addEventListener(TweenEvent.MOTION_FINISH,cleartween);
photo_loader.unload();
if (photo_bit!=null) {
stage.removeChild(photo_bit);
}
stage.removeEventListener(MouseEvent.CLICK,closephoto);
}
private function cleartween(e:TweenEvent):void {
arraytween=[];
}
}
}
VERSION: 0.1
DATE: 6/27/2009
ACTIONSCRIPT VERSION: 3.0
UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.onenterflash.com
DESCRIPTION:
Loads and displays a thumb and main picture on click of thumb image.
EXAMPLES:
**
var img_holder:Sprite=new Sprite();
var thumb:Sprite=new createThumb(img_holder,'smallimage/file.png','largeimage/file.png');
thumb.x=205*i;
img_holder.addChild(thumb);
addChild(img_holder);
**
CODED BY: Waarith Abdul-Majeed, questions@onenterflash.com
Copyright 2009, OnEnterFlash
*/
package {
import flash.display.Loader;
import flash.display.Sprite;
import flash.display.Bitmap;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.net.URLRequest;
public class createThumb extends Sprite {
private var arraytween:Array = new Array();
private var thumb_loader:Loader;
private var photo_loader:Loader;
private var thumb_url:String;
private var photo_url:String;
private var thumb_bit:Bitmap;
private var photo_bit:Bitmap;
private var mother:Sprite;
private var thumb_btn:Sprite;
public function createThumb(childof:Sprite,thumburl:String,photourl:String) {
mother=childof;
thumb_url=thumburl;
photo_url=photourl;
loadthumb();
}
private function loadthumb():void {
thumb_loader = new Loader();
thumb_loader.load(new URLRequest(thumb_url));
thumb_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,displaythumb);
}
private function displaythumb(e:Event):void {
thumb_btn = new Sprite();
thumb_bit= new Bitmap();
thumb_btn.graphics.beginFill(0x000000,0);
thumb_btn.graphics.drawRect(0,0,200,200);
thumb_btn.graphics.endFill();
thumb_bit=e.target.content as Bitmap;
thumb_btn.width=thumb_btn.height=thumb_bit.width=thumb_bit.height=200;
thumb_bit.smoothing=true;
addChild(thumb_bit);
addChild(thumb_btn);
thumb_btn.addEventListener(MouseEvent.CLICK,loadphoto);
}
private function loadphoto(e:Event):void {
arraytween.push(new Tween(mother,"y",Regular.easeOut,mother.y,400,.5,true));
photo_loader = new Loader();
photo_loader.load(new URLRequest(photo_url));
photo_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,displayphoto);
}
private function displayphoto(e:Event):void {
stage.addEventListener(MouseEvent.CLICK,closephoto);
photo_bit= new Bitmap();
photo_bit=e.target.content as Bitmap;
photo_bit.smoothing=true;
photo_bit.x=(stage.stageWidth-photo_bit.width)/2;
photo_bit.y=(stage.stageHeight-photo_bit.height)/2;
stage.addChild(photo_bit);
}
private function closephoto(e:Event):void {
arraytween.push(new Tween(mother,"y",Strong.easeOut,mother.y,0,.5,true));
arraytween[arraytween.length-1].addEventListener(TweenEvent.MOTION_FINISH,cleartween);
photo_loader.unload();
if (photo_bit!=null) {
stage.removeChild(photo_bit);
}
stage.removeEventListener(MouseEvent.CLICK,closephoto);
}
private function cleartween(e:TweenEvent):void {
arraytween=[];
}
}
}