#1 (permalink)  
Old 06-17-2008, 11:00 PM
Junior Member
 
Join Date: Jun 2008
Posts: 4
Default Can i select a category?

I need to open the flash with a category selected, not the first one, like it does now. Is there any way i can do that?

Thanx in advance
Reply With Quote
  #2 (permalink)  
Old 06-18-2008, 05:20 PM
Junior Member
 
Join Date: Jun 2008
Posts: 4
Default keep trying

i have tried this:

var Albums:Array = xd.root.childNodes;
for(var i=0; i< Albums.length;i++)
{
if(Albums[i].attributes.name == album)
{
TitleBar_mc.data = Albums[i];
ThumbsGrid_mc.data = Albums[i];
TabSlider_mc.data = xd.root;
break;

}
}

where album has the name of the category i wasnt to select. Everything works but the TabSlider_mc, i get the photos of the album i selected, but the tabslider keeps the selection on the first category. I tried to simulate a click but i couldnt make it. Is there any method i can call in TabSlider_mc, passing an XMLNode, to change the selection as if i clicked on a category?
Reply With Quote
  #3 (permalink)  
Old 06-20-2008, 10:44 AM
Super Moderator
 
Join Date: May 2008
Posts: 561
Send a message via Skype™ to Adrian
Default

Hi,
In the TabSlider.as file, line 109:

Code:
if (i == 0) {
	tb.setInitTab();
}
This means it selects the first tab.

Now you could do something like:

Code:
var Albums:Array = xd.root.childNodes;
for(var i=0; i< Albums.length;i++)
{
if(Albums[i].attributes.name == album)
{
TitleBar_mc.data = Albums[i];
ThumbsGrid_mc.data = Albums[i];
_global.TABINDEX = i;
TabSlider_mc.data = xd.root;
break;
}
}
and for the tab...

Code:
if (i == _global.TABINDEX) {
	tb.setInitTab();
}
Let me know if it works.
Reply With Quote
  #4 (permalink)  
Old 06-20-2008, 03:50 PM
Junior Member
 
Join Date: Jun 2008
Posts: 4
Default

Hi, thank you for your reply. I needed to solved this before i could read any answers, so i came up with another solution, a little more complicated i think, but works until now.


Code:
var Albums:Array = xd.root.childNodes;
for(var i=0; i< Albums.length;i++)
{
	if(Albums[i].attributes.name == album)
	{
		var Copia = Albums[i].cloneNode(true);
		TitleBar_mc.data = Copia;
		ThumbsGrid_mc.data = Copia;
		if(i!=0)
		{
			var Parent = Albums[i].parentNode; 
			Albums[i].removeNode();
			Parent.insertBefore(Copia,Parent.firstChild);
			TabSlider_mc.data = Parent;
		}else
		TabSlider_mc.data = xd.root;
			
		break;

	}
}
I hope this solves the problem for any situations. . Thanx again

Last edited by alejo; 06-20-2008 at 04:01 PM.
Reply With Quote
  #5 (permalink)  
Old 08-17-2008, 07:21 AM
Junior Member
 
Join Date: Aug 2008
Posts: 7
Default

Thanks your bit of code Adrian, it does work perfectly...

Here is a couple things I did with it...

Select a random gallery to load on first run (code goes at the end of the as on frame 2 of the main gallery.fla)
Code:
//select a random gallery to load on first run
randomNum = int(Math.random() * xd.root.childNodes.length);
var Albums:Array = xd.root.childNodes;
TitleBar_mc.data = Albums[randomNum];
ThumbsGrid_mc.data = Albums[randomNum];
_global.TABINDEX = randomNum;
TabSlider_mc.data = xd.root;
Pass in a certain gallery in the url path (or link to a certain gallery)(code goes at the end of the as on frame 2 of the main gallery.fla)
Code:
//pass in a certain gallery in the url path (link to a certain gallery)
//_root.selectedAlbum = "Your Gallery Name";
for(var i=0; i< Albums.length;i++) {
	if(Albums[i].attributes.name == _root.selectedAlbum) {
		TitleBar_mc.data = Albums[i];
		ThumbsGrid_mc.data = Albums[i];
		_global.TABINDEX = i;
		TabSlider_mc.data = xd.root;
		break;
	}
}
//http://yoursite.com/gallery.swf?selectedAlbum=Your Gallery Name
In both code samples you must change the code in TabSlider.as file, line 109 to:
Code:
if (i == _global.TABINDEX) {
	tb.setInitTab();
}
Hope this will help someone...
-scottyFlasher
Reply With Quote
  #6 (permalink)  
Old 10-24-2008, 06:26 PM
Junior Member
 
Join Date: Oct 2008
Posts: 2
Default _root.selectedAlbum

What do I pass in so that _root.selectedAlbum contains a value?
Can this be done within the data.xml file or via params when loading the swf, or both (hopefully)
Reply With Quote
  #7 (permalink)  
Old 10-24-2008, 06:45 PM
Junior Member
 
Join Date: Oct 2008
Posts: 2
Default

Quote:
Originally Posted by michaelbailey View Post
What do I pass in so that _root.selectedAlbum contains a value?
Can this be done within the data.xml file or via params when loading the swf, or both (hopefully)
Nevermind, I just added an element to the category in the xml file
Code:
<category selected="1" name="
and then check for it here
Code:
if(Albums[i].attributes.selected == 1) {
what I have noticed is that if the initial Album's thumbnail image is out of the scrolling area, it is selected, however it is not scrolled into view -

Where would I make that code change at?
I'll keep looking, and if I find it I'll post back here unless it's already been answered.
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.