PDA

View Full Version : [Help - ActionScript] Help with compiler errors



G-FLASH
03-22-2011, 08:53 PM
I'm basically trying to port an old app from 2004 and update it to CS5 but there seems
to be a syntax error that i cannot understand... If anyone dose then i will
Post the problem otherwise i wont confuse anyone..It's kinda technical.

Eris
03-22-2011, 09:06 PM
My programming-fu is godlike. But, I've not bothered to learn AS, as programming languages should be open.

None the less, I may be able to help you if you post an error description, as most errors generalize to other similar languages (unless it's API-specific).

G-FLASH
03-22-2011, 10:04 PM
My programming-fu is godlike. But, I've not bothered to learn AS, as programming languages should be open.

None the less, I may be able to help you if you post an error description, as most errors generalize to other similar languages (unless it's API-specific).

I get this **Error** Scene=Scene1, layer=d1, frame=1:Line 1: Statement block must be terminated by '}'

Have a look at this


onClipEvent(enterFrame) { _root.preloader.bar._xscale = siteLoaded; siteLoaded = int(((loaded_bytes / total_bytes) * 100)); total_bytes = _root.getBytesTotal(); loaded_bytes = _root.getBytesLoaded(); remaining_bytes = total_bytes - loaded_bytes; frame_loaded = _root._framesloaded; frame_total = _root._totalframes; totalkb = "int((total_bytes / 1024)) + KB"; loadedkb = "int((loaded_bytes / 1024)) + KB"; remaining_kb = int((remaining_bytes / 1024)); remainingkb = "int(remaining_kb) + KB"; percent_done = "int(((loaded_bytes / total_bytes) * 100)) + %"; time = getTimer() / 1000; speed = loaded_bytes / time; bits = speed / 1024; Kbps = "(Math.round(bits * 10) / 10) + KB/S"; kbyteCounter = (total_bytes - loaded_bytes) / 1024; loadRate = (loaded_bytes / 1024) / time; timeCounter = kbyteCounter / loadRate; minutes = Math.floor(timeCounter / 60); seconds = Math.round((timeCounter / 60 - minutes) * 60); time_remaining = minutes + " min " + seconds + " sec"; minute = Math.floor(time / 60); second = Math.round((time / 60 - minute) * 60); time_elapsed = minute + " min " + second + " sec"; if(total_bytes == loaded_bytes) { _root.gotoAndPlay(2); } // end if }

so Basically i was trying to Fix an old pre-loader which i had back in the days when Flash was Macromedia and not Adobe... (yeah the good old days) d=
The dilemma is the last Save was on the MX 2004 Flash series which would make my Fla File obsolete but not impossible...

I spent a good 1 hour and 20 mins trying to see where the enclosed } <----- was meant to be put...


The preLoader is meant to look like this...

http://i674.photobucket.com/albums/vv104/Skullworth/Rightone.jpg



But when it was Up-fitted to CS5 this was the result...

http://i674.photobucket.com/albums/vv104/Skullworth/Errorone-1.jpg



I can't really say why this is happening...Flash Action scripting is one of my poorest understandings but i know the CS5 Port has different Coding Sequences that have surpassed the Flash 8 and MX through Time...
I personally think i should send you the Two files and you can then figure it out practically if you want to get your hands dirty d=)

FlashD
03-23-2011, 03:49 AM
It's hard to read that code, but copy pasting it into an editor shows that your whole code is inside only one line. Assuming this is the case in your code and not the forum's way to format code posted with no code tags, the error means the } at the end is not seen due to the single line comment.

In other words your code should look like this:


