PDA

View Full Version : comboBox to load .xml files: pathing


getdjed
08-26-2005, 11:40 AM
Hi!

Thanks in advance for reading my post and for any help given.

I have a comboBox that loads .xml text into a text field. I'm using the following code (thanks xeef for the script ):

//load css
aStyle = new TextField.StyleSheet();
aStyle.load("a.css");
textField.styleSheet = aStyle;

//load in XML
textContent = new XML();
textContent.onLoad = function(success)
{
if(success)
{
textField.text = textContent;
}
}

//comboBox
L = {};
L.change = function(eventObj) {
Index = eventObj.target.selectedIndex;
//here you also coud use the label as file name
//just change data-->label
LOAD(eventObj.target.getItemAt(Index).data);
};
ComboBox.addEventListener("change", L);
function LOAD(URL) {
//or what ever you use to load it
//take care of pathing !
textContent.load(URL, 0);
trace("Here you load rutine "+URL);
}

// Add's the eventListen to be called when someone changes the comboBox
ComboBox.addEventListener("change", form);

The problem is that I've got lots of .xml files to be loaded and I want to have them into an specific folder outside the flash movie. How can I define the path into this script???

Thanks a lot :)

tarjinder80
08-26-2005, 01:00 PM
Hi

You can use _url
I ur fla use trace(_url) .with this u can get the path where ur swf file is located.This can help u.

getdjed
08-26-2005, 02:18 PM
Thank you tarjinder for your help but I'm not an expert in actionscrip and I'm not sure about what to do with trace(_url)... Could you be more specific please?

Imagine that the folder where I store the xml files is called "folder". Could you put it into the script? I'll appreciate this.

L = {};
L.change = function(eventObj) {
Index = eventObj.target.selectedIndex;
//here you also coud use the label as file name
//just change data-->label
LOAD(eventObj.target.getItemAt(Index).data);
};
ComboCau.addEventListener("change", L);
function LOAD(URL) {
//or what ever you use to load it
//take care of pathing !
cauContent.load(URL, 0);
trace("Here you load rutine "+URL);
}

// Add's the eventListen to be called when someone changes the comboBox
ComboCau.addEventListener("change", form);

Thanks again for your help!!!

getdjed
08-29-2005, 04:31 PM
Well, and furthermore, I'm actually using the function:

trace(URL)

Thank you for your help but I still don't know how to use it...

Xeef
08-29-2005, 07:23 PM
Hmmmm

specific folder outside the flash movie

what do you mean by this ?

C:/FMovie/MyFlash.swf
C:/MyXMLs/Xml.xml
?????

load("../MyXMLs/Xml.xml")
".." -> one directory up

getdjed
08-30-2005, 02:48 PM
Thanks again Xeef.

I knew the "../" but this was not exactly the problem, it was only a "lapsus" I had, I didn't know where to define the path in the script... but now it's working perfectly.

The comboBox is now a powerful tool for me, and it's all due to your help. Thanks a lot!