Copy link to clipboard
Copied
hi everyone!
I'm starting to learn how to work with flash, and i can't seem to get over this damn error...
Can somebody please look at my code and tell me what I'm doing wrong?
I'm getting the error for lines 21 and 22.
Thanks a lot!
Yep... "CLICK", not "Click"
You didn't recognize it but the error message probably changed since fixing the spelling.... but I think now you'll find you are still not getting what you expect due to other typos/copy-paste errors.
In the future, if you get errors be sure to provide the entire error messages in your posting
Copy link to clipboard
Copied
cast those obects explicitly. for example, if they are SimpleButton's import that class and use:
SimpleButton(startPage.HillButton).addEventListener(etc...)
also, you should use the parantheses when you're creating new objects:
startPage=new StartPage();
etc
Copy link to clipboard
Copied
The error is likely indicating that as far as the compiler sees it, the two objects you are trying to target in those lines do not exist. Make sure they exist in a current frame when that code executes and check instance names.
Copy link to clipboard
Copied
Thank you both for you answers, unfortunately the problem remains...
I changed the code as kglas suggested:
but that didn't help...so i guss the problem is intance names
I'm not sure i fully comprehend the concept, maybe through the screenshots you can tell me whats wrong:
thats the .fla file (the startPage):
and that the relevant part of the library:
Can you spot the probelm?
Thanks guys!
Copy link to clipboard
Copied
Instance names are the names you assign to the objects in the Properties panel, not the names you see in the library. THe code uses those names to target the objects.
Did you manually place the hill and pond button objects inside the startPage object? If so, you need to assign them instance names (same with the startPage).
If you are assigning those as class names for the objects then you should not use them as instance names... normally, class names start with capital letters and instance names don't, so I'd recommend changing the instance names to "hillButton" and "pondButton"
If you did not manually place those buttons inside the startPage object I have a different explanation to provide.
Copy link to clipboard
Copied
Yeah I manually added the buttons.
I assinged the instance names for the buttons on the startPage:
But I'm still getting the 1119 for the lines that add the event listner...What am I missing..?
Copy link to clipboard
Copied
If the image shows the instance names, and you have not changed the code, then you misspelled the instance names in the code.
Copy link to clipboard
Copied
I changed to code, the names are the same, still I'm getting that damn error 😕
I noticed that when I change the buttons names in the SimpleButton(...) it does't change anyting, but if I change the startPage to something else, it generates additional error, it's like it doesn't recognize that there are buttons on the StartPage...
If you have any other ideas, I'll be glad to hear them, if not I'll earase the whole thing and start a new one, cause I really don't know where I messed up...
Anyways, thanks!
Copy link to clipboard
Copied
Since you have a way of mixing up spelling things different ways, like you just did with startPage/StartPage, I still suspect you have naming errors.
To rule that out, try using the trace function before those two lines to see if they trace the objects properly.
trace(startPage); // should output something like [object MovieClip]
trace(startPage.hillButton); // should output something like [object SimpleButton]
trace(startPage.pondButton); // ditto
Copy link to clipboard
Copied
"I still suspect you have naming errors."
(or, those buttons don't exist in frame one of startPage.)
Copy link to clipboard
Copied
I ran trace and got:
[object StartPage]
[object HillButton]
[object PondButton]
Copy link to clipboard
Copied
Show the code as youy have it now, and the complete error message(s)
Copy link to clipboard
Copied
Any ideas?
Copy link to clipboard
Copied
Yep... "CLICK", not "Click"
You didn't recognize it but the error message probably changed since fixing the spelling.... but I think now you'll find you are still not getting what you expect due to other typos/copy-paste errors.
In the future, if you get errors be sure to provide the entire error messages in your posting
Copy link to clipboard
Copied
Yeah that solved it!
Though, as you said, now I'm getting:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main()
what eve the hell that means ...but hey, thats a start, thanks a lot to both of you guys!
Btw, if you have any idea what can cause that error, please feel free to share
Copy link to clipboard
Copied
It's always better to start new postings for new problems... they get noticed faster. The 1009 error is more definitively what I described for the 1119 error (which can cover a number of issues)....
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 if timeline code) which will help you isolate which object is involved.
Copy link to clipboard
Copied
Yeah that solved it! After is showed the line it was a quick fix...
It was a slight misspell! ...
Works like a chram now!
Thanks a lot! To both of you guys!!!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now