XML and Flash

twister

Howdy
I could use a little help here. I'm jumping into XML really fast and I've been able to get XML data into flash with no problems. What I have is one XML file with 44 of my portfolio pieces information. Now what i'd like to do is be able to filter out all those pieces so when I click on websites, I only read in the web portfolio pieces.

Now I know i could separate them out into different files but some pieces could fall under 'web' and 'flash' and I don't want to be duplicating a bunch of XML child's or whatever they are.

What I did was created three category names and if it fit in the 'web' category, it would contain a 1 otherwise a 0. Now how do i filter my results? I can think it out in my head but not in my code.

My XML example:
<portfolio>
<piece id="0">
<name>test</name>
<url>http://www.test.com</url>
<shortdesc>test</shortdesc>
<desc></desc>
<image>none.jpg</image>
<web>1</web>
<flash>1</flash>
<media>0</media>
</piece>
</portfolio>

My Flash Code:
See Attachment
 

Attachments

I used that for my site, but changed it to a client list instead of a category listing.

<urbansory>
<clients>
<clt id="00" head="Title" link="swf file" tag="tag" />
</clients>

<audio>
<title file="50cent_pwait.swf" />
</audio>

<video>
<title file="vid.swf" />
</video>
</urbansory>

Kinda hard to write this out and explain it, but from the looks of it, you have it down, you just need to do a little tweaking. And since you are using arrays, you can cut down all that code, make a few if statements to catch this or that, or toggle from one section to the other with variables that identify the section.
 
?? I started out with everything in one line but then expanded it. XML is confusing because everyone does it different from what i've seen. I also don't know where to put my if statement.

Also what code can i cut down? The XML?

Thanks
 
Wow, awesome thats some compliment for an unfinished site, but i really appreciate it. :)

I like the one line version because it's easier to read when you have tons of data to sort through or add.

Cut down the functions, my code is setup to go through one list, sort alphabetically, then pass the array to another function that passes other variables to duplicated movie clips that make up the portfolio sections list. My code is about half of your code. I would make it a while statement that passes through, once thats met, it does it again instead with a different category.

You could use a if or switch/case statement to toggle between the categories. That way you use the same code, but with different variables that control how the function runs.

When i get the time I will make an example run through that displays this.
 
Thanks for all your help. I'm going in circles trying to find information on the web and the best way to do this. However I'm still spinning my wheels. If you get time, could you make me up an example?

Thanks
 
Oh I figured it out. I need to look at my <web>1</web> value when duplicating my MCs not when i'm first reading all the crap, um i mean stuff, in. I probably still have way to many lines of code though. :D
 
As long as it works and you know why it works, thats all that matters, you can chop down the code at another time. I general hard code my designs, make sure they work then i go back an clean up the code, but after doing this for a while, you begin to use the short form as more routine.

My mixer has a crazy amount of code, and I'm still cleaning it up, but most importantly i wanted it to work with as little bugs as possible. The next release will be faster, far less bugs and more features.
 
Back
Top