Copy link to clipboard
Copied
I need major help here. I have a script with a movieclip with a two buttons inside. These work so that it would look like it stayed pushed down until you clicked it again to simulate a multiple choice. Pressing the buttons sends the array a push. If the array reaches 4 it should stop and all that stuff. Problem is that it works pretty fine if you press it, but wont stay pressed anymore and drops me with the 1009 error.
Anyways, here's the code:
Any kind of help would be greatly appreciated as this is basically for my finals.
The 1009 error indicates that one of the objects being targeted by your code is out of scope. This could mean that the object....
- is declared but not instantiated
- doesn't have an instance name (or the instance name is mispelled)
- does not exist in the frame where that code is trying to talk to it
- is animated into place but is not assigned instance names in every keyframe for it
- is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).
...Copy link to clipboard
Copied
The 1009 error indicates that one of the objects being targeted by your code is out of scope. This could mean that the object....
- is declared but not instantiated
- doesn't have an instance name (or the instance name is mispelled)
- does not exist in the frame where that code is trying to talk to it
- is animated into place but is not assigned instance names in every keyframe for it
- is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).
If you go into your Publish Settings Flash section and select the option to Permit debugging, your error message should have a line number following the frame number which will help you isolate which object is involved.
Copy link to clipboard
Copied
Alright, I got the debugging on. It says:
"TypeError: Error #1009: Cannot access a property or method of a null object reference.
at MagiTest_fla::MainTimeline/frame1()[MagiTest_fla.MainTimeline::frame1:27]"
frame1:27 is:
magibatClip.magiDown.addEventListener(c, unTake);
Most likely, it's the first mistake you pointed out (declared, but not instantiated). I read an older answer you gave to another user, and I speculated it is that, but I still don't understand that.
It went something like this from what I read:
var someMC:MovieClip = new MovieClip();
But I still don't seem to get it to work as I don't really understand it. (Sorry for my uselessness).
Copy link to clipboard
Copied
If those are objects that you manually placed on the stage then it will not be the first item in the list.
Before line 27 try adding a few traces and see where is comes up with a null (or errs again)
trace("magibatClip: ", magibatClip);
trace("magiDown: ", magibatClip.magiDown);
trace("c: ", c);
Copy link to clipboard
Copied
magibatClip: [object myMagiClip]
magiDown: null
c: click
So the null is "magiDown".
Copy link to clipboard
Copied
Make sure you assigned that instance name to whatever object is inside magibatClip that you intend to be magiDown. Make sure that same object is not somewhere down the timeline of magibatClip when that code executes - it needs to be present. If that object animates into place, make sure you assigned instance names to it in all keyframes.
Copy link to clipboard
Copied
I've checked them and they all look like they have their instance name where they are supposed to be. Also this is all I have currently on the timeline (above) and inside the movie clip (below). Inside the clip are the buttons and there aren't any buttons or clips there.
Copy link to clipboard
Copied
Which frame is the button in that comes up null?
Copy link to clipboard
Copied
The button is in frame #2 inside the movie clip.
Copy link to clipboard
Copied
That is likely the problem then - see item 3 of the list I provided. If the code is executing while that movieclip is still in frame 1, which it most likely is when the file starts running, then it cannot target an object in frame 2.
Copy link to clipboard
Copied
One way around this is to have that button in frame 1 but make it invisible in frame 1 and visible in frame 2. YOu can use the visible property and set it to true or false as needed.
Copy link to clipboard
Copied
I'm going to sound really dumb right now, and I'd like to apologize for it.. OK I made it invisible in frame 1, but that made it unclickable. Then I made it visible, but when clicked it turned invisible and went straight to frame 2, but the next button wouldn't appear. Sorry for being such a noob in flash.
Copy link to clipboard
Copied
Yes, an invisible object cannot be clicked. If you only want it to be interactive in frame 2 then that should not be a problem. It is when you get to frame 2 that you want to turn it visible. You can do that either by making it visible in whatever function moves that movieclip to frame 2 or within the movieclip itself you can have commands in frames 1 and 2 that control its visibility.
Copy link to clipboard
Copied
Aaaaaaaaaaaand I made it work. Thank you Ned. Greatly appreciate your help and patience. With that I even made it work with the array. Thanks again.
Copy link to clipboard
Copied
You're welcome
Find more inspiration, events, and resources on the new Adobe Community
Explore Now