kehmical
09-03-2009, 06:05 PM
Hello,
Does anyone know how to do a photo viewer like this in AS3?
http://www.toxiclab.org/tutorial.asp?ID=79
No XML, just 5 or so bitmaps, a left button and a right button.
If you know of a good tutorial that would be great.
j
bertha_b52
09-03-2009, 07:10 PM
Here is a gallery that I created a while back. Just copy the code below. Hope this helps.
//create a movie clip with the instance name sections and nest photos in sequential frames (as many as you want)
//create a button called btn_play and also a button named btn_back
btn_play.addEventListener(MouseEvent.CLICK, goForward, false, 0, true);
//
function goForward(evt:MouseEvent):void {
trace("play is clicked");
//
if (activeSection==sections.totalFrames) {
//
activeSection=1;
} else {
activeSection++;
}
getNewSection();
}
btn_back.addEventListener(MouseEvent.CLICK, goBack, false, 0, true);
//
function goBack(evt:MouseEvent):void {
trace("back is clicked:", activeSection);
//
// first. increment the activeSection var
if (activeSection==1) {
//
trace("ative secton is 1", sections.totalFrames);
activeSection=sections.totalFrames;
} else {
activeSection--;
}
// then call getNewSection():
getNewSection();
}
//
// the default tweenlite stuff
import gs.TweenLite;
import gs.easing.*;
//
// variables for easing, and tween time
var easyEase:* =Cubic.easeInOut;
//var jiggleEase:* =Bounce.easeInOut;
var tweenTime:Number=.5;
var activeSection:uint=1;
//
// tell the sections mc to stop in the first frame
sections.stop();
//
// these functions handle the transitions
function getNewSection():void {
TweenLite.to(sections, .4, { alpha:0, ease:easyEase, onComplete:updateSection});
}
function updateSection():void {
sections.gotoAndStop(activeSection);
TweenLite.to(sections, .4, { alpha:1, ease:easyEase});
}
kehmical
09-03-2009, 07:25 PM
I will give it a try, thank you very much.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.