Hi Im hoping someone will be kind enough to help me.
I have pieced together from a number of tutorials an xml as3 fading portfolio,(see attached Flv.
and have to admit at this point I don’t fully understand the code I have assembled(I realise this deconstructionist way of learning is not ideal but sometimes …)
At present the buttons for the fading slide show are made from small versions of the main images. What I am hoping to do is to change the script so I can create a simple set of buttons (from movie clips) 1 to 10 say and have them linked to a corresponding image.
The idea is that I can then highlight the button which is selected.I have got stuck with this and while i slowly learn more about “arrays…” any help would be really appreciated . Also if anyone knows of a tutorial :XML as3 fading slide show ,that would be very helpful thanks.
textureworks( sorry for all code below couldn’t seem to attach as a Flv file)
stop();
import biz.Flashscript.utils.TextLoader;
import biz.Flashscript.utils.LoaderClass;
import biz.Flashscript.utils.LoaderClassStatic;
import biz.Flashscript.tweens.ApplyTweensTimer;
// declaring variables
var imageArray:Array = new Array ();
var lcs:LoaderClassStatic=new LoaderClassStatic();
var hangerLoader:Loader = new Loader();
var hangTen:String = “images/pic_1.jpg”;
var urlREQhang:URLRequest = new URLRequest(hangTen);
addChild(hangerLoader);
hangerLoader.load(urlREQhang);
hangerLoader.x=0;
hangerLoader.y=60;
//adding the main image holder
var imageHolder:Sprite=new Sprite();
imageHolder.x=0;
imageHolder.y=60;
addChild(imageHolder);
// loading the XML file
var myXML:TextLoader = new TextLoader();
myXML.initText(“menu.xml”,completeHandler);
function completeHandler(e:Event,a:String,b:Number,c:Boolean):void {
var myXML:XML=new XML(e.currentTarget.data);
// we cycle through the nodes of the XML file
var count01:Number = 0;
var myTimer:Timer = new Timer(400,myXML.sub.length());
myTimer.addEventListener(TimerEvent.TIMER, loadingThumbs);
myTimer.start();
function loadingThumbs(e:TimerEvent):void {
// we create holders for the thumbs and position them
var _mc:MovieClip = new MovieClip();
_mc.name="_mc"+count01;
_mc.x = (15 * count01) +578;
_mc.y = 423;
_mc.alpha = 0;
_mc.buttonMode=true;
// we get the URL and name of the slides
var slideURL:String=myXML.sub.attribute("slide")[count01];
var slideName:String=myXML.sub.attribute("name")[count01];
_mc.slideURL=slideURL;
_mc.slideName=slideName;
// we create an array with those data
imageArray.push({ name:slideName,data:slideURL});
addChild(_mc);
// we load the images into the imageholders _mc
var lc:LoaderClass=new LoaderClass();
lc.initLoader(slideURL,loadingComplete,_mc);
count01++;
}
}
// Function when loading of thumbs is complete
function loadingComplete(ev:Event,a:Object,b:Object,c:Object):void {
// we need to scale the thumbs and set alpha back to 1
var mc:MovieClip=ev.currentTarget.content.parent.parent;
mc.scaleX=0.02;
mc.scaleY=0.05;
mc.alpha = 0;
// we make buttons out of the thumbs
mc.addEventListener(MouseEvent.CLICK,mouseHandler);
}
// Function when thumbs are pressed to load slides into an imageHolder
function mouseHandler(ev:MouseEvent):void {
var hangTen:String = "white.jpg";
var urlREQhang:URLRequest = new URLRequest(hangTen);
addChild(hangerLoader);
hangerLoader.load(urlREQhang);
hangerLoader.alpha=0;
//removeChild(wMButtonAboutLoader);
imName.text=ev.currentTarget.slideName;
var myURL:String=ev.currentTarget.slideURL;
/*
we first test if the imageHolder is empty. If it is empty we load the slide
and fade it in. If it is not empty we first fade out the previous slide and add an
event listener evoked when the fade out is complete.
*/
if (imageHolder.width>0) {
var at:ApplyTweensTimer = new ApplyTweensTimer(imageHolder,20,"alphaOut",10,1000);
at.initTweens();
at.addEventListener(ApplyTweensTimer.CALL_BACK,faderin);
function faderin(ev:Event):void {
lcs.initLoader(myURL,imageDisplay,imageHolder);
}
} else {
lcs.initLoader(myURL,imageDisplay,imageHolder);
}
}
// Function to fade in the slide after loading it into the imageHolder
function imageDisplay(ev:Event):void {
var at:ApplyTweensTimer = new ApplyTweensTimer(ev.target.content.parent.parent,80,“alphaIn”,10,1000);
at.initTweens();
}
var borderLoader:Loader = new Loader();
var border:String = “border.swf”;
var urlREQBorder:URLRequest = new URLRequest(border);
addChild(borderLoader);
borderLoader.load(urlREQBorder);
borderLoader.y=60;