PDA

View Full Version : Teething troubles


steadi
05-01-2004, 05:51 AM
Hi there, please forgive me this question as I know it's probably very basic but it's got me stumped.
Here's what I'm trying to do:
I have a couple of buttons that work as a main menu of sorts (buttonGimbal, buttonMon, etc.), a listbox (itemSel) and two text boxes.
When a user selects one of the buttons the contents of the listbox change to provide options for the selected subject.
If the user then selects an item from the listbox, the two textboxes (itemDescr and itemPrice) show information and pricing details for that subselection.
All the data comes from a data.txt which is populated as such:

&gimbal1=name|5000|2|0|descriptive text here&
&gimbal2=name|3400|3|12|descriptive text here&

where the second item is price and the fourth item is the description

So far I can import the data and populate the listboxes just fine (loaded the textfile into several arrays with 4 variables each) but I can't figure out how to get the item description/price to come up.
I thought of declaring a new variable and filling that with the imported data by changing the contents for each selected main item, but I don't know how to get this to work.
I should warn you that this is my first attempt at programming with actionscript, having come from Visual Basic, so I've picked up some nasty habits that don't work here.
So please be gentle with me...
Thanks, Ruben

CyanBlue
05-01-2004, 08:12 PM
Howdy and Welcome... :)

Quick sample that loads your text data...data_lv = new LoadVars();
data_lv.onLoad = function (success)
{
if (success)
{
for (var i = 1 ; i <= Number(this.dataCount) ; i++)
{
_level0["data" + i + "_arr"] = this["gimbal" + i].split("|");
}
trace(_level0.data1_arr[4]);
}
else
{
trace("Problem loading data file...");
}
}
data_lv.load("LoadText.txt");As you can see, _level0.data1_arr[4] contains the description...
I have added one more line on your text file as well...&gimbal1=name|5000|2|0|descriptive text here&
&gimbal2=name|3400|3|12|descriptive text here&
&dataCount=2&

steadi
05-12-2004, 09:21 AM
Thanks for the welcome and the help, however I'm not much further than before.
As I said, I can load the data fine and I can populate the listbox.
What I'd like is to have the user select an item from the listbox and then fill two text boxes (itemDescr and itemPrice) with the relevant data from the text file.
So the user would first select a category from the main menu, then the listbox would fill with the relevant items (so far, so good).
Then the user can select one of those items and get a description/price.
All this comes from the same text file.
Then when the user clicks a 'select' button, it should remember the users selection and display it in a third textbox.

I can't figure out how to get the textboxes to update correctly on selection, I''m assuming I need to use variables but I'm stumped as to where to put them and how to best use them.
Like I said, I'm terribly new at actionscript and I'm doing this as a favour for a friend of mine in my spare time and having come from Visual Basic I've picked up a few habits that are getting in my way... :(

I hope this made some sense, it's really a very simple idea but I just can't figure out the best way to aproach this in Actionscript...
Thanks for your help

Ruben

CyanBlue
05-13-2004, 08:43 AM
Why don't you post the sample that tells me where you are having problem??? I think that's whole lot easier for us to tackle where the problem is... :)