PDA

View Full Version : How to use listBox component


Skinner
10-21-2003, 12:56 AM
Hi just wanna shared this out. Some basic stuffs i had regarding saving and loading text.txt from a Floopy Drive.

Keyframe 1:
stop();
loadVariablesNum ("file:///A|/TextField.txt",0);
Selection.getFocus ("TextField"); // where TextField is the var

Button :
on(release){
fscommand ( "save", "A:\\TextField.txt" );
}

But Problem is:
*How can i prompt a message when it is done saving or floopy is not inserted ? Pls guide me heheh.

Skinner
05-08-2004, 12:47 AM
Hi people,

Just wondering since Flash MX and 2004 cant support this fscommand 'save'...is there anyway way i can pass an argument to xml so i can save or load a .txt file from there?


Appreciate.

Skinner

CyanBlue
06-01-2004, 09:52 AM
Howdy... :)

I don't think you can pass an argument from the Flash anymore... So, you cannot really use fscommand save to save data anymore unless you are working on F5...

Read this page for more information...
http://www.northcode.com/links/mxproject.html

The best way to do it would be using the server side script, but if that's not your option, IE only solution can be found here...
http://www.actionscript.org/forums/showthread.php3?t=44092

Skinner
06-01-2004, 12:13 PM
Hey man thanks for the reply...very appreciate ;)
and it will be perfect and solve everyone problems if that IE server side script can be work in Projectors (.exe). :D

Anyway i got some minor problems with listBox in MX.

I have this actually it creates .swf into it but wanted it to create .txt


listArray = new Array ();
for (i=1; i<=0; i++) {
listArray.push ({label:"Slides" + i, data:"Slides" + i + ".txt"});
}

this.attachMovie ("FListBoxSymbol", "newSlides", 18, {_x:18, _y:482});
this.newSlides.setSize (280,100);
this.newSlides.setDataProvider (listArray);
this.newSlides.setChangeHandler ("loadTXT");

function loadTXT (component) {
loadVariablesNum (component.getValue(), 0);
}


Question is i wanted it to load .txt instead of .swf
and label were based on the txt file name.

Edit: OK i figured out half of it just have the problem for the listArray to push it.

CyanBlue
06-01-2004, 03:46 PM
Half way done, then, right??? :D

Skinner
06-02-2004, 03:05 AM
hey man dang im stuck at the listArray


listArray = new Array ();
for (i=1; i<=0; i++) {
listArray.push ({label:"Slides" + i, data:"Slides" + i + ".txt"});
}


How can i abstart the <filename>.txt filename and place into the listbox label? yet there will be more than 1 <filename>.txt with each different filename.

i have this but no idea how to continue on using LoadVars(); or perhaps u have better solution ?


loadUser = new LoadVars();
loadUser.load ("user.txt");


Cheers

CyanBlue
06-02-2004, 08:47 AM
Um... Can you post some workable sample???

Skinner
06-02-2004, 09:24 AM
ops ok here you go the file...thank you.

the listBox located in keyframe 2 which i use the attachClip.

Edit: One.txt, Two.txt, & Three.txt is to be load into it and One, Two, & Three happens to be the name of the listbox label.

CyanBlue
06-02-2004, 09:53 AM
Um... I am not fully getting it... What about this one???
(I was focusing on the listbox issue not the actual saving part...)

Let me know if it is actually going somewhere... :)

Skinner
06-02-2004, 10:05 AM
getting into it but not quite right....

The listbox label should be the filename of <filename>.txt
e.g Skinner.txt, CyanBlue.txt, or Jesse.txt and so on containing each individual respectively like this
Skinner
CyanBlue
Jesse
One
.
.
n

note the <filename>.txt will be different instead of building it up using i++ not asd1.txt -asdn.txt. Why? coz when save the <filename> will base on the user keyin name.

CyanBlue
06-02-2004, 10:13 AM
Um, what about now???

Skinner
06-02-2004, 10:22 AM
You are there but one more problem bout using the array there. Sorry for the troubles let me explain how the entire things work

