Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Splitting An Array



Hello

I have a function that causes an array

i call it with this


ActionScript Code:
var tags:Array = thisPhoto.getTagsAsStrings();


i want to split it using this but it says it cannot because it is an array


ActionScript Code:
var platStr:String = tags[1];    var platSplit:Array = platStr.split(",");    var platLast:String = platSplit[platSplit.length-0];    trace(platLast);



ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 05-08-2007, 03:00 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Splitting An Array
I have three arrays (see the code bellow the message), and I'm trying to get all the possible combinations of elements. The resulting array is as follows:
1a*1a%1a#1b*1b%1b#1c*1c%1c#2a*2a%2a#2b*2b%2b#2c*2c %2c#3a*3a%3a#3b*3b%3b#3c*3c%3c#
I would like to be able to split it, such that at every iteration I get the result on a new line, and the result is saved in a variable:
1a*
1a%
1a#
1b*
.
.
.
and, var1=1a* etc.

I tried using var1=field_total[0]; ,but it's not working. Any thoughts? Below is the code.

Thanx,
Smash


field1=new Array("1","2","3");
field2=new Array("a","b","c");
field3=new Array("*","%","#");
field_total=new Array();


for(i=0;i<field1.length;i++)
{
for(j=0;j<field2.length;j++)
{
for(k=0;k<field3.length;k++)
{
field_total+=field1[i].concat(field2[j],field3[k]);
//field_total+=" ";
}}}
trace(field_total);
field_total.toString();
trace(field_total);

Splitting From An Array?
Hey gang,

I'm banging my head against the wall on this one. Here's the code that I have in place at the moment:

Quote:




bottomword = tossup[tosscount].split("");






(where the tosscount is a variable counter, and the tossup[x] is an array of words.)

Everytime I run the program, I check the variable table, and it states it as "undefined".

Can someone please point out the error I'm making, or a work-around? And can someone get me an ice=pak.. my head hurts!

Thanks in advance,
MrGameShow

Splitting Array
hi
I have a large array. Please could somone suggest some code to split the array into 3 parts.

BigArray contains element1 , element2, element3, element4...

LittleArray1 should contain element1, element4...

LittleArray2 should contain element2, element5...

LittleArray3 should contain element3, element6...

Thx allp help appeciated

Splitting An Array
Hi,

does anyone know how I can split an array to get the last character of every instance name in the array?

Splitting An Array Too Slow
I am trying to split the string from a database search into an array inside flash but on slower machines I am getting a message that the flash player is not responding and asking if you should quit the script. If the user quits the script the flash file just plays through ignoring all frame scripts and continues to cycle.

I am performing two seperate split operations - the first is to split the variable into its catagories then I split the catagories information (Array) into its components i.e.
ID, Name, Suburb.

This problem only exists on slow machines when the size of the returned variable contains > 40 items.

The site in question is: www,wlmw.net

I am probably not the first to have this proble so can any body suggest a solution.

Thanks ,
Matt

Splitting String Into An Array
Hi,

this should be incredibly easy: splitting a string into an array, where each character becomes an array element.

According to Flash help files it should work like this:


Code:
myString = "hello";
myArray = myString.split("");


ie. using an empty string as delimiter in the split function.

In practice however, this simply creates an array with a single element containing the complete string - ie. the same as when doing 'myString.split()'. Am I specifying the empty string incorrectly???

