Error #1009 when the first choice is clicked (but working with the 2nd and 3rd choice) - actionscript-3

Ok ive googled about this error and still cant fix my problem.
it was all going well. Im just copying the same codes and changing variable names for the first frame since the 3 frames basically has the same functions. But when i copied it to the first frame, i get that error.
Fla file: https://www.dropbox.com/s/domsbipbxwmyoje/100%20-%20Copy.rar
stop();
small.addEventListener(MouseEvent.CLICK,play1);
function play1(event:MouseEvent):void{
gotoAndStop("3");
}
medium.addEventListener(MouseEvent.CLICK,play2);
function play2(event:MouseEvent):void{
gotoAndStop("4");
}
large.addEventListener(MouseEvent.CLICK,play3);
function play3(event:MouseEvent):void{
gotoAndStop("5");
}
Thats the code for the first frame. Thats just a part of the code and not the whole. I feel like the error is in there. The medium and large are perfectly fine. i carbon copied the codes to the SMALL option but i get an error. I feel like i dont need to post the code for the frame 3 (where the error is happening) since its just the same with MEDIUM and LARGE.

You have to change the name of your button next_btn1 is called in the script but the name on the timeline is next_btn.
Instead of running the movie (ctrl+enter) you can debug the movie (ctrl+shift+enter) try it it will change your life ;)

Related

TypeError 1009, began appearing randomly after adding new button code

SOLVED: It was a two stop functions. Two. Stop. Functions. AS3 can be so annoying sometimes.
I am making a space invaders style game for a school assignment. I was adding in a button to go between frames and I deleted an unnecessary layer that contained a single sprite in my game, which I added back onto the main code layer. Then after attempting to restart my game to check the button, I began receiving a TypeError Code 1009. It is stating that there is an error with MainTimeline/moveBullet() and, MainTimeline/eFrame(). These sections of the code were not altered whatsoever during the creation of the button or movement of the sprite, however, as the bullet is linked to the moving sprite I think the error may be there. I'll put the code below, if anyone knows how to fix this specifically or has a general idea of how to do so please let me know. This is due in a few hours and would greatly appreciate a quick fix. Thanks.
Re-named sprites, re-typed code sections returning errors again. Most fixes appear to be in instance names, corrected them and no fix.
this.addEventListener(Event.ENTER_FRAME, eFrame)
function eFrame(e: Event) {
controls();
restrain();
moveBullet();
enemyHit();
barrierHit();
function moveBullet() {
if (bull.visible == true) {
bull.y -= bulletspeed;
if (bull.y < 0) {
bull.visible = false;
}
}
}
The game had been running fine until this point. The character would move along bottom and shoot up at "bad guys". Bullets were removing bad guys. Now I get the usual super fast run through frames repeatedly. NO Compiler Errors, just output, being
TypeError: Error #1009
"I deleted an unnecessary layer that contained a single sprite in my game, which I added back onto the main code layer. Then after attempting to restart my game to check the button, I began receiving a TypeError Code 1009."
Possible solutions:
(1)
Did you also give the Sprite an instance name? I suspect the name bull is what's expected.
(2)
Eliminate that the problem is in moveBullet(). Disable the call and if the error still exists, then the problem must be between variables bull and bulletspeed.
Comment the call movebullet() in function eFrame:
function eFrame(e: Event)
{
//moveBullet();
....

Adobe Animate Actionscript 3.0 "clicktogotonextscene" code not working

So I have the following code for a button called "n2" and as you can see it's supposed to take me to the next scene when I click it, but it isn't working. It is inside Scene 2 and I'm trying to get to the next one and whenever I test the scene and click it, I don't even get an error, it just doesn't work.
Btw, it's a GIF defined as a movie clip and then as a button. Could that be causing the problem?
n2.addEventListener(MouseEvent.CLICK, fl_ClickToGoToNextScene);
function fl_ClickToGoToNextScene(event:MouseEvent):void
{
MovieClip(this.root).nextScene();
}
If you put a trace in the function and comment out "MovieClip(this.root).nextScene();" you could then see if the function gets called on a button click.
I've not used animate before, but in flash you have to name your button/movieclip and then also name the instance. This allows you to create the object twice with two seperate names to be referred to by actionscript.
Not sure if this helps but thought I'd give you some things to try, good luck

Actionscript ExternalInterface syntax error

I have created a simple container app whose purpose is to:
play an embedded flv by clicking a button onscreen
activate an external interface call (this records the fact that the person has watched the video)
That's it.
I have it working partially. I have a button on scene 1 with the "click and go to next scene" code snippet attached to it. I click it and it happily moves on to scene 2 where the flv video plays beautifully. The problem happens when I try to insert the code that the external developer told me to use to make the connection between my flash file and IT's back end work.
Here is the recommended code:
ExternalInterface.call("recordScore()”);
Unfortunately, as soon as I enter this code, there is a syntax error and the movie no longer plays. I added the code on a frame at the end of the movie.
I am no sure that the syntax the developer sent was correct, nor do I know where to insert this code into the proper place.
It looks like there is a closed double quotes (”) in what you pasted:
ExternalInterface.call("recordScore()”);
Assure quotation marks, and you do not need the () on the JavaScript function you're calling:
ExternalInterface.call("recordScore");
When running from Flash Projector (as in Ctrl+Enter), you can test whether External Interface is available; otherwise, an exception is thrown at runtime:
if (ExternalInterface.available) {
ExternalInterface.call("recordScore");
}
Fortunately, I found some code in the former employee's files that seems to have worked:
ExternalInterface.call
(
"recordScore()"
);
Hopefully this will connect with the database and resolve the issue so I can go back to making videos.
Thank you so much for your help!
Regards!

Adobe flash can't run code in a frame

Ok, I'm fairly new to Flash, and I was trying to code some ActionScript now for the last two days. I can't a simple piece of code to work:
stop();
So... pretty simple right? ;)
I have a 10 frame animation, and I'm trying to make the animation stop at frame 5. So I select frame 5 from my timeline and then I open the action menu and I simply write stop(); in the window. When I run it I get the following error message:
In ActionScript 3.0 code cannot be placed directly on objects. Please select an object or use the Code Snippet panel to apply code to the current selection on stage.
I totally understand this is a simple question and the answer might be obvious, but I can't find it...
Thanks
EDIT:
I tried debugging it, and it works when in the debugger but not when in flash...
You're putting the code "on" the object, not allowed in AS3 (thx god).
To avoid it, create a new layer and name it "code" (or whatever you want), and put the code in it

Actionscript: TypeError: Error #1009

I have been trying to fix an error in my project for the past hour, and I really have no idea what the cause is. I will post the code on my skydrive:
https://skydrive.live.com/embed?cid=9AB08B59DCCDF9C6&resid=9AB08B59DCCDF9C6%21108&authkey=AGVkp5KnQLMYu7M
Everything just doesn't work the way I want to. The inventoryrelationships_btn is glitchy when I test the movie. To make it worse, when I debug, and the inventory/relationships button is clicked, it freezes up everything.
The culprit comes from the following line
menuback_btn.addEventListener(MouseEvent.CLICK, menubackClick);
in your "popups" symbol, frame 2. There is no menuback_btn, and if you do a trace(menuback_btn); The output window shows null.
Hope this helps.