Within this Login form user will able to save their profiles into .txt meaning in future will creating more than 10 or more users of <filename>.txt which will be save into local disk drive.

So the listbox functionality is to load this .txt out and the listbox label will display each <filename> of <filename>.txt. So by putting limited arrays is not really a good idea.

How can i read these filename unlimited and display it as a label in the listbox?

CyanBlue
06-02-2004, 10:35 AM
Okay... The key is that YOU have to have some sort of routine that will store the names... It doesn't matter where it is, but you have to have one...

This will be how to do that by loading a data from the text file... You can do that via Shared Object or dump in the variable if it can be temporary...

Skinner
06-02-2004, 10:43 AM
ahh thats cool...so meaning whenever i create a new user i somehow have to save a name into the list.txt ? aint it goin to overwrite it?

thanks for the help ;)

CyanBlue
06-02-2004, 10:57 AM
Well... Whether you overwrite it or append to it, you do need to keep the list of the names so that you can use it later on... :)

Skinner
06-02-2004, 10:59 AM
yeah man is like double the work now hahahaha coz i cant overwrite it else it will end up only 1 user exist in the list.txt....heheh

CyanBlue
06-02-2004, 11:02 AM
Um... Really??? That's a bummer... :(

Skinner
06-02-2004, 11:05 AM
really dunno why it can save based on the name but cant load based on the <filename> guess i have to take a couple of coffees and catch the midnight express.... :(

CyanBlue
06-02-2004, 11:10 AM
Here is a dumb version of the question... Where is the routine that actually saves data??? I can't find it...

Skinner
06-02-2004, 11:14 AM
i have the save function in flash 5 but still doin research on it that can be work on MX version without using third party tools like screenweever, or on.
So i was thinkin trying to write this user info into XML maybe later if i can figure it out.

coz i believe most of the ppl out there are tryin to scratch their head for this to workout without using IE or any third party tools.

Skinner
06-02-2004, 11:24 AM
sorry how do fit in when user select a name in the list and hit 'Ok' ?

CyanBlue
06-02-2004, 11:47 AM
Um... Can I ask WHY you don't want to use third party projector tool for it???

Skinner
06-02-2004, 11:50 AM
coz i do not have time to do research on it my time all pack
and i have to submit this login form in short period of time.
i see screenweezer can do this but if i used it i need money to get the s/w.

and im still thinkin how to do this ?
sorry how do fit in when user select a name in the list and hit 'Ok' ?

CyanBlue
06-02-2004, 11:57 AM
Um... I think you are trying to waste your time on something that's really really hard to achieve, no offence though... If you can achieve something with reasonable amount of money, you should really go for it because that will save you time... But then, it is the matter of time vs money... I'll leave it up to you but I can't help you with that cuz I don't know how to achieve it...

As for the question... What do you mean by 'fit'??? I don't understand...

Skinner
06-02-2004, 12:00 PM
sorry i mean how to do it ?
How can i select the name from the listbox and hit ok to proceed ?
if there's nuthin selected prompt a msg.

CyanBlue
06-02-2004, 12:08 PM
Um... If you select Skinner from the list, it will show you something in the output window, right??? That's when loadTxt function gets executed... Use the same function... If you want it to be executed only when the button is pressed, then you can add a routine there where you only set the selected item within the loadTxt function and run the loadVars() stuff if the selected item is not null... Know what I mean???

I think it's going more toward to the generic use of the listBox component... I think you should really look up the Flash manual for the use of the functions... I am going to move this thread to the FMX/Component forum soon...

Skinner
06-02-2004, 12:10 PM
alright will try it out now...perhaps u wnana change this title coz
i see this multiple load txt is quite usefull for the rest as well.

CyanBlue
06-02-2004, 12:14 PM
Yup... It's not that I don't want to help, but this has been dealt with alot before, so I think you should really look for the use of the functions of the listBox component to help you better... :)

I am sure somebody else could be able to use this... What do you suggest for the topic??? Tell me what it is going to be and I am going to change it and move to the component forum...

Skinner
06-02-2004, 12:19 PM
frankly im not really expect in AS but i never give up but it really takes hrs for me to figure it out where to put in the codin in order to make it work. shame on me :(



bout the title up to u wat suit best ;)

Edit: crap i confused...actually the 'OK' button is to verified to that particular user...select Skinner then click 'OK' then proceed


Btn_Ok.onRelease = function () {
if (<statement is selected true>) {
trace ("Proceed to main");
else (<statement is not selected>) {
trace ("Select user");
}
}

CyanBlue
06-02-2004, 12:37 PM
Um... The way I see it, the people does better when I don't give out the whole code because that way they understand things better... It might take some additional time to go over the hill, but they normally get to the point where they should be... Nothing is easy... Do it step by step... That's how things are done... :)

Skinner
06-02-2004, 12:58 PM
dohhh....im lost @_@ samples samples directions directions

Edit: man i give up sitting down putting here and there...will you review it ? :confused:

CyanBlue
06-02-2004, 02:13 PM
Um... If you give up, who's going to do the work??? Get up and return to your post!!!

This would be the script for the frame 2...stop();

// Title
txt_Title = "Login - Local Disk Drive";

errorMsg = "Confirm file overwrite. \nCreate new profile will overwrite previous profile. Are you sure you want to overwrite previous profile?";

Btn_Cancel.onRelease = function () {
gotoAndStop(1);
newSlides.removeMovieClip ();
}

Btn_newUser.onRelease = function () {
gotoAndStop(4);
newSlides.removeMovieClip ();
}

Btn_ok.onRelease = function ()
{
trace(selected);
if (selected != "")
{
//loadVariablesNum (component.getValue(), 0);
data_lv = new LoadVars();
data_lv.onLoad = function (ok)
{
if (ok)
{
trace("txt_userID = " + this.txt_userID);
trace("txt_name = " + this.txt_name);
}
}
data_lv.load(selected);
}
else
{
trace("Select the item from the list!!!");
}
}

// Create slides
//*

init_lv = new LoadVars();
init_lv.onLoad = function (ok)
{
if (ok)
{
trace("txt_userID = " + this.txt_userID);
trace("txt_name = " + this.txt_name);
trace(this.list);
name_arr = this.list.split("|");
listArray = new Array()
for (i = 0 ; i < name_arr.length ; i++) {
// listArray.push ({label:"asd" + i, data:"asd" + i+ ".txt"});
listArray.push ({label:name_arr[i], data:name_arr[i] + ".txt"});
}
trace("name_arr = " + name_arr);
createListBox();
}
}
init_lv.load("list.txt");

//*/

function createListBox()
{
// Create list box
selected = "";
this.attachMovie("FListBoxSymbol", "newSlides", 18, {_x:240, _y:292});
this.newSlides.setSize(320, 80);
this.newSlides.setDataProvider(listArray);
this.newSlides.setChangeHandler("loadTXT");
}

function loadTXT(component)
{
selected = component.getValue();
trace(selected);
}

Skinner
06-02-2004, 02:21 PM
thanks man i think i need to brush up my flash AS...and sorry for the troubles.
and last question wont the two different function crash when both have the same value of function (ok) in it ?

Edit: i will return u a favor if u have any problem with designs ;) or logos ;)
Again thank you for the help.

Skinner
06-02-2004, 02:45 PM
why is this msg not appearing ?
trace("Select the item from the list!!!");


output when nuthin selected

undefined
Error opening URL "file:///C|/"

CyanBlue
06-02-2004, 03:51 PM
It works when I try it... I don't know why you are getting that message... Maybe add this line within if (ok) routine...

selected = "";

Skinner
06-03-2004, 11:01 AM
ahh shooo...my mistake i left out the select="" in the createlistbox function ...
heheheh sorry

Skinner
06-14-2004, 03:28 PM
hey CB,

1. Why is it listbox doesnt work inside a movie clip ?
2. and why is a dynamic text not work as well in a movie clip ?

Attach is a sample i did.

Cheers