(I know how to do this 'by hand' - but want to know why the split method isn't working).

Any thoughts welcome,

thx - n.

Splitting Text Into An Array
In layer 1 I have the following code to pull the variable 'playerrank' from my ASP page:

myData = new LoadVars();
myData.onLoad = function() {
playerrank.text = this.playerrank;
};
myData.load("livedraftvar.asp");
stop();

In layer 2 I have the following code to split 'playerrank' into an array and enter each item into a list box:

var playerrankArray = new Array();
playerrankArray = playerrank.split(",");
for(i=0; i<8; i++) {
playerlist.addItem(playerrankArray[i]);
}

The list box comes up with 8 commas, that's it. If I put 'playerrank' into a dynamic text box, it comes up exactly how I want it. 102,204,209,308,489,518,555,698. Using playerrank.split(",") should put the eight elements into the array, then enter them into the list box. Why am I getting eight commas instead of the eight numbers. Thanks.

Splitting Strings Into An Array
Hi All,


I'm familiar that in flash, an array can be populated using such as a following:

var myArr = Array("cat","dog","bird");


Is there a way to populate an array if I get passed a string like this... (note the quotes placement):

"cat, dog, bird"

Some of you maybe familiar with VB's 'split' command which automatically turns that comma-delimited string into an array.

I need your help guys if there is a built-in function in flash that can do or mimic this or did I just missed an item in the help file?


Thanks in advance. Butch

Splitting An Array On Tab Character
Hello,
Quick one (hopefully):
I'm importing a text file into Flash with the format:
thinga;thingb;thingc
thingd;thinge;thingf
thinga;thingb;thingb etc.

Once I have the text in Flash I'm first using split('
') to split it into an array, and then using split(';') to convert each line into a sub-array. All works OK, but to get the text into the format thinga;thingb;thingc I'm having to convert my original Excel file to text via a very boring and slow process.

It would be a lot easier to use Excel to create a tab-separated text document, can anyone tell me how to split an array on the tab character instead of the colon as I'm doing at the moment? In other words is there a version of
for the tab key?

Ta,
Gravy.

Splitting A String To An Array
Hello there again..

I have a string "Something"
I want to separate this string to this;
arrayString[0]="S";
arrayString[1]="o";
arrayString[2]="m";
arrayString[3]="e";
arrayString[4]="t";
arrayString[5]="h";
arrayString[6]="i";
arrayString[7]="n";
arrayString[8]="g";

I tried to look for myString.split()..Did'nt work..
Can anyone help

Splitting Multiline Text Into Array
Hi. I want to separate a mutliline text field variable into an array so that each line is it's own string in the array. I used this code, but it doesn't work. Responses is the variable that has 5 elements separated by a return.

splitString=String.fromCharCode(13);
response_array = responses.split(splitString);
stop ();

I then used a dynamic text field to call the variable response_array[1]
And nothing showed up. What am I doing wrong?

Splitting A File Path Array?
Hi guys,

here's the deal.

I'm using flash and javascript to enable flash to call files directly from a computer's hard drive by opening the usual explorer window. When selected, Java passes the full file path to Flash and then flash does what it wants with the file.

Thing is, I'd like to display just the file names to the user instead of the complete paths.

My first thought was ARRAYS...but I can't use the backslash "" as a symbol to split the arrays.
Should I do this in Javascript first? If this is the best way, how do I do it? I'm a real beginner at Java and HTML.

Any and all help will be appreciated.

Intravenus.

Splitting Text And Checking It Against An Array
Hi,
I want to get flash to read a textbox and then check the text in it against an array. But its not that simple.
I want to split up the text as follows:

The text 'Hello World' would look like this:

H, e, l, l, o, , W, o, r, l, d, He, ll, o , wo, rl, d, Hel, lo , Wor, ld, Hell, o wo, rld, Hello, Worl, ,d, Hello , World, Hello W, orld, Hello wo, rld, Hello Wor, ld, Hello Worl, d, Hello World.

I want to do this so that I can check all the combinations of the text against the array. The array is called 'badWords'. How do I check the text (in the imput textbox: 'mytext') like this?

Regards,

Splitting Array Values Into A List Box
Hi

my problem is that i create an array consisting of external valuse. One of the array dimensions is made of xml element attributes which works dandy for all the later processing. But i am also trying to display each of the attributes on a list box for the user to see what is available.

this does work but atm says for example

wheels,steeringWheel,Brakes,Engine

instead of

Wheels
SteeringWheel
BRakes
Engine

this is the code

for (i = 0; i < myXML.childNodes.length; i++)
{
this[myXML.childNodes[i].nodeName] = new Object();
this[myXML.childNodes[i].nodeName].name = myXML.childNodes[i].nodeName;
this[myXML.childNodes[i].nodeName].isa = myXML.childNodes[i].attributes.isa;
this[myXML.childNodes[i].nodeName].has = myXML.childNodes[i].attributes.has.split(",");
parseArray.push(this[myXML.childNodes[i].nodeName]);
hasDisplay.addItem(myXML.childNodes[i].attributes.has.split(","));
} // end of for

where hasDisplay is the list box I dont really want to change the structure of the array because that is used later on and works fine just wondered if anyone knows how i could split the attribute values when it reaches a comma?

thanks.

Splitting An Array Into Multiple Variables
i know how to use arrays in a flash file but i'm not sure if i can split it into multiple from an input text box:



Code:
stop();
getcode = [_root.colorskin, _root.coloreyes, _root.colorwing, _root.eyes, _root.mouth];
function post() {
dragonarray = [postcode.text];
_root.thing = dragonarray.length;
trace(_root.thing);
}
when it traces the code it says 1

:/

is it possible to split the input box text up like an array?
and split the array up into multiple variables like this:
input box text: 26112,39423,13998489,3,3
_root.variable1= 26112
_root.variable2= 39423
etc
etc..

can somebody help please?

Splitting A String Into An Array Of Three Words?
Hi kids,
heres one - how would I go about splitting a string into an array of substrings based on every third space?

Basically, each element of the array will contain three words, or less for the last one.

Splitting Text Variable Into An Array
In layer 1 I have the following code to pull the variable 'playerrank' from my ASP page:

myData = new LoadVars();
myData.onLoad = function() {
playerrank.text = this.playerrank;
};
myData.load("livedraftvar.asp");
stop();

In layer 2 I have the following code to split 'playerrank' into an array and enter each item into a list box:

var playerrankArray = new Array();
playerrankArray = playerrank.split(",");
for(i=0; i<8; i++) {
playerlist.addItem(playerrankArray[i]);
}

The list box comes up with 8 commas, that's it. If I put 'playerrank' into a dynamic text box, it comes up exactly how I want it. 102,204,209,308,489,518,555,698. Using playerrank.split(",") should put the eight elements into the array, then enter them into the list box. Why am I getting eight commas instead of the eight numbers. Thanks.

Simple Splitting Values From A Txt File Into An Array Question...
I've got a simple txt file:

friends=tom9dick9harry9bob

and using this code to load that and split it into an array:
code:
myVar=new LoadVars(this);
myVar.load("friends.txt");
myVar.onLoad = function(success){
if(success){
myArray = new Array(this)
myArray = myVar.friends.split("9");
}
}now that works fine but I'd like to make the txt file a little easier on the eye so it looks like this:

friends=tom
dick
harry
bob

but now I'm stumped, what do you replace the "9" with in the split function, do you need some funky ascii code or something for a new line/carriage return?

sure this is simple to do for someone who knows.

Splitting External Vars To Be Loaded Into An Array Of Objects
This part loads the vars that I have in my getLinks.txt file.

ActionScript Code:
TempLinkLoadVars = new LoadVars();TempLinkLoadVars.load("getLinks.txt");TempLinkLoadVars.onLoad = function() {    gLinksArray = this.tempLinks.split("|");    trace(gLinksArray);};

it works very nicely, but i want to combine both of the sections of code to load my vars into an object that is located in an array.

----

this actionscript has objects declared and defined and applied to my allLinks array so I can manipulate them.

ActionScript Code:
function Link(linkTitle, linkUrl, linkCategory, linkDescription) {    this.linkTitle = linkTitle;    this.linkUrl = linkUrl;    this.linkCategory = linkCategory;    this.linkDescription = linkDescription;}allLinks = [];allLinks.push(new Link("Google", "http://www.google.com", "Search", "Great Search Engine"));allLinks.push(new Link("Yahoo", "http://www.yahoo.com", "Portal", "Advertisement Central"));allLinks.push(new Link("Ask Jeeves", "http://www.aj.com", "Search", "Decent Search Engine"));allLinks.push(new Link("Boundless-Vision", "http://www.boundless-vision.com", "Personal", "My personal website"));allLinks.push(new Link("Kirupa", "http://www.kirupa.com", "Tutorial", "Great Tutorial Site"));trace("Original data:");for (i=0; i<allLinks.length; i++) {    trace(i+" "+allLinks[i].linkTitle+" "+allLinks[i].linkUrl+" "+allLinks[i].linkCategory+" "+allLinks[i].linkDescription);}allLinks.sortOn("linkUrl");trace("
After sort on linkUrl:");for (i=0; i<allLinks.length; i++) {    trace(i+" "+allLinks[i].linkTitle+" "+allLinks[i].linkUrl+" "+allLinks[i].linkCategory+" "+allLinks[i].linkDescription);}
----

Example of what I would like to accomplish ...
where "&" denotes the beginning and end of file.
where "|" denotes paramaters of each object.
where "," denotes the next object of the array eg, link2.

VARS.txt - &link1=link1_title|link1_url|link1_category|link1_ description,link2=link2_title|link2_url|etc....&

or something very similar.
Not quite sure if those are the best var 'splitters' or not.

I have not been able to pin this script down... it's just out of my reach..
Might be having a bad day....

Thanks For the help!

Splitting External Vars To Be Loaded Into An Array Of Objects
This part loads the vars that I have in my getLinks.txt file.

ActionScript Code:
TempLinkLoadVars = new LoadVars();TempLinkLoadVars.load("getLinks.txt");TempLinkLoadVars.onLoad = function() {    gLinksArray = this.tempLinks.split("|");    trace(gLinksArray);};

it works very nicely, but i want to combine both of the sections of code to load my vars into an object that is located in an array.

----

this actionscript has objects declared and defined and applied to my allLinks array so I can manipulate them.

ActionScript Code:
function Link(linkTitle, linkUrl, linkCategory, linkDescription) {    this.linkTitle = linkTitle;    this.linkUrl = linkUrl;    this.linkCategory = linkCategory;    this.linkDescription = linkDescription;}allLinks = [];allLinks.push(new Link("Google", "http://www.google.com", "Search", "Great Search Engine"));allLinks.push(new Link("Yahoo", "http://www.yahoo.com", "Portal", "Advertisement Central"));allLinks.push(new Link("Ask Jeeves", "http://www.aj.com", "Search", "Decent Search Engine"));allLinks.push(new Link("Boundless-Vision", "http://www.boundless-vision.com", "Personal", "My personal website"));allLinks.push(new Link("Kirupa", "http://www.kirupa.com", "Tutorial", "Great Tutorial Site"));trace("Original data:");for (i=0; i<allLinks.length; i++) {    trace(i+" "+allLinks[i].linkTitle+" "+allLinks[i].linkUrl+" "+allLinks[i].linkCategory+" "+allLinks[i].linkDescription);}allLinks.sortOn("linkUrl");trace("
After sort on linkUrl:");for (i=0; i<allLinks.length; i++) {    trace(i+" "+allLinks[i].linkTitle+" "+allLinks[i].linkUrl+" "+allLinks[i].linkCategory+" "+allLinks[i].linkDescription);}
----

Example of what I would like to accomplish ...
where "&" denotes the beginning and end of file.
where "|" denotes paramaters of each object.
where "," denotes the next object of the array eg, link2.

VARS.txt - &link1=link1_title|link1_url|link1_category|link1_ description,link2=link2_title|link2_url|etc....&

or something very similar.
Not quite sure if those are the best var 'splitters' or not.

I have not been able to pin this script down... it's just out of my reach..
Might be having a bad day....

Thanks For the help!

Splitting Xml
I understand that you can get xml values like title or description or whatever and that it puts all that information into an array. How would I then split that or call it individually? Let's say I have 100 items in my "title"...I can trace out the title but all the 100 values are all appended together. How do I get each individual value?

Splitting A URL Up. Need Some Help
Hi all,

need a bit of help on splitting a url

i got a url like this.


http://www.mysite.com/company/compDo...r1/campaign/2/


I need to get the Number 2 out of the string. But the number 2 could be
any number of digits. Most likely from 1 to 9999 but I can't just count the number of chars from the end of the string, Campaign will always be there right in front of it. CAn i use split("campaign/") as the criteria?

THANKS
mcm

Splitting Strings
I am able to give a dynamic text box a name of bookmark, and also see the correct numbers when I run my movie (reads as 0.0.1). I want to split this string up so that I am able to read the three different numbers separately, and then be able to do an if then statement to send the user to the right page? I think string splitting is what needs to happen, but I have failed in the implementation. Any help would greatly be appreciated! Thanks!

Splitting Strings
Yo people hows tricks?

I;m trying to split up a string into an array. Each element of the array is seperated by a comma. Up until now I've been using a loop to do it which works fine, but I believe there is a single command that will do it for me. So do you know it?

Cheers
Mark

Splitting With Actionscript.
Hello fellow scripters

As i know from php you can split lines e.g. hi:bye
How does this work with flash?

let's say my variable is greetings so:
greetings = "hi:bye";

how do I split these two so that field greetings1 says hi and field greetings2 says bye?

thanks in advance,

rob

Splitting Up A Input Box
I am splitting up a string but what happens is it doesnt split it up so how do i place delimiters in between each letter so that it will be able to split it up here is my code

[code]
on (release) {
myInputText = "This is a string";
txtArray = myInputText.split("");
ltr_1.ltr1 = txtArray[0];
}

Splitting Arrays?
can i take an array say with 8 numbers and then split it up into variables like this:

randArray = [5, 27 , 34, 21, 7, 16, 77, 32]

and make each one of those numbers go to one of these variables:

card1 =
card2 =
card3 =
card4 =
card5 =
card6 =
card7 =
card8 =

please advise

thanks

yechiel

Splitting Up A Number
For example, x equals a two digit number; how do I split up the number into two numbers?

x = 21;
firstNumber = 2;
secondNumber = 1;

21 represents any number between 10 and 99. Thanks for any help you can provide.

gamist

Splitting A String?
Hi,

I have a string like this:

a = "value1^value2^value3^value4^etc.etc";

And i want to split this string into

b = "value1";
c = "value2";
etc.

Is there any other way then the way I'am trying to do it now as the string contains quite some values seperated by the "^".

this is what I am using:

b3 = a.indexof("^");
b2 = a.charAt(b3);
b = a.substr(0,b3);
trace(b);

and so on and on. Any easier (faster) method here?

Thanks,

Vincent

Splitting A String
hi,

i have a variable string that goes something like this:

" hello charles - how are you this morning"

i would like to split this at the "-" so "hello charles" goes to one variable, and "how are you this morning" goes to another

tnx

Splitting Arrays
Hi there

I am loading a list of choices into flash combo boxes from an asp file.
What I need to do is to split each entry at the symbol #, but within each entry, I need to again split each entry at the symbol %, then display only the content after the %, but be able to assign the content before the % symbol as being the variable.

Basically, the output looks like this:
entry1clickhereforresults%entry 1#entry2clickhereforresults%entry2#
and so on...
I need to be able to display "entry 1", "entry 2" etc. in the combo box, but when clicked on, I need the selection to be called "entry1clickhereforresults" etc...

I am able to populate and use a combobox when I don't need this extra step, but I am not sure how to split the entries and only display the part after the %, while still remembering the part before the % to assign as a variable...

Hopefully that all makes a little sense and someone can point me in the right direction...

thanks a lot

Splitting Textfield Var And Using Later
Harro all-

I am attempting to get a number from the user, then later dynamically add in the number into a clip. For those without flash, here's the code:
code: for (i=0; i<=3; i++) {
newName = "chosenNum"+i;
_root.attachMovie("chosenNum", newName, 10);
with (newName) {
newName._x = Stage.width/i;
newName._y = Stage.height/2;
}
_root[newName].textbox.text = _root.choice.split(charAt(i).join(charAt(i)));
}

For those with, the fla is attached. T'anks!

Splitting Strings
hi.

i have 10 sentences i am importing into flash from xml. here is a sample:
code:
my frog has four legs!

i parse it and place it in a variable c.

what i really want is the punctuation put into its own array. i strip c like this:
code:
var strings = c.split(" ");

and of course that places every character into the array and the last character is "legs!".

for other purposes i need to split it in every character but how can i now separate the punctuation (in order) so i can recall it later.

thanks. fumeng.

Splitting Text
How can I split the text I have in an inut textbox into separate letters and check this against an array.
eg. 'Hello world', would come out as, h,e,l,l,o, ,w,o,r,l,d. and each of these separate things would be checked against an array.

I can do the rest, so just please give me some kind of if statment or somthing to put my code in if one of the letters equals somthing in the array.

Regards,

Splitting Text
How do I split text into individual letters and add these letters to an array?

Thanks for any help,

Splitting Up Text
This AS2 script splits ups an input textfield value into individual letters. So if the user types in "CAT" this script will split the word into individual letter varables. eg: "C" "A" "T".

Can someone help me out with this script so that it works in AS1


This is the code on a button.

on(Release){
for(x=0;x < myText.length;x++){
var word:String = myText.text;
_root["myLetter"+x] = word.charAt(x);
}
}

myText is the instance of the input textfield
I called the variables (for individual letters) : root.myLetter0, _root.myLetter1, _root.myLetter2 and so on

Splitting Text
I'm trying to split text in a much more efficient way then I am currently doing. I load external text from a db through php. My display page offers a thumbnail embedded in the layout so I'm using 2 text boxes. textnews_details_1 & textnews_details_2.

My code seperates the content after 400 characters right now and looks for a new word so it doesn't cut just at the characters. I've been learning on these boards that I can count exactly where the text ends based on the number of lines and then put the rest of the text in my second text box. I've messed around for a few days and am more confused now then when I started. I know that my first text box holds ten lines and then me second is set to autosize and my scrollbar wil kick in if needed. I'd love to more efficiently separate the text.

Any help would be great!!

Here is my current code.

PHP Code:



// loads the image into place
news_img.loadMovie(_level10.details_img);
// number of characters to split the text
fill = 400;
if (_level10.details_desc.length>400) {
    news_details_1 = _level10.details_desc.substring(0, Number(_level10.details_desc.lastIndexOf(" ", fill)));
    news_details_2 = _level10.details_desc.substring(Number(_level10.details_desc.lastIndexOf(" ", fill)+1));
} else {
    news_details_1 = _level10.details_desc;
}
textnews_details_2.autoSize = true;
textnews_details_2.wordWrap = true;

Splitting Variable
ok, well I have a variable which contains: "square14". is there a way to get only the number at the end in another variable?

Splitting External Value
I´m trying to split an external value into array, but it just doesn´t work. Movie can read values both from textfile and php-generated text, but the split function just doens´t work.
Code:
&values=1,2,3,4,5,6

Code:
var table:Array = values.split(",");

Splitting Up Strings
Hi Guys,

Just a quick question and thanks to everyone who replied to my last post.

If I use this code:

var word:String = "this";
var aLetters:Array = word.split("");

Does this mean I refer to each letter as aLetters[0], aLetters[1], aLetters[2] and aLetters[3] ???

How do I refer to the letters 't' 'h' 'i' 's' as a group? ie 't' or 'h' or 'i' or 's'???

Cheers for any help

M

Splitting A String ...
Hi, can I split the string "0102030405..." (of unknown length) into the array [01, 02, 03, 04, 05, ...]?

Splitting Up A String.
How would i split up a string into a single array using split?

such as

string = "Hello World!";
array = string.split("");
trace(array[5]);

what would i put between the split(""); quote marks to make it include each character please?

Thanks

Splitting A String
in AS2:


ActionScript Code:
var str:String = "string";
var arr:Array=str.split("");
trace(arr); // outputs s,t,r,i,n,g

simply i want to split a string like this in AS3 but the code dont works. the split() method has a little changed.

how can i split a string like above in AS3?

thanks for any help

Splitting Strings
Hi there,

I'm having a big issue getting a string to split into two pieces, and I can't for the life of me work out why. This is a function that is run, with the midText var, being a number between 0-100, spat out from a loader. I've traced it, and it seems fine, but my splitter function just wont work!

The function works fine if you simple define a var in the code


ActionScript Code:
function splitter(){    midText.toString();    firstSpot = midText.slice(0,1);    secondSpot = midText.slice(1,2);}


I basically just need to get the percent loaded split into 2 seperate text fields

Anyone ?

Splitting Up A Map Into Different Sections?
Hi all,

I heard there was a way in flash 8 to easily and accurately split an image up into different sections?? Ex. Splitting a map up into different countries.
I've tried searching for ways to do this on the site but obviously amn't entering the correct search criteria!! Could someone please tell me how to do this or give me a link to show me?

Tanx a mil guys,
Derms

Splitting A String ..
Hi, can I split the string "0102030405..." (of unknown length) into the array [01, 02, 03, 04, 05, ...]? The string could also be "0100000504..." etc.

Splitting A URL String
I have the following url that I am capturing in Flash. http://localhost:47/images/imageMap....type=rs&efr=97. I need to capture the number from data(16 in this case) and can't quite figure it out. If I do a split on '=' it gives me 16&type, I just need the 16. The url will change and so will the number of digits for the data number.

Thanks!

Check On Splitting Arrays
Hi,

I've been getting headaches lately of this specific problem;

I am creating a dynamic menu that is build up completely from an external variable file.

My swf file loads perfectly fine on my machine. However, once uploaded, it either loads the first time, but doesn't load when refreshing the page, or it doesn't load at all.

I think I know where the problem lies, either in the amount of time it takes to parse and process the variables loaded from the textfile, or in teh creation of the actual buttons. But, I am at a loss of how to tackle this issue.

All in all, despite the lenghty code below, my question is quite simple... what is the best way to make sure that the menu is only shown when everything is loaded? In other words, how can I put in a check to make sure the menu is shown?


So, what is happening in my file?

First of all, I load the following on frame 1:

Code:
MyVars = new LoadVars();
MyVars.load("menu_text.php");
on frame 3, called "splitter", I create the arrays from the variables loaded:

Code:
// to determine the number of mainbuttons
var menucount = MyVars.menucount;
// to determine the number of mainbuttons
var submenucount = MyVars.submenucount;

// MAIN BUTTONS ARRAY
MainButtons_Array = new Array();
MainButtons_Array = MyVars.mainbuttons.split('|');
count_mainbuttons = MainButtons_Array.length;
_root.loadcounter=0;

// SUBMENU ARRAY
for (z=0; z<_root.menucount; ) {
this["submenu"+z+"_array"] = new Array();
this["submenu"+z+"_array"] = MyVars["submenu"+z].split('|');
z++;
}
_root.loadcounter=1;

// MAIN_LINKS ARRAY
Main_Links_Array = new Array();
Main_Links_Array = MyVars.main_links.split('|');
count_links = Main_Links_Array.length;
_root.loadcounter=2;

// MAIN BUTTON TARGETS
main_links_target = new Array();
main_links_target = MyVars.main_links_target.split('|');
count_mlinks_target = main_links_target.length;
_root.loadcounter=3;

// SUB_LINKS ARRAY
for (sm=0; sm<_root.submenucount; ) {
templinks = "submenu_links"+sm+"_array";
this["submenu_links"+sm] = new Array();
this["submenu_links"+sm] = MyVars["submenu_links"+sm].split('|');
sm++;
}
_root.loadcounter=4;

// SUB_LINKS_TARGETS ARRAY
for (tm=0; tm<_root.submenucount; ) {
targetlinks = "submenu_links_target"+tm+"_array";
this["submenu_target"+tm] = new Array();
this["submenu_target"+tm] = MyVars["submenu_target"+tm].split('|');
tm++;
}
_root.loadcounter=5;
On frame 8 I put in a check as follows:

Code:
if(_root.loadcounter==5) { gotoAndPlay("create_buttons"); }
else {
gotoAndPlay("splitter"); }
On frame 10, called "create_buttons", I duplicate and position the buttons according to the arrays created earlier:

Code:
// DUPLICATE MAINBUTTONS
for (i=0; i<_root.menucount; ) {
duplicateMovieClip(_root.buttonholder, "mainbutton"+i, i+200);
_root["mainbutton"+i].title.html = true;
_root["mainbutton"+i].title.HTMLtext = MainButtons_Array[i];

//POSITION TEH MAIN BUTTONS
new_h= getProperty(_root["mainbutton"+i],_height);
ButtonY = ButtonY+new_h;
_root["mainbutton"+i]._y = ButtonY;
_root["y_pos"+i] = ButtonY;
Last but not least, on frame 12 I duplicate and position the submenubuttons:

Code:
// FUNCTION DUPLICATE SUBMENUBUTTONS
function addsubmenus(waarde) {
count_submenu = _root["submenu"+waarde+"_array"].length;
for (t=0; t<count_submenu; ) {
_root.dieptepunt = _root.dieptepunt;
s_t = ""+s+t;
duplicateMovieClip(_root.submenu, "subbutton"+s_t, _root.dieptepunt);
_root["subbutton"+t].sub_title.html = true;
subarray = _root["submenu"+s+"_array"];
_root["subbutton"+s_t].sub_title.HTMLtext = subarray[t];
ButtonY = ButtonY+20;
_root["subbutton"+s_t]._y = ButtonY;
msbut1 = _root["subbutton"+s_t];
msbut2 = msbut1+".m_clicked_small";
setProperty(msbut2, _visible, 0);

setProperty(_root["subbutton"+s_t], _visible, "0");
t++;
_root.dieptepunt++;
}
}
// ACTUAL SUBMENU DUPLICATION
for (s=0; s<_root.submenucount; ) {
["submenu"+s+"_array"]);
addsubmenus(s);
s++;
}
_root.loadcounter=6;
I know it's a lenght of actionscript here... but I thought to show you all of it, so you know exactly what I am doing.

I hope someone can help me out with this, because despite all my efforts in creating this menu, it's useless if it isn't loading properly.

Thx in advance.

With kind regards,

RF

Splitting One Variable Into Pieces
Is there a method to split one variable into different variables?

Ex: I have a text input field with variable "text" when I type for example "this ;should ;be ;split" I want the 4 words to be assigned to variables 1, 2, 3 and 4...
so that the ; is the point where it splits, can be any carracter, best would be the space.

It realy needs to come from ONE variable since this SWF will be controlled by an external app that can only take one variable...

Thanks a lot

Copyright © 2005-08 www.BigResource.com, All rights reserved