Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Flash General Questions > Other Flash General Questions

Reply
 
Thread Tools Rate Thread Display Modes
Old 01-28-2007, 11:52 PM   #1
Gymdawg
Registered User
 
Join Date: Jan 2007
Posts: 5
Default expected '}' error

I'm rather new to Actionscript, granted I've taught myself other programming languages so I'm not quite as new as I could be, but the point remains.

I'm trying to make a simple program for school that will have a number of button presses and multi-key presses control which background is shown in a movie, the only problem is I can't get it working and I don't know why.

I've set up my code as you see below. I've probably done numerous things wrong, hence the errors, but as I said, I'm new at this.

Quote:
Originally Posted by code
onClipEvent (keyDown)
if (Key.isDown(49)) {
tellTarget ("/BackgroundChange") {
gotoFrame(3);
}
};

if (Key.isDown(49) && key.isDown(37)) {
tellTarget ("/BackgroundChange") {
gotoFrame(4);
}
};

if (Key.isDown(49) && key.isDown(39)) {
tellTarget ("/BackgroundChange") {
gotoFrame(5);
}
};

if (Key.isDown(50)) {
tellTarget ("/BackgroundChange") {
gotoFrame(6);
}
}

if (Key.isDown(50) && key.isDown(37)) {
tellTarget ("/BackgroundChange") {
gotoFrame(7);
}
};

if (Key.isDown(50) && key.isDown(39)) {
tellTarget ("/BackgroundChange") {
gotoFrame(8);
}
};

if (Key.isDown(51)) {
tellTarget ("/BackgroundChange") {
gotoFrame(9);
}
};

if (Key.isDown(51) && key.isDown(37)) {
tellTarget ("/BackgroundChange") {
gotoFrame(10);
}
};

if (Key.isDown(51) && key.isDown(39)) {
tellTarget ("/BackgroundChange") {
gotoFrame(11);
}
};

if (Key.isDown(52)) {
tellTarget ("/BackgroundChange") {
gotoFrame(12);
}
};

if (Key.isDown(52) && key.isDown(37)) {
tellTarget ("/BackgroundChange") {
gotoFrame(13);
}
};

if (Key.isDown(52) && key.isDown(39)) {
tellTarget ("/BackgroundChange") {
gotoFrame(14);
}
};

if (Key.isDown(53)) {
tellTarget ("/BackgroundChange") {
gotoFrame(15);
}
};

if (Key.isDown(53) && key.isDown(37)) {
tellTarget ("/BackgroundChange") {
gotoFrame(16);
}
};

if (Key.isDown(53) && key.isDown(39)) {
tellTarget ("/BackgroundChange") {
gotoFrame(17);
}
};

if (Key.isDown(key.space) && key.isDown(37)) {
tellTarget ("/BackgroundChange") {
gotoFrame(18);
}
};

if (Key.isDown(key.space) && key.isDown(38)) {
tellTarget ("/BackgroundChange") {
gotoFrame(19);
}
};

if (Key.isDown(key.space) && key.isDown(39)) {
tellTarget ("/BackgroundChange") {
gotoFrame(20);
}
};

if (Key.isDown(key.space) && key.isDown(40)) {
tellTarget ("/BackgroundChange") {
gotoFrame(21);
}
}
Basically, I tried to combine several tutorials to achieve my desired effect, yet wound up with the error below:

Quote:
Originally Posted by error
**Error** Scene=Scene 1, layer=change, frame=2:Line 2: '{' expected
if (Key.isDown(49)) {

**Error** Scene=Scene 1, layer=change, frame=2:Line 114: Syntax error.
}

Total ActionScript Errors: 2 Reported Errors: 2
I'd appreciate some help, as the due date for the project is approaching and I don't want to have to lower the scale of my submission just to get it done.

Much thanks.
Gymdawg is offline   Reply With Quote
Old 01-29-2007, 01:42 AM   #2
Cota
Super Moderator
 
Cota's Avatar
 
Join Date: Jul 2001
Location: NYC
Posts: 10,175
Default

Firstly, I'd say dont use telltarget, its depreciated. secondly, see if you're still getting that error after you take out telltarget.
__________________
Color Wars | (kul′ər wrs) n. - Open conflict between factions. www.theColorWars.com

