all groups > flash actionscript > july 2005 >
You're in the

flash actionscript

group:

load data from list


load data from list stijn1989
7/19/2005 11:44:06 PM
flash actionscript:
hi

I have a problem with display data from the list component. I read the
livedocs but nothing helped :(
Can someone give me a code that's print the date when I push on a item of the
list....

i have also a second problem: i can't load text in the textarea component

chat.text = "hi there handsome guy.";

but when I do this:

chat.text = loadVariables("test.txt", 0);

he says no error, but when i publish movie, he gives errors.
Can someone help me. I know u can help me.
This is my last hope, nobody understands my problem of don't wanna help me :(
is this so hard then...

with friendly greets of Stijn
Re: load data from list stijn1989
7/20/2005 12:00:00 AM
yes hi again

euh how can i open a PHP file then? When I change ur code test.txt ->
test.php, then I see the codes.
code:
<?php
$Query = mysql_query("SELECT * FROM chat");
while($C = mysql_fetch_assoc($Query))
{
echo "&var =".$C['message']."<br>":
}
?>

how can I just tell to flash that he must print the 'var' and not the code :s

thx
Re: load data from list NSurveyor
7/20/2005 12:00:00 AM
The onData handler is to get raw text from a file. This is obviously not what
you want. In this case, you would use the onLoad handler:

myloadvars = new LoadVars();
myloadvars.onLoad = function(success){
chat.text = this.var;
};
myloadvars.load("test.php");

But note, this code is most likely to not work. You should NEVER use reserved
words as variable names. var is reserved as it is used to declare local
variables. I would change that to myVar. And for code;


myloadvars = new LoadVars();
myloadvars.onLoad = function(success){
chat.text = this.myVar;
};
myloadvars.load("test.php");

Re: load data from list juankpro
7/20/2005 12:03:08 AM
About your first question, your are not giving us enough data to help you. What
is that you exactly want to do, using what version of flash and using what kind
of data. Maybe if you write some code.

About the second question, you can never load data just by saying chat.text =
loadVariables("test.txt", 0);. This process is more complicated than just a
single line.

There are many approaches when loading data, the loadVariables approach is
somewhat old and has some disadvantages, this is the way I am used to load data
found on a txt file:

myloadvars = new LoadVars();
myloadvars.onData = function(myText){
chat.text = myText;
};
myloadvars.load("test.txt");

This method loads all the text present inside the txt file. If instead of
using onData you use onLoad you can load data stored in variables in
URL-Encoded format.
Re: load data from list juankpro
7/20/2005 12:06:14 AM
The loading process requires all those lines becuase data loading in flash is
not done inmediately. Data is loaded asynchronously that means that after
calling a load method you must wait until the data is loaded and ready for
using. This is what the onData function does. It runs only when the data is
already loaded.
Re: load data from list stijn1989
7/20/2005 12:17:07 AM
hi

i thank u for ur code for my second question :lips; :p

but what I mean with my first question:

I have a list component in my movie.
data: [1,2,3]
labels: [stijn, ivo, graham]

when i press label Stijn I want to print the data that is linked with the
label: so I will see on my screen 1.

how can i do that?
Re: load data from list stijn1989
7/20/2005 8:54:14 AM
but what I mean with my first question:

I have a list component in my movie.
data: [1,2,3]
labels: [stijn, ivo, graham]

when i press label Stijn I want to print the data that is linked with the
label: so I will see on my screen 1.

how can i do that?
Re: load data from list stijn1989
7/21/2005 8:09:26 PM
mhz my problem is not fixed dudes :p well I give up my code and date :)

So I have List compo:
Data: stijnleenknegt1@hotmail.com, fan_moreira@hotmail.com
Labels: Stijn, Ivo

--code--
on(itemRollOver)
{
toon.text = emails.getItemAt();
}

this code is linked on the list compo, but when i test it, I don't see on my
textfield component the data of the item where I rollover. :(

can u help me plz, i searching for a week dudes :/

greetz stijn
Re: load data from list NSurveyor
7/22/2005 12:00:00 AM
Try:

Re: load data from list stijn1989
7/22/2005 12:00:00 AM
it doesn't work :( he doesn't display it :(

undefined

--code--
on(itemRollOver)
{
trace(emails.selectedItem.data);
}

Re: load data from list LuigiL
7/22/2005 12:00:00 AM
About the list component. Here is an example. Put a listbox component on the
stage and give it an instance name of myListBox_lb
Create a new layer and call it 'actions'. Put the attached script on frame 1
of the layer actions. Test your movie.



myListBox_lb.dataProvider = [
{label:"Stijn", data:1},
{label:"Ivo", data:2},
{label:"Graham", data:3} ];

lb_listener = new Object();
lb_listener.change = function(evtObj){
trace(myListBox_lb.selectedItem.data);
}
myListBox_lb.addEventListener("change", lb_listener);
Re: load data from list LuigiL
7/22/2005 12:00:00 AM
And when you want to display the data in a textfield on the stage:
Add a (dynamic) textfield to the stage and give it an instance name of
myText_txt and replace the script in the layer actions with the attached script.



myListBox_lb.dataProvider = [
{label:"Stijn", data:"stijn@hotmail.com"},
{label:"Ivo", data:"ivo@hotmail.com"},
{label:"Graham", data:"graham@hotmail.com"} ];

lb_listener = new Object();
lb_listener.change = function(evtObj){
myText_txt.text=myListBox_lb.selectedItem.data;
}
myListBox_lb.addEventListener("change", lb_listener);
Re: load data from list stijn1989
7/22/2005 12:00:00 AM
OW MY GOD :o

thx a lot dudes ;) it works great :):)

thanks for al ur help, I found my answers :)

Re: load data from list LuigiL
7/22/2005 12:00:00 AM
AddThis Social Bookmark Button