
Finished a new version of the gallery template, this time fading in thumbnails instead of having them move. It's less dynamic, but more like the Flickr galleries it will be replacing. We also had our first group meeting where we hashed out my need for design guidance (in terms of the aesthetics desired for the art gallery) so that what I create is actually what they want. This template can be found
here.code can be found in the comments section. removing the movement reduced the amount of code from around 300 lines to around 100 lines.
code: note that the delay is created not by using a timer, but by counting the number of frames that has passed. i got this idea from researching the code for tower defense games for a game design class I took.
ReplyDeletestop();
import flash.display.*;
import flash.utils.*;
var preview;
var numClips:int = 10;
var currentClip:int = 0;
var gallery:Array = new Array(numClips);
var minFrameProgress:int = 0;
var minFrameLimit:int = 20;
stage.addEventListener(Event.ENTER_FRAME, createArray);
stage.addEventListener(Event.ENTER_FRAME, loadThumbs);
btn1.addEventListener(MouseEvent.MOUSE_OVER, openPrev);
btn2.addEventListener(MouseEvent.MOUSE_OVER, openPrev);
btn3.addEventListener(MouseEvent.MOUSE_OVER, openPrev);
btn4.addEventListener(MouseEvent.MOUSE_OVER, openPrev);
btn5.addEventListener(MouseEvent.MOUSE_OVER, openPrev);
btn6.addEventListener(MouseEvent.MOUSE_OVER, openPrev);
btn7.addEventListener(MouseEvent.MOUSE_OVER, openPrev);
btn8.addEventListener(MouseEvent.MOUSE_OVER, openPrev);
btn9.addEventListener(MouseEvent.MOUSE_OVER, openPrev);
btn10.addEventListener(MouseEvent.MOUSE_OVER, openPrev);
function createArray(e:Event): void
{
gallery[0] = new mc001();
hld1.addChild(gallery[0]);
gallery[0].alpha = 0;
gallery[1] = new mc002();
hld2.addChild(gallery[1]);
gallery[1].alpha = 0;
gallery[2] = new mc003();
hld3.addChild(gallery[2]);
gallery[2].alpha = 0;
gallery[3] = new mc004();
hld4.addChild(gallery[3]);
gallery[3].alpha = 0;
gallery[4] = new mc005();
hld5.addChild(gallery[4]);
gallery[4].alpha = 0;
gallery[5] = new mc006();
hld6.addChild(gallery[5]);
gallery[5].alpha = 0;
gallery[6] = new mc007();
hld7.addChild(gallery[6]);
gallery[6].alpha = 0;
gallery[7] = new mc008();
hld8.addChild(gallery[7]);
gallery[7].alpha = 0;
gallery[8] = new mc009();
hld9.addChild(gallery[8]);
gallery[8].alpha = 0;
gallery[9] = new mc010();
hld10.addChild(gallery[9]);
gallery[9].alpha = 0;
stage.removeEventListener(Event.ENTER_FRAME, createArray);
}
function openPrev(e:MouseEvent): void
{
if(e.target == btn1)
preview = new tc001();
if(e.target == btn2)
preview = new tc002();
if(e.target == btn3)
preview = new tc003();
if(e.target == btn4)
preview = new tc004();
if(e.target == btn5)
preview = new tc005();
if(e.target == btn6)
preview = new tc006();
if(e.target == btn7)
preview = new tc007();
if(e.target == btn8)
preview = new tc008();
if(e.target == btn9)
preview = new tc009();
if(e.target == btn10)
preview = new tc010();
closePrev();
loadWindow.addChildAt(preview, 0);
}
function closePrev(): void
{
loadWindow.removeChildAt(0);
}
function loadThumbs(e:Event):void
{
if(currentClip < numClips)
{
if(minFrameProgress < minFrameLimit)
{
minFrameProgress++;
gallery[currentClip].alpha += .05;
}
else
{
currentClip++;
minFrameProgress = 0;
}
}
else
stage.removeEventListener(Event.ENTER_FRAME, loadThumbs);
}