IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Flash hates me
Commander Flufy
post Jun 30 2005, 11:11 PM
Post #1


Member
**

Group: New Members
Posts: 13
Joined: 27-June 05
Member No.: 1,863
Gender: Male



I'm trying to link a button to a frame, but when i compile to test it i get this error:

**Error** Scene=Scene 2, layer=Layer 12, frame=1:Line 1: Wrong number of parameters; gotoAndPlay requires between 1 and 2.
gotoAndPlay();

**Error** Scene=Scene 2, layer=Layer 12, frame=1:Line 1: Statement must appear within on handler
gotoAndPlay(235);

Total ActionScript Errors: 2 Reported Errors: 2

The code i'm using on the action button is:

gotoAndPlay(235);

I hope you can help! cool.gif


--------------------
user posted image
Go to the top of the page
 
+Quote Post
Mata
post Jul 1 2005, 12:19 AM
Post #2


'Trouble Down Pit' now online!
***************

Group: Admin
Posts: 10,205
Joined: 22-February 03
From: Southern UK
Member No.: 1
Gender: Male



Hmm.

Well, my first guess would be that you might have forgotten the basic stuff. Do you have the 'on' function defined?

on(press){
gotoAndPlay(235);
}

Your use of gotoAndPlay looks fine, so I don't think that the error is there.

I don't think it should make any difference with something so basic, but you might want to try setting the publish settings (under the file menu) to actionscript 1.0 . Like I say, I doubt it's related, but I program in 1.0 and your code looks fine so that's a slim possibility of being the error.

