Advertisement

04.08.2008 at 02:57PM PDT, ID: 23306433
[x]
Attachment Details

slideshow / image gallery in AS3 small glitch, need help please!

Asked by kungricht in Macromedia Flash, Extensible Markup Language (XML), Scripting Languages

Tags: , ,

I have an image gallery with thumbnails that you can click on to go to a certain image and it also automatically plays like a slide show. But while the slideshow is playing, if you click on an image, it goes to that image but then the slideshow picks up where it left off (so if the slide show was on image 2 and you click on image 4, it proceeds to image 3 and then 4 again) and I'd like it to start playing from the image that was clicked: so if you clicked on image three, I'd like the slideshow to continue from there and go to image four. I have just modified code that I found from a tutorial and so I can't get it to do exactly what I want. thanks.
see what I have here: http://www.kelliegraphicdesign.com/gallery/com_daybreakgarbett2.html

here is my code:Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
//timer/////////////////////////////////////////////
 
var autoRotate = 0;
var imageTimer:Timer = new Timer(5000);
imageTimer.addEventListener(TimerEvent.TIMER, readImages);
 
function readImages(event:TimerEvent):void{
if(autoRotate == 0){
	imageTimer.start();
	trace("fired");
		top.alpha = 100;
	img_holder.removeChildAt(0);
if(increment < total-1){
	increment += 1;
} else {
	increment = 0;
}
ImageLoad(LINKS[increment],img_holder,0,0); 
imageNUMB.text = increment+1 + " of " + total;
}
}
//////////////////////////////////////////////////
 
//loader//////////////////////////////////////////
 
import flash.display.*;
import flash.events.*;
import flash.net.URLRequest;
import flash.net.URLVariables;
import fl.transitions.Tween;
import fl.transitions.easing.*;
 
var numOfImages = 90;
var imgNum = 0;
 
 
function ImageLoad(u:String,target,Ypos,Xpos){
	var targetClip = target;
	var positionY = Ypos;
	var positionX = Xpos;
    var _loader:Loader = new Loader();
    var request:URLRequest = new URLRequest(u);
    _loader.load(request);
	 targetClip.addChild(_loader);
	 //targetClip.y = positionY;
	 //targetClip.x = positionX;
	 _loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
	 _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
}
 
function loadProgress(event:ProgressEvent):void {
    var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
    percentLoaded = Math.round(percentLoaded * 100);
	if(percentLoaded > 20){
		trace("firing");
	preLoader.alpha = 100;
	} else{
	preLoader.alpha = 0;
	}
}
 
function completeHandler(event):void {
    trace("DONE");
	preLoader.alpha = 0;
	var myTween:Tween = new Tween(top, "alpha", Strong.easeOut, 1, 0, 1, true);
	imageTimer.start();
}
 
////////////////////////////////////////////////////
 
//xml load//////////////////////////////////////////
 
var loader:URLLoader;
loader = new URLLoader();
var increment = 0;
var total = 0;
var i = 0;
var TITLES = [];
var COPYS = [];
var LINKS = [];
 
//ADD EVENT LISTENER, THIS LISTENS FOR WHEN XML IS LOADED
loader.addEventListener(Event.COMPLETE, xmlLoaded);
 
//DEFINES XML FILE THAT IS LOADED
var request:URLRequest = new URLRequest("com_daybreakgarbett.xml");
loader.load(request);
 
//FUNCTON CALLED ONE XML IS LOADED
function xmlLoaded(event:Event):void {
   //DEFINE MY XML VARIABLE
   var myXML:XML = new XML(loader.data);
   total = myXML.children().length();
   trace(total);
   imageNUMB.text = "1 of " + total;
   ImageLoad(myXML.children().LINK[0],img_holder,0,0); 
   for (i=0; i<total; i++) {
		LINKS[i] = myXML.children().LINK.children()[i];
	}
}
 
////////////////////////////////////////////////////
 
//gallery//////////////////////////////////////////
 
btn1.addEventListener(MouseEvent.MOUSE_DOWN, showimg1); 
function showimg1(event:MouseEvent):void {
	top.alpha = 100;
	img_holder.removeChildAt(0);
ImageLoad(LINKS[0],img_holder,0,0);
imageNUMB.text = 1 + " of " + total;
}
 
btn2.addEventListener(MouseEvent.MOUSE_DOWN, showimg2); 
function showimg2(event:MouseEvent):void {
	top.alpha = 100;
	img_holder.removeChildAt(0);
ImageLoad(LINKS[1],img_holder,0,0);
imageNUMB.text = 2 + " of " + total;
}
 
btn3.addEventListener(MouseEvent.MOUSE_DOWN, showimg3); 
function showimg3(event:MouseEvent):void {
	top.alpha = 100;
	img_holder.removeChildAt(0);
ImageLoad(LINKS[2],img_holder,0,0);
imageNUMB.text = 3 + " of " + total;
}
 
btn4.addEventListener(MouseEvent.MOUSE_DOWN, showimg4); 
function showimg4(event:MouseEvent):void {
	top.alpha = 100;
	img_holder.removeChildAt(0);
ImageLoad(LINKS[3],img_holder,0,0);
imageNUMB.text = 4 + " of " + total;
}
[+][-]04.08.2008 at 03:13PM PDT, ID: 21310133

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Macromedia Flash, Extensible Markup Language (XML), Scripting Languages
Sign Up Now!
Solution Provided By: BongoMoose
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628