Hello, Thank you for looking at my post! Now lets see if you survive to the end of it… I have about 103 lines of code which I have put together but I am very new to programming and I want to make sure it all makes sense and I’m not missing anything or doing anything wrong! I have gotten help from a bunch of individuals on this forum and it all works now!
I have a slideshow that loads through XML. The first picture slides on from the right and stops in the middle of the screen. There is a Next button and a Previous button. When the user presses Next, the currently displayed image slides off to the left as the next image slides on from the right and stops in the middle of the screen. If the user presses Previous, the currently displayed picture slides back off to the right and the previous picture slides on from the left. That is the basic concept of what this programming does. Oh and the buttons glow on and off as the user presses them.
If some kind soul could take the time to review my code and give me any pointers/critiques or comments etc. I would totally appreciate it and you can relax at the end of the day knowing you have done your good deed for the day/week!
[AS]import com.pixelfumes.reflect.;
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.events.Event;
import gs.TweenMax;
import gs.easing.;
var xmlRequest:URLRequest=new URLRequest(“imageData.xml”);
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, xmlLoadedF);
xmlLoader.load(xmlRequest);
var imgData:XML;
var imageReflect:Reflect;
var imageLoader:Loader;
var rawImage:String;
var rawH:String;
var rawW:String;
var imgNum:int = 0;
var lastImageIndex:int = 0;
var imageLoaderHost:MovieClip;
btnNext.addEventListener(MouseEvent.CLICK, nextImgF);
btnBack.addEventListener(MouseEvent.CLICK, prevImgF);
btnNext.buttonMode=true;
btnBack.buttonMode=true;
function xmlLoadedF(event:Event):void {
imgData=new XML(event.target.data);
packagedF();
}
//Loads picture:
function packagedF(e:Event = null):void {
rawImage=imgData.image[imgNum].imgURL;
lastImageIndex = imgData.*.length() - 1;
rawW=imgData.image[imgNum].imgW;
rawH=imgData.image[imgNum].imgH;
imageLoaderHost = new MovieClip;
imageLoader = new Loader;
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadCompleteHandler);
imageLoader.load(new URLRequest(rawImage));
master_mc.addChild(imageLoaderHost);
imageLoaderHost.addChild(imageLoader);
imageLoaderHost.y = (stage.stageHeight - Number(rawH)) /5;
imageLoaderHost.x = 1500;
TweenMax.to(imageLoaderHost, 1.5, {x:(stage.stageWidth - Number(rawW)) /1.75, y:(stage.stageHeight - Number(rawH)) /5, ease:Quad.easeInOut});
TweenMax.from(imageLoader, 1.5, {blurFilter:{blurX:100}});
imageLoader.scaleX=.8;
imageLoader.scaleY=.8;
clearInterval(imgNum);
clearInterval(lastImageIndex);
}
function loadCompleteHandler(event:Event) {
imageLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, loadCompleteHandler);
imageReflect = new Reflect({mc:imageLoaderHost,alpha:50,ratio:50,distance:1,updateTime:2,reflectionDropoff:2});
}
function nextImgF(e:MouseEvent):void {
// Button glows on and off:
TweenMax.from(btnNext, .5, {glowFilter: {color:0x0098ff, alpha: 0.6, blurX:45, blurY:45, strength:10, quality:3}, ease:Quad.easeInOut});
//Moves image currently on screen forward to bring on next picture:
TweenMax.to(imageLoaderHost, 2, {blurFilter: {blurX:100}, x:-1500, y:(stage.stageHeight - Number(rawH)) /5, ease:Quad.easeInOut});
imgNum = imgNum < lastImageIndex ? imgNum + 1 : 0;
// Refers to function to bring on next picture
packagedF();
}
function prevImgF(e:MouseEvent):void {
// Button glows on and off:
TweenMax.from(btnBack, .5, {glowFilter: {color:0x0098ff, alpha: 0.6, blurX:45, blurY:45, strength:10, quality:3}, ease:Quad.easeInOut});
// Moves image currently on screen back to where it came from:
TweenMax.to(imageLoaderHost, 2, {blurFilter: {blurX:100}, x:1500, y:(stage.stageHeight - Number(rawH)) /5, ease:Quad.easeInOut});
imgNum = imgNum > 0 ? imgNum - 1 : lastImageIndex;
// Refers to function to bring on last picture:
imageBackMovement();
}
// Loads previous picture and brings it into view:
function imageBackMovement (e:Event = null):void {
rawImage=imgData.image[imgNum].imgURL;
lastImageIndex = imgData.*.length() - 1;
rawW=imgData.image[imgNum].imgW;
rawH=imgData.image[imgNum].imgH;
imageLoaderHost = new MovieClip;
imageLoader = new Loader;
imageLoader.load(new URLRequest(rawImage));
master_mc.addChild(imageLoaderHost);
imageLoaderHost.addChild(imageLoader);
imageLoaderHost.y = (stage.stageHeight - Number(rawH)) /5;
imageLoaderHost.x = -1500;
TweenMax.to(imageLoaderHost, 1.5, {x:(stage.stageWidth - Number(rawW)) /1.75, y:(stage.stageHeight - Number(rawH)) /5, ease:Quad.easeInOut});
TweenMax.from(imageLoader, 1.5, {blurFilter:{blurX:100}});
imageLoader.scaleX=.8;
imageLoader.scaleY=.8;
clearInterval(imgNum);
clearInterval(lastImageIndex);
}[/AS]