-
Currently i am passing a variable with all the elements seperated by commas then using the .split(",") function this is dont for Six variables as you can imagin this can slow the player down considerably even though each var is split up into an array on six different frames.
Tha Question
Is it possible to pass an array directly from PERL to flash so i dont have to do the split to make it an array within flash?
Thanks in advance!
Danny
-
Hi Danny,
simply: NO
you will have to live with either a faster replacement split or passing individual variables (text1, text2, ... text6) and making them into an array in flash - which is not _that_ fast either.
Probably the best way would be to use the replacement split and then hand-optimize the code with flash assembler; it is a bit of work as well
Musicman
-
Hi Musicman!, to the rescue again!
"use the replacement split" - That im doing now (.split(",")
"and then hand-optimize the code with flash assembler;"
That bit i dont follow, i split it then use it?? Please explain
Thanks!
Danny
-
Hi Danny,
there is some "mysplit" function circulating in this forum - I was just reposting it recently, credits go to whoever wrote it in the first place.
Basically it is
String.prototype.mysplit = function(ch)
{ // some code here
}
at the beginning of your file
and then replacing all calls to split() by calls to mysplit() - it will be a lot faster
The other thing: there was a discussion recently about replacing the "relatively high level" action script by AS byte codes. This would mean you create (or ask someone to create) the split function as a loadable swf movie with only code and call that code rather than the builtin split() or that faster mysplit()
For source code please search for mysplit - for a discussion of flash assembler search openswf forum; keyword might be flasm or flash assembler.
I was faced with a similar problem (splitting things) and I came up with a solution where x things are split per frame (if not done, go back one frame) and I could at least double that "x" by using the other split code
Musicman
-
the code you was talking about
String.prototype.mysplit = function(ch)
{ var k, s, l = this.length;
var res = new Array();
for(k = s = 1 ; k <= l ; k++)
{ if(substring(this,k,1) == ch)
{ res.push(substring(this, s, k-s));
s = k+1;
}
}
if(s <= l)
res.push(substring(this, s, l-s+1));
return res;
};
How do i get it to work? i have tryed a few thinkgs but no luck
if i have the string idnumbers and want to make it the object sectionNames seperated by a comma how would i go about it?
Many Thanks
Danny
-
Hi,
This function is a direct replacement of split, so it should be
sectionNames = idnumbers.mysplit(",")
The code for the function itself has to appear before it is used, say in one of the first frames of the movie.
Musicman
-
WOW! thats like 10 times faster! Thanks man! your just f**kin amazing!
Once again your knowledge has saved my plans! - I really must follow all that advise about planning sites first!
I was about to scrap the whole thing i was doining coz of the risk that users might get the "a script in flash is killing your comp" message. but there is no need!
Thank you ever so much Musicman!
Danny