As a designer I would strongly suggest giving whatever you have at frame 235 a name, even if it is "twothreefive" and making your code gotoAndPlay(""twothreefive"). This will give you lots more flexibility if/when you need to edit your timeline. I almost never use timeline frame numbers in my scripts, they just cause more problems further along the line.


--------------------
Trouble Down Pit: Still updated every Monday and Friday
The Matazone Games blog
The Matazone Shop The Matazone Blog
The Matazone Corset Shop: Snobz corsets at 10% off their recommended price!
Go to the top of the page
 
+Quote Post
Commander Flufy
post Jul 1 2005, 08:48 AM
Post #3


Member
**

Group: New Members
Posts: 13
Joined: 27-June 05
Member No.: 1,863
Gender: Male



how do i name a frame?

ah, it says i have Action Script 1.0

i have that exact code and it still hates me


--------------------
user posted image
Go to the top of the page
 
+Quote Post
Mata
post Jul 1 2005, 09:54 AM
Post #4


'Trouble Down Pit' now online!
***************

Group: Admin
Posts: 10,205
Joined: 22-February 03
From: Southern UK
Member No.: 1
Gender: Male



You name a frame by selecting it on the timeline, then using the properties box to give the frame a label.

How big is the Flash file? If it's under 1MB then email it to me, I'll have a look to see if I can spot where you're going wrong. mata [at} matazone{dot]co[uk}


--------------------
Trouble Down Pit: Still updated every Monday and Friday
The Matazone Games blog
The Matazone Shop The Matazone Blog
The Matazone Corset Shop: Snobz corsets at 10% off their recommended price!
Go to the top of the page
 
+Quote Post
Commander Flufy
post Jul 1 2005, 10:13 AM
Post #5


Member
**

Group: New Members
Posts: 13
Joined: 27-June 05
Member No.: 1,863
Gender: Male



good greif it's 58mb!

i'll take out the sounds! rolleyes.gif


--------------------
user posted image
Go to the top of the page
 
+Quote Post
Commander Flufy
post Jul 1 2005, 10:15 AM
Post #6


Member
**

Group: New Members
Posts: 13
Joined: 27-June 05
Member No.: 1,863
Gender: Male



ok, that's better, only 112kb now

emailed smile.gif


--------------------
user posted image
Go to the top of the page
 
+Quote Post
Mata
post Jul 1 2005, 02:37 PM
Post #7


'Trouble Down Pit' now online!
***************

Group: Admin
Posts: 10,205
Joined: 22-February 03
From: Southern UK
Member No.: 1
Gender: Male



58MB!!!! Blimey, your processor must hate you. Try importing semi-optimised mp3 files for your sounds instead of .wav or zero-compression mp3s.

I've had a look through and the answer is very simple, although it took me a while to work out.

To start off with the error you're getting is nothing to do with the button. As the error says, gotoAndPlay needs to have either one or two variables in it. On one of the frames you have 'gotoAndPlay()' with nothing in the brackets. Delete that and you get rid of the error.

So, there was no error with the code. I tried many different variations and still no error, but also no result.

My first clue to what the problem was was when I noticed that in one frame you've used the stop() code four times, and you then repeat it again on another layer! You don't need to tell the computer to do something five times, once will suffice!

I'd ruled out there being a problem with the button code, and had now seen that you are fond of scattering code onto your frames like needles from an indoor pine tree. I went and had a look at what was at frame 235.

Bingo: you had code there saying 'gotoAndPlay(1)'. So whenever the button sent the playhead to that point it immediately got sent back. Not only that, but you've put another stop() on your actions layer at frame 235 too, so even if you'd found the first error it still wouldn't have played! Delete those commands and it works perfectly.

My tip: if you are going to be doing something simple with timeline animations such as you are then always keep your actions on one layer. You've called one layer 'actions' so use it! Go through your whole movie and move all the actions onto that layer _and nothing else_. That way you will be able to see clearly what you've told it to do and leave the rest of your layers free for animation.

Like I say, use frame labels too: that way if you decide to add in more animation frames before 235 the label will be shunted along too, rather than you having to go back into your button code and changing the frame number. A frame label is written between speech marks, ie.

gotoAndPlay("framelabel235orsomething");

There you go. All fixed!


--------------------
Trouble Down Pit: Still updated every Monday and Friday
The Matazone Games blog
The Matazone Shop The Matazone Blog
The Matazone Corset Shop: Snobz corsets at 10% off their recommended price!
Go to the top of the page
 
+Quote Post
Commander Flufy
post Jul 1 2005, 02:51 PM
Post #8


Member
**

Group: New Members
Posts: 13
Joined: 27-June 05
Member No.: 1,863
Gender: Male



wow!!!!! thanks very much!!!! biggrin.gif

i've just put an "actions" layer in now, too


--------------------
user posted image
Go to the top of the page
 
+Quote Post
Mata
post Jul 1 2005, 11:36 PM
Post #9


'Trouble Down Pit' now online!
***************

Group: Admin
Posts: 10,205
Joined: 22-February 03
From: Southern UK
Member No.: 1
Gender: Male



'Glad to be of help, it gave me something to ponder while I was eating my lunch.

Like I say, when you're doing something simple like a timeline navigation piece such as this then it's best to have all your frame actions in one layer. It keeps things tidy and it prevents you from missing things when you're trying to locate a problem.

Frame labels are great! In programming I use as few numbers as possible because it makes things easier to change. For example, if I want something to be moving at a maximum speed of 20 pixels per frame I could write '20' all over the place, but if I set speed = 20 at the beginning then I can alter that with a couple of keystrokes. This saves a lot of time!

When your programming becomes more complicated then you might find that you want to split your actions onto different levels. My animations usually only have one actions level, but my games often have several, one for defining functions, another for setting initial variables, another for loop controls, and another to actually run the functions. I find this makes it easier to find something rather than wading through code.

Like many things in life, if you start with some good organisation then you make your life easier further down the line.


--------------------
Trouble Down Pit: Still updated every Monday and Friday
The Matazone Games blog
The Matazone Shop The Matazone Blog
The Matazone Corset Shop: Snobz corsets at 10% off their recommended price!
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 17th October 2017 - 06:07 AM
Use these links if you're going to shop at Amazon and a percentage of what you spend goes towards helping this site!