1. I'm making a coverdisplay flow - using components that are
out there on the net, however the example I found has the amount of
panels that are shown (each picture shown is in a panel), hardcoded
Now, I made a php page which creates an xml file depending on
how many jpg-files are in a certain directory.. I already made a
connection & everything.. But I was wondering, can i somehow
use a for loop in MXML to create a dynamic amount of panels? (so
the amount will depend on how many files are in the folder).
Because all the actionscript code in MXML files needs to be inside
the script tags :s
2nd Question.. is about Objected Oriented programming.
I created a covermanager.. this is called upon out of the
This manager calls on the CoverXML class, which creates an
array of the info from the xml page mentioned in question 1. I then
make sure the array is put inside the Cover class (which just has
the info from the array (imagetitle, year & url)). I'd really
like to use the O.O way of programming, I'd obviously like the
covermanger to be the only class to be called upon, from there out
everything has to happen. I was wondering if that means i just have
to go to the CoverXML class to get the array? If so, what's the
point of that separate Cover class? I'm a bit confused of how that
- cover class
- createXML class
Sorry for the maybe confusing questions.. don't really know
how to phrase them!
Sure it is possible to create the panels dynamic. Just make a
loop and for every iteration create a panel with var pan:Panel =
new Panel(), make your initialization stuff and then add the panel
whereever you want with addChild(pan);
In general the Flex way to do this (not necessarily OO
related) is to use events. Your cover class can listen to the
HTTPService event at the same time you UI class is, and they will
both get the ResultEvent, so they can each do their own thing
without tying the two together.
But unless this is a learning excercise, or you expect to
release this code or reuse it, worrying about design principles you
might not fully understand (I'm no expert myself :) is surely a way
to code yourself into a corner.