CX gamer
04-26-2008, 09:42 AM
I'm programming in AS 2.0 and everything works fine... I have a script that does heavy calculations and convertions, while the script runs I get multiple errors that the flash movie is causing the computerizer to run slow, if I want to abort the movie... I say 'no', the script will run for several minutes and at the end it displays what I want it to do...
Because I hadn't a progress bar, I didn't knew how long it was going to take, so I tought of having a _root.progress variable to indicate it... Displaying it on the frame had no use because the frame was displayed after the script...So I put it into a trace() command... The output window showed up everytime I had the error, but no text... Strange...
So I put
trace("Is my trace command broke?!...");
on the first frame, before the script, the output window showed up but no text...:(
And there's more to it, my flash movie, output window and actionscript editor are all displayed behind my tools, library, etc. So if I maximise my flash movie, I can't see the red cross to close it... Is there any way to reset my interface?!... I tried window>workspace but it didn't work... :(
Here's the script, it's on the timeline frame 2, and I'm demn pround on it:
////////////////////////////////////////
// Stepmania/milliseconds convertion //
// //
// Script written by CX gamer //
////////////////////////////////////////
// This is the stepfile, as string, put in a commah in teh beginning and replace the ; on
// the end with another commah, remove all enters and comments insode so you would have
// one continuous line of bits seperated by commas...
stepfile = "..."; // This is a very very long string of 0s, 1s, 2s and 3s, I edited it out as it does nothing about the case
BMP = 200.000;
offset = -0.291;
stopnum = 0;
stoppos = new Array();
stoptim = new Array();
// Counts the number of 'char' that are present within 'string'
function countChar(string, char) {
count = 0;
for (i=0; i<=length(string); i++) {
if (string.charAt(i) == char) {
count++;
}
}
return count;
}
// Returns the 'num'th position of 'char' in 'string'
function charPos(string, char, num) {
count = 0;
for (i=0; i<=length(string); i++) {
if (string.charAt(i) == char) {
count++;
}
if (count == num) {
return i;
}
}
}
// Returns a slice from 'start' to 'end' in 'string'
function split(string, start, end) {
output = new String();
for (i=start; i<=end; i++) {
output += string.charAt(i);
}
return output;
}
array = new String();
type = new String();
// Highly compressed and complicate timing calculator starts here,
// don't even think about figuring it out... :)
// Srsly, you will get a message that will tell you to abort the script because it takes
// so long... Just continue, thrust me...
for (a=1; a<=(countChar(stepfile, ",")-1); a++) {
trace(Math.round(a/(countChar(stepfile, ",")-1)*100) + "%");
comp = split(stepfile, charPos(stepfile, ",", a)+1, charPos(stepfile, ",", a+1)-1);
for (b=0; b<=(length(comp)-4); b += 4) {
if (comp.charAt(b+0) == 1 || comp.charAt(b+1) == 1 || comp.charAt(b+2) == 1 || comp.charAt(b+3) == 1) {
prevT = 240/BMP*(a-1)-offset;
t = 240*b/BMP/length(comp)+prevT;
for (c=0; c<stopnum; c++) {// C++ heh :)
if (t>stoppos[c]*60/BMP-offset) {
t += stoptim[c];// Yeehaa, king of the hill!
}
}
array += [t]+",";
if (comp.charAt(b+0) == 1 && comp.charAt(b+1) == 1 && comp.charAt(b+2) == 1 && comp.charAt(b+3) == 1) {
type += "12,";
} else if (comp.charAt(b+0) == 1 && comp.charAt(b+1) == 1 && comp.charAt(b+2) == 1) {
type += "11,";
} else if (comp.charAt(b+0) == 1 && comp.charAt(b+1) == 1 && comp.charAt(b+3) == 1) {
type += "10,";
} else if (comp.charAt(b+1) == 1 && comp.charAt(b+2) == 1 && comp.charAt(b+3) == 1) {
type += "9,";
} else if (comp.charAt(b+0) == 1 && comp.charAt(b+2) == 1 && comp.charAt(b+3) == 1) {
type += "8,";
} else if ((comp.charAt(b+0) == 1 && comp.charAt(b+1) == 1) || (comp.charAt(b+0) == 1 && comp.charAt(b+2) == 1)) {
type += "4,";
} else if ((comp.charAt(b+2) == 1 && comp.charAt(b+3) == 1) || (comp.charAt(b+1) == 1 && comp.charAt(b+3) == 1)) {
type += "7,";
} else if (comp.charAt(b+1) == 1 && comp.charAt(b+2) == 1) {
type += "6,";
} else if (comp.charAt(b+0) == 1 && comp.charAt(b+3) == 1) {
type += "5,";
} else if (comp.charAt(b+0) == 1) {
type += "0,";
} else if (comp.charAt(b+1) == 1) {
type += "1,";
} else if (comp.charAt(b+2) == 1) {
type += "2,";
} else if (comp.charAt(b+3) == 1) {
type += "3,";
}
}
}
}
Please note that this script works as it should, only the trace command is broke...
Thanks in advance...
CX
Because I hadn't a progress bar, I didn't knew how long it was going to take, so I tought of having a _root.progress variable to indicate it... Displaying it on the frame had no use because the frame was displayed after the script...So I put it into a trace() command... The output window showed up everytime I had the error, but no text... Strange...
So I put
trace("Is my trace command broke?!...");
on the first frame, before the script, the output window showed up but no text...:(
And there's more to it, my flash movie, output window and actionscript editor are all displayed behind my tools, library, etc. So if I maximise my flash movie, I can't see the red cross to close it... Is there any way to reset my interface?!... I tried window>workspace but it didn't work... :(
Here's the script, it's on the timeline frame 2, and I'm demn pround on it:
////////////////////////////////////////
// Stepmania/milliseconds convertion //
// //
// Script written by CX gamer //
////////////////////////////////////////
// This is the stepfile, as string, put in a commah in teh beginning and replace the ; on
// the end with another commah, remove all enters and comments insode so you would have
// one continuous line of bits seperated by commas...
stepfile = "..."; // This is a very very long string of 0s, 1s, 2s and 3s, I edited it out as it does nothing about the case
BMP = 200.000;
offset = -0.291;
stopnum = 0;
stoppos = new Array();
stoptim = new Array();
// Counts the number of 'char' that are present within 'string'
function countChar(string, char) {
count = 0;
for (i=0; i<=length(string); i++) {
if (string.charAt(i) == char) {
count++;
}
}
return count;
}
// Returns the 'num'th position of 'char' in 'string'
function charPos(string, char, num) {
count = 0;
for (i=0; i<=length(string); i++) {
if (string.charAt(i) == char) {
count++;
}
if (count == num) {
return i;
}
}
}
// Returns a slice from 'start' to 'end' in 'string'
function split(string, start, end) {
output = new String();
for (i=start; i<=end; i++) {
output += string.charAt(i);
}
return output;
}
array = new String();
type = new String();
// Highly compressed and complicate timing calculator starts here,
// don't even think about figuring it out... :)
// Srsly, you will get a message that will tell you to abort the script because it takes
// so long... Just continue, thrust me...
for (a=1; a<=(countChar(stepfile, ",")-1); a++) {
trace(Math.round(a/(countChar(stepfile, ",")-1)*100) + "%");
comp = split(stepfile, charPos(stepfile, ",", a)+1, charPos(stepfile, ",", a+1)-1);
for (b=0; b<=(length(comp)-4); b += 4) {
if (comp.charAt(b+0) == 1 || comp.charAt(b+1) == 1 || comp.charAt(b+2) == 1 || comp.charAt(b+3) == 1) {
prevT = 240/BMP*(a-1)-offset;
t = 240*b/BMP/length(comp)+prevT;
for (c=0; c<stopnum; c++) {// C++ heh :)
if (t>stoppos[c]*60/BMP-offset) {
t += stoptim[c];// Yeehaa, king of the hill!
}
}
array += [t]+",";
if (comp.charAt(b+0) == 1 && comp.charAt(b+1) == 1 && comp.charAt(b+2) == 1 && comp.charAt(b+3) == 1) {
type += "12,";
} else if (comp.charAt(b+0) == 1 && comp.charAt(b+1) == 1 && comp.charAt(b+2) == 1) {
type += "11,";
} else if (comp.charAt(b+0) == 1 && comp.charAt(b+1) == 1 && comp.charAt(b+3) == 1) {
type += "10,";
} else if (comp.charAt(b+1) == 1 && comp.charAt(b+2) == 1 && comp.charAt(b+3) == 1) {
type += "9,";
} else if (comp.charAt(b+0) == 1 && comp.charAt(b+2) == 1 && comp.charAt(b+3) == 1) {
type += "8,";
} else if ((comp.charAt(b+0) == 1 && comp.charAt(b+1) == 1) || (comp.charAt(b+0) == 1 && comp.charAt(b+2) == 1)) {
type += "4,";
} else if ((comp.charAt(b+2) == 1 && comp.charAt(b+3) == 1) || (comp.charAt(b+1) == 1 && comp.charAt(b+3) == 1)) {
type += "7,";
} else if (comp.charAt(b+1) == 1 && comp.charAt(b+2) == 1) {
type += "6,";
} else if (comp.charAt(b+0) == 1 && comp.charAt(b+3) == 1) {
type += "5,";
} else if (comp.charAt(b+0) == 1) {
type += "0,";
} else if (comp.charAt(b+1) == 1) {
type += "1,";
} else if (comp.charAt(b+2) == 1) {
type += "2,";
} else if (comp.charAt(b+3) == 1) {
type += "3,";
}
}
}
}
Please note that this script works as it should, only the trace command is broke...
Thanks in advance...
CX