cota - www.chadworkman.com | http://shavedplatypus.com
occupation: designer | flash developer | server-side developer (php, asp, mssql, mysql)
Cota is offline   Reply With Quote
Old 01-29-2007, 02:14 AM   #3
Gymdawg
Registered User
 
Join Date: Jan 2007
Posts: 5
Default

What should I use instead of tellTarget?
Gymdawg is offline   Reply With Quote
Old 01-29-2007, 03:13 AM   #4
Cota
Super Moderator
 
Cota's Avatar
 
Join Date: Jul 2001
Location: NYC
Posts: 10,175
Default

PathtoMovieClip.gotoAndPlay(1);

where PathtoMovieClip is replaced by the path to your movieclip or just the movieclip name if no path is needed.

example
ActionScript Code:
if (Key.isDown(key.space) && key.isDown(39)) { backgroundChange.gotoAndStop(20); }
__________________
Color Wars | (kul′ər wrs) n. - Open conflict between factions. www.theColorWars.com

cota - www.chadworkman.com | http://shavedplatypus.com
occupation: designer | flash developer | server-side developer (php, asp, mssql, mysql)
Cota is offline   Reply With Quote
Old 01-29-2007, 07:24 PM   #5
Gymdawg
Registered User
 
Join Date: Jan 2007
Posts: 5
Default

Nope, changed them all and I'm still getting the same errors.
Gymdawg is offline   Reply With Quote
Old 01-29-2007, 07:37 PM   #6
Cota
Super Moderator
 
Cota's Avatar
 
Join Date: Jul 2001
Location: NYC
Posts: 10,175
Default

attach your FLA.
__________________
Color Wars | (kul′ər wrs) n. - Open conflict between factions. www.theColorWars.com

cota - www.chadworkman.com | http://shavedplatypus.com
occupation: designer | flash developer | server-side developer (php, asp, mssql, mysql)
Cota is offline   Reply With Quote
Old 01-29-2007, 07:42 PM   #7
petite minotaure
Registered User
 
Join Date: Aug 2006
Location: hudson valley, NY
Posts: 86
Default you forgot a {}

to start you need an opening bracket after your onClipEvent... at the beginning of your code, on the first line

ActionScript Code:
onClipEvent (keyDown) {

then use a closing bracket at the very end of the code enclosing all your if statements in between

I tested it and there were no syntax errors once I added the brackets. Cota's suggestion is also a good one.

Last edited by petite minotaure; 01-29-2007 at 07:46 PM. Reason: typo
petite minotaure is offline   Reply With Quote
Old 01-29-2007, 07:43 PM   #8
Cota
Super Moderator
 
Cota's Avatar
 
Join Date: Jul 2001
Location: NYC
Posts: 10,175
Default

No Clipevents!
__________________
Color Wars | (kul′ər wrs) n. - Open conflict between factions. www.theColorWars.com

cota - www.chadworkman.com | http://shavedplatypus.com
occupation: designer | flash developer | server-side developer (php, asp, mssql, mysql)
Cota is offline   Reply With Quote
Old 01-31-2007, 03:03 AM   #9
Gymdawg
Registered User
 
Join Date: Jan 2007
Posts: 5
Default

The .zip file is too large to attatch and I don't have time to upload it right now. I can upload it an post it later though, if that's still necessary.
Gymdawg is offline   Reply With Quote
Old 01-31-2007, 03:18 AM   #10
Cota
Super Moderator
 
Cota's Avatar
 
Join Date: Jul 2001
Location: NYC
Posts: 10,175
Default

Basically you have a stray "{" somewhere.
__________________
Color Wars | (kul′ər wrs) n. - Open conflict between factions. www.theColorWars.com

cota - www.chadworkman.com | http://shavedplatypus.com
occupation: designer | flash developer | server-side developer (php, asp, mssql, mysql)
Cota is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Flash4 FLA to FLASH8. AS error PasteLurv ActionScript 2.0 3 09-26-2006 02:55 PM
Wierd Timeline Transition Error Benaiah Other Flash General Questions 1 08-01-2006 04:32 PM
Nonsense Pop Up Error?? IceCo ActionScript 2.0 0 06-13-2005 11:27 PM
; expected error er1717 ActionScript 1.0 (and below) 1 02-05-2005 04:56 PM
dynamic variables (newbie question) smirnie Simple Stuff (Newbies) 13 05-07-2004 07:46 AM


All times are GMT. The time now is 11:56 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.