onClipEvent(enterFrame)
{
_root.preloader.bar._xscale = siteLoaded;
siteLoaded = int(((loaded_bytes / total_bytes) * 100));
total_bytes = _root.getBytesTotal(); loaded_bytes = _root.getBytesLoaded();
remaining_bytes = total_bytes - loaded_bytes;
frame_loaded = _root._framesloaded;
frame_total = _root._totalframes;
totalkb = "int((total_bytes / 1024)) + KB";
loadedkb = "int((loaded_bytes / 1024)) + KB";
remaining_kb = int((remaining_bytes / 1024));
remainingkb = "int(remaining_kb) + KB";
percent_done = "int(((loaded_bytes / total_bytes) * 100)) + %";
time = getTimer() / 1000;
speed = loaded_bytes / time;
bits = speed / 1024;
Kbps = "(Math.round(bits * 10) / 10) + KB/S";
kbyteCounter = (total_bytes - loaded_bytes) / 1024;
loadRate = (loaded_bytes / 1024) / time;
timeCounter = kbyteCounter / loadRate;
minutes = Math.floor(timeCounter / 60);
seconds = Math.round((timeCounter / 60 - minutes) * 60);
time_remaining = minutes + " min " + seconds + " sec";
minute = Math.floor(time / 60);
second = Math.round((time / 60 - minute) * 60);
time_elapsed = minute + " min " + second + " sec";

if(total_bytes == loaded_bytes) { _root.gotoAndPlay(2); } // end if
}

Other than that I'm not sure why there are so many brackets .... then again I don't speak AS. ~_~;;

G-FLASH
03-23-2011, 08:00 AM
Yeah d=) i think it's down to untidyness... the CS5 may have
disfigured the settings to how it originally was set....
to be honest looking at te way you formed it I'm 95% sure this that the right way..
Believe im no pro at AS either but thank you for spending time to help me on this.. *Bows in gratitude*

Here have some Rep+

(Update) it was a success but the only issue i'm getting is that the dynamic information digits are still not showing...

FlashD
03-24-2011, 04:00 AM
(Update) it was a success but the only issue i'm getting is that the dynamic information digits are still not showing...
Sadly I don't speak AS, but some good old debugging methods should help here. Start by checking that all your variables are geting the values they should and then move on to graphics issues (even though I kinda doubt that there are any).

For one, I kinda feel weird when I see this:

remainingkb = "int(remaining_kb) + KB";
Why would you use quotation marks for the whole variable. Logic would say it should be int(remaining_kb) + "KB";

or this:

remaining_kb = int((remaining_bytes / 1024));
Here it should be enough to just use int(remaining_bytes / 1024);

As I already stated before I don't speak AS and these might as well be legit syntaxes for the language, but if this is not the case it can be a good reason why your code doesn't work as it should.

╠-The Neo-╣
04-20-2011, 04:39 PM
I'm probably the only flash guru here xD AS is my language, by the looks of it yes it has been stated that you are putting quotes around the whole variables here is a quick touch up on your code


onClipEvent(enterFrame)
{
_root.preloader.bar._xscale = siteLoaded;
siteLoaded = int(((loaded_bytes / total_bytes) * 100));
total_bytes = _root.getBytesTotal(); loaded_bytes = _root.getBytesLoaded();
remaining_bytes = total_bytes - loaded_bytes;
frame_loaded = _root._framesloaded;
frame_total = _root._totalframes;
totalkb = int((total_bytes / 1024)) + "KB";
loadedkb = int((loaded_bytes / 1024)) + "KB";
remaining_kb = int((remaining_bytes / 1024));
remainingkb = int(remaining_kb) + "KB";
percent_done = int(((loaded_bytes / total_bytes) * 100)) + "%";
time = getTimer() / 1000;
speed = loaded_bytes / time;
bits = speed / 1024;
Kbps = (Math.round(bits * 10) / 10) + "KB/S";
kbyteCounter = (total_bytes - loaded_bytes) / 1024;
loadRate = (loaded_bytes / 1024) / time;
timeCounter = kbyteCounter / loadRate;
minutes = Math.floor(timeCounter / 60);
seconds = Math.round((timeCounter / 60 - minutes) * 60);
time_remaining = minutes + " min " + seconds + " sec";
minute = Math.floor(time / 60);
second = Math.round((time / 60 - minute) * 60);
time_elapsed = minute + " min " + second + " sec";

if(total_bytes == loaded_bytes) { _root.gotoAndPlay(2); } // end if
}


there ya go, if you continue to have any problems, just reply