Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 01-10-2005, 01:25 PM   #1
betamax
Registered User
 
Join Date: Oct 2003
Location: UK
Posts: 110
Default Incrementing problem?

I'm working on an XML driven photo gallery. I have a number of icons which need to correspond to the relevant thumbnail image so when the user clicks on the icon the relevant thumbnail is displayed. The problem i have is to do with incrementing I think.

Heres the code:
Code:
for (var i = 0; i<picCount; i++) {
	thumbImage = mySection.childNodes[i].attributes.thumbURL;
	jpegImage = mySection.childNodes[i].attributes.jpegURL;
	tnHolder = _root.tnLoader.attachMovie("thumb_container", "tc"+i+"_mc", i);
	tnHolder.loadMovie(thumbImage);
	tnHolder._x = i*75;
	tnIcon = _root.testHolder.attachMovie("tn_icon", "tnIcon"+i+"_mc", i);
	tnIcon._y = i*35;
///// THE PROBLEM IS WTH THE FOLLOWING BIT /////
	tnIcon.onPress = function() {
		trace(tnIcon);}
		}
At the moment all tnIcons trace the same value when clicked, I need them to trace the corresponding value.
tnIcon 1 - traces Icon1
tnIcon 2 - traces Icon2
tnIcon 3 - traces Icon3

Any help much appreciated.
Cheers
betamax is offline   Reply With Quote
Old 01-10-2005, 01:54 PM   #2
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Howdy and Welcome...

You could try to assign another variable and use that one instead...
ActionScript Code:
for (var i = 0; i < picCount; i++) {     thumbImage = mySection.childNodes[i].attributes.thumbURL;     jpegImage = mySection.childNodes[i].attributes.jpegURL;     tnHolder = _root.tnLoader.attachMovie("thumb_container", "tc" + i + "_mc", i);     tnHolder.loadMovie(thumbImage);     tnHolder._x = i * 75;     tnIcon = _root.testHolder.attachMovie("tn_icon", "tnIcon" + i + "_mc", i);     [B]tnIcon.num = i;[/B]     tnIcon._y = i * 35;     ///// THE PROBLEM IS WTH THE FOLLOWING BIT /////     tnIcon.onPress = function()     {         trace([B]this.num[/B]);     }; }
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 01-10-2005, 03:08 PM   #3
betamax
Registered User
 
Join Date: Oct 2003
Location: UK
Posts: 110
Default

Thanks for that CyanBlue, it works fine. Im having a little trouble applying this to my project though.
Code:
tnIcon.num = i;
	tnIcon._y = i*35;
	tnIcon.onRollOver = function() {
		trace(this.num);
		testOver.loadMovie(thumbImage);
			};
Any ideas how i can get the corresponding thumbnail to appear when I roll over the icon.

Much appreciated
betamax is offline   Reply With Quote
Old 01-10-2005, 03:15 PM   #4
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

What about this???
ActionScript Code:
for (var i = 0; i < picCount; i++) {         jpegImage = mySection.childNodes[i].attributes.jpegURL;         tnHolder = _root.tnLoader.attachMovie("thumb_container", "tc" + i + "_mc", i);         tnHolder.loadMovie(thumbImage);         tnHolder._x = i * 75;         tnIcon = _root.testHolder.attachMovie("tn_icon", "tnIcon" + i + "_mc", i);         tnIcon.num = i;         tnIcon.thumbImage = mySection.childNodes[i].attributes.thumbURL;         tnIcon._y = i * 35;         ///// THE PROBLEM IS WTH THE FOLLOWING BIT /////         tnIcon.onRollOver = function() {         trace(this.num);         testOver.loadMovie(this.thumbImage);     }; }
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 01-10-2005, 09:24 PM   #5
betamax
Registered User
 
Join Date: Oct 2003
Location: UK
Posts: 110
Default

Thank you for your time and help CyanBlue that works great, I just shifted a few things around. I've got a new problem now, I don't think the preloader is working. As it stands I am loading the thumbnails into a MC which has a preloader behaviour attached. I think this would work fine with one file but as there are multiple files its causing problems. I think I need some kind of sequential preloader.

In simple terms I want to preload the thumbnails 'behind the scenes' to be accessed instantly by the rollovers.

ActionScript Code:
var gallery_xml = new XML(); gallery_xml.ignoreWhite = true; gallery_xml.load("photo.xml"); gallery_xml.onLoad = function(success) {     if (success) {         var mySection = gallery_xml.firstChild.childNodes[2];         var picCount = mySection.childNodes.length;         for (var i = 0; i<picCount; i++) {             //create icons             tnIcon = _root.testHolder.attachMovie("tn_icon", "tnIcon"+i+"_mc", i);             tnIcon.thumbImage = mySection.childNodes[i].attributes.thumbURL;             //Preload thumbnails into tnHolder MC             tnHolder = _root.tnLoader.attachMovie("thumb_container", "tc"+i+"_mc", i);             tnHolder.loadMovie(tnIcon.thumbImage);             //Space icons             tnIcon._y = i*35;             //icon rollover > show thumbnail             tnIcon.onRollOver = function() {                 testOver.loadMovie(this.thumbImage);             }         }     } else {         trace("Error loading XML file");     } }

Cheers
betamax is offline   Reply With Quote
Old 01-10-2005, 09:25 PM   #6
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Well... I don't know, but you could try this thread to get more information...

http://www.actionscript.org/forums/s...d.php3?t=59554
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 01-10-2005, 09:37 PM   #7
betamax
Registered User
 
Join Date: Oct 2003
Location: UK
Posts: 110
Default

Thanks I'll have a look.
betamax is offline   Reply With Quote
Old 01-10-2005, 11:26 PM   #8
betamax
Registered User
 
Join Date: Oct 2003
Location: UK
Posts: 110
Default

Cheers for the links
Luckily I had a play with Senocular's 'load consecutive jpgs' a while back so i didn't find it too daunting.

I've got my thumbnails preloading in sequence and I have my icons (buttons) loading in too.

What i need to do now is give the icons a rollover function to show the relevant thumbnail, what is the best way to do this? Show/Hide the relevant thumbnail, change depth ie. bring the relevant thumbnail to the top??

Any thoughts appreciated.
betamax is offline   Reply With Quote
Old 01-11-2005, 11:06 AM   #9
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Quote:
I've got my thumbnails preloading in sequence and I have my icons (buttons) loading in too.
I'd probably load the thumbnails into the 1000x1000 location which is an off stage area, and change the _x/_y of the thumbnail to display it whenever you roll over the icon... Just a thought...
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 01-11-2005, 12:14 PM   #10
betamax
Registered User
 
Join Date: Oct 2003
Location: UK
Posts: 110
Default

That sounds like a good plan! cheers

After implementing the sequencial preloader with my thumbnails and icons I'm now back to my original problem - associating the rollover icons with the thumbnail MCs. I'm not sure how to go about this as the code has changed a bit, it now uses arrays.
betamax is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:26 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.