View Full Version : Syntax Error
StupidRalph
07-22-2007, 10:17 PM
I just created a rating system in Flash 8.
I'm receiving this error
**Error** Scene=Scene 1, layer=actions, frame=1:Line 25: '{' expected
function enable_rate():Void{
**Error** Scene=Scene 1, layer=actions, frame=1:Line 36: Unexpected '}' encountered
}
Total ActionScript Errors: 2 Reported Errors: 2
this is the code starting at line 25 and ending at line 36
function enable_rate():Void{
if (rate_mask == true)
{ //song has been rated
mc_enable._alpha = 0;
set_icn_status(rating, "rate_icn_on", "rate_icn_off"); //show many icons
}
mc_enable.onMouseUp = function() {
mc_enable._alpha = 0;
rate_mask = true;
setup_events();
}
}
As you can see, I have the opening curly brace '{'.
_Aerospace_Eng_
07-22-2007, 10:18 PM
Can you post the rest of your actionscript? Chances are the error is before this function. Because just running that actionscript doesn't return any syntax errors.
StupidRalph
07-22-2007, 10:23 PM
I honestly don't know what I did differently in the last 2 minutes but its working. I try adding an additional '{' after the one I already had and still received the error. So I deleted it and moved the { to the next line (line 26) and the error stopped. So, then I moved it back to line 25 and I still didn't receive the error
function enable_rate(){
if (rate_mask == true)
{ //song has been rated
mc_enable._alpha = 0;
set_icn_status(rating, "rate_icn_on", "rate_icn_off"); //show many icons
}
mc_enable.onMouseUp = function() {
mc_enable._alpha = 0;
rate_mask = true;
setup_events();
}
}
StupidRalph
07-22-2007, 10:27 PM
Can you post the rest of your actionscript? Chances are the error is before this function. Because just running that actionscript doesn't return any syntax errors.
Hey _Aero I honestly didn't change anything above or below that function and it works. However, just for quirks, here is the full actionscript code.
//init variables
//var rating:Number = 0; //temporary for testing. should be loaded from SWFObject.
var is_rateable:Boolean = false;
var rate_mask:Boolean = false; //when set to false 'RATE HERE' appears
if (rating == 0 || rating == null || rating == undefined)
{ //song has not been rated.
rating = 0;
is_rateable = true;
rate_mask = false; //show 'RATE HERE'
}
else
{ //song has been rated.
is_rateable = false;
rate_mask = true; //hide 'RATE HERE'
}
function enable_rate(){
if (rate_mask == true)
{ //song has been rated
mc_enable._alpha = 0;
set_icn_status(rating, "rate_icn_on", "rate_icn_off"); //show many icons
}
mc_enable.onMouseUp = function() {
mc_enable._alpha = 0;
rate_mask = true;
setup_events();
}
}
enable_rate();
function setup_events()
{
if (is_rateable == true && rate_mask==true )
{ trace("Entered setup_events(): rate_mask = " + rate_mask + " is_rateable = " + is_rateable);
for (var i = 1; i <= 5; i++)
{
set ("icn_rate_" + i +".rate_value",i);//set the value for each icon
tellTarget("icn_rate_" + i)
{
onDragOver = onRollOver = function()
{
trace(this.rate_value);
set_icn_status(this.rate_value,"rate_icn_on","rate_icn_off");
}//end events
onRollOut = onDragOut = function ()
{
set_icn_status(rating, "rate_icn_on", "rate_icn_off");
}//end events
onRelease = function ()
{//user has just rated the song
//save users rating and change is_rateable
is_rateable = false;
clear_events(); //delete event functions
var send_lv:LoadVars = new LoadVars(); //e
//Here you insert variables to be sent (example using username and password)
send_lv.rating = this.rate_value;
send_lv.memberID = member_id; //hard coded should be sent from SWFObject
send_lv.songID = song_id; //hardcoded should be set from SWFObject
send_lv.send("http://localhost/8thwonder/v2/rate_flash.php", "_self", "POST");
}
}//end tellTarget
}//end for loop
}//end if
}//end function
function set_icn_status(icn_number, state1, state2)
{
for (k = 1; k <= 5; k++)
{
if (k <= icn_number) //
{
tellTarget("icn_rate_" + k)
{
gotoAndStop(state1);
} // End of tellTarget
} // end if
if (k > icn_number && k <= 5)
{
tellTarget("icn_rate_" + k)
{
gotoAndStop(state2);
} // End of tellTarget
} // end if
} // end of for
} // End of the function
clear_events = function ()
{
for (j = 1; j <= 5; j++)
{
set("icn_rate_" + j + ".rate_value",j);
tellTarget("icn_rate_" + j)
{
delete onRollOver;
delete onDragOver;
delete onRollOut;
delete onDragOut;
delete onRelease;
trace("cleared");
} // End of TellTarget
} // end of for
}
_Aerospace_Eng_
07-22-2007, 10:30 PM
You obviously changed something. Perhaps you accidentally typed an extra character in the actionscript somewhere and when moving things around you got rid of it.
StupidRalph
07-22-2007, 10:31 PM
On second thought, I will post another topic because I am using tellTarget which of course is deprecated. I want to use with but couldn't get it to work with dynamically named objects. I'll create another post and link it here.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.