Announcement

User registrations are currently disabled due to high spam traffic.

#1 09/05/08 5:51pm

Zuriki
Flash Dev (The Lazy One)
From: Manchester
Registered: 18/01/08
Posts: 755
Website

[Question] Strings

Ok so using Jake's Save/Load feature it will save/load as a variable.

Now I need to convert that to a string that will divide (Much like Teleport's external text level loader thingy xD).

Anyway say I am saving some text in separate categories all as one string for simplicity.

Might read out:

Code:

#cat1=123,abc#cat2=456,def

Ok first off I want to now take the values out of those and put them into text boxes.

IE. _root.cat1 = 123,abc

Ok. Now I was thinking of using an exsisting code that I have which loads external text files. Then interlink it with Jake's save/load thing but modifiy to select the various variables.

(A little help on this thanks)

Ok all that stuff aside I now want to change the string to read;

Code:

#cat1=789,xyz#cat2=456,def

I changed cat1! But how to make sure that it doesn't add it to the end like:

Code:

#cat1=123,abc#cat2=456,def#cat1=789,xyz

???

I really don't know how to do this at all.


[img]http://img134.imageshack.us/img134/9129/headerxt2.png[/img]
[url=http://zuriki.co.nr/project/traveller/][img]http://i28.tinypic.com/2vspafo.png[/img][/url]
[url=http://zuriki.co.nr]Zuriki - PSP Flash Games[/url]

Offline

 

#2 10/05/08 5:46pm

Zuriki
Flash Dev (The Lazy One)
From: Manchester
Registered: 18/01/08
Posts: 755
Website

Re: [Question] Strings

HELP PLEASE!!!!


[img]http://img134.imageshack.us/img134/9129/headerxt2.png[/img]
[url=http://zuriki.co.nr/project/traveller/][img]http://i28.tinypic.com/2vspafo.png[/img][/url]
[url=http://zuriki.co.nr]Zuriki - PSP Flash Games[/url]

Offline

 

#3 10/05/08 6:53pm

Jake
Administrator
Registered: 29/04/06
Posts: 307

Re: [Question] Strings

In teleports levels there are variables such as
&lev1=303,303,303,303,.......

This in flash will load the variable "lev1" which will be equal to 303,303,303,303,.......

In flash this is then split up in to the separate variables. For this the code reading the data needs to know which variable is which.

An example showing this would be:

Code:

var dataload:LoadVars = new LoadVars();
dataload.onLoad = function(success:Boolean) {
    if (success)
    {
     // mydata is a string variable loaded from the text file data.txt
     // mydata is comma seperated this can be any string
     data_array=dataload.mydata.split(",");
     // 
     x=data_array[0];
     y=data_array[1];
     trace("x is "+x);
     trace("y is "+y);
    }
    else
    {
     // Handle the error
    }
};
dataload.load("data.txt");

Download example fla

Alternatively you could just load them as separate variables and use an & symbol before each one so flash knows it is a new variable.


moose

Offline

 

#4 10/05/08 10:37pm

Zuriki
Flash Dev (The Lazy One)
From: Manchester
Registered: 18/01/08
Posts: 755
Website

Re: [Question] Strings

I will look into this further tomorrow.

my main concern was being code effective when splitting up the variables as well.


[img]http://img134.imageshack.us/img134/9129/headerxt2.png[/img]
[url=http://zuriki.co.nr/project/traveller/][img]http://i28.tinypic.com/2vspafo.png[/img][/url]
[url=http://zuriki.co.nr]Zuriki - PSP Flash Games[/url]

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson