Hey,
I need help to understand what's wrong and what to do in this situation:
i'm building a website with 5 menuBtns and 5 frameLabels gotoAndStop . The problem is with 2 btns > on CTRL+ENTER when i click on those 2 i get this error : TypeError: Error #1009: Cannot access a property or method of a null object reference. .. it took me on the framelabel of the btn but the animations and actions that i have there don't work. . What can i do to prevent this or fix it ? pls help me
This is the code for my btns: >>problem btns are weDance and inFan !
stop();
// handle events for menu btns
weDance_btn.addEventListener(MouseEvent.CLICK, clickWedance);
clubSpace_btn.addEventListener(MouseEvent.CLICK, clickClubSpace);
inFan_btn.addEventListener(MouseEvent.CLICK, clickInFan);
outOfSpace_btn.addEventListener(MouseEvent.CLICK, clickOutOfSpace);
karnivale_btn.addEventListener(MouseEvent.CLICK, clickCarnivale);
function clickWedance(evtObj:MouseEvent) {
//trace shows what's happening .. in the output window
trace("The wedance btn was clicked!");
gotoAndStop("weDance");
}
function clickClubSpace(evtObj:MouseEvent) {
//trace shows what's happening .. in the output window
trace("The clubspace btn was clicked!");
gotoAndStop("clubSpace");
}
function clickInFan(evtObj:MouseEvent) {
//trace shows what's happening .. in the output window
trace("The INFAN btn was clicked!");
gotoAndStop("inFan");
}
function clickOutOfSpace(evtObj:MouseEvent) {
//trace shows what's happening .. in the output window
trace("The outofspace btn was clicked!");
gotoAndStop("outOfSpace");
}
function clickCarnivale(evtObj:MouseEvent) {
//trace shows what's happening .. in the output window
trace("The carnivale btn was clicked!");
gotoAndStop("karnivale");
}
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.
thnk you. i did that :
The INFAN btn was clicked!
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at qqqqq_fla::MainTimeline/frame160()[qqqqq_fla.MainTimeline::frame160:1 ]
at flash.display::MovieClip/gotoAndStop()
at qqqqq_fla::MainTimeline/clickInFan()[qqqqq_fla.MainTimeline::frame1:3 0] >>>>>>>this is whats in this line " gotoAndStop("inFan"); "
The wedance btn was clicked!
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at qqqqq_fla::MainTimeline/frame1()[qqqqq_fla.MainTimeline::frame1:48] >>>>>>>>>> -//- " fbkWeDance_btn.addEventListener(MouseEvent.CLICK, clickFbk); "
at flash.display::MovieClip/gotoAndStop()
at qqqqq_fla::MainTimeline/clickWedance()[qqqqq_fla.MainTimeline::frame1 :16] >>>>>>>>>> " gotoAndStop("weDance"); "
Here is how i assigned my framelabels and menu to understand :
layer>Actions/Labels>frame1 weDanceLBL frame20 clubSpaceLBL and so on... ON THIS LAYER is only code nothing else.
then i created folders with menu sections
folder inFan>2layers > Actions and menu items (here i have 2 btns and 2 mc animation)
i have this code in frame 160 of inFan page layer for the mc anim and btns
inFan2_btn.addEventListener(MouseEvent.CLICK, toggleContent3);
function toggleContent3(event:MouseEvent) {
if (toggleScreen3.currentFrame == 1) {
toggleScreen3.gotoAndPlay(2);
} else {
toggleScreen3.gotoAndPlay(21);
}
}
inFan1_btn.addEventListener(MouseEvent.CLICK, toggleContent4);
function toggleContent4(event:MouseEvent) {
if (toggleScreen4.currentFrame == 1) {
toggleScreen4.gotoAndPlay(2);
} else {
toggleScreen4.gotoAndPlay(21);
}
}
Thank You!
It is really hard to read what you just posted. The first error seems to be indicating the problem is in frame 160, line 1, not frame 1 line 30. The problemed line is always the first in the error... the rest are just identifying the trail back to what led to encountering that line.
Just as an example, if the following line is indicated as being the problem...
fbkWeDance_btn.addEventListener(MouseEvent.CLICK, clickFbk);
then fbkWeDance_btn does not exist as far as that line sees it. It's up to you to figure out why... different frame, misspelled name, no name, etc...
Thanks for ur info , i'm working on it.
I want to ask u something else if u want to give me a sugestion of how to do it :
So i have the site with 5 pages/Lbls ; I want to make an intro animation for the site with a logo animated and as soon the animation ends , beneath it should appear 2 btns(language btns english/other) [this i know how to do] ; Now what i'm thinking to do is this : to dublicate each page on a different keyframe and assign to it frame Lbl_english_page1 ; Lbl_english_page2 ; Lbl_english_page3 ;Lbl_english_page4 ;Lbl_english_page5 , and the other pages > name frame Lbl_other_page1 ,Lbl_other page2..etc. So when i press the english butn to take me to the framelbl eng Keyframe and same for the other language buton. And one more thing, if i'm doing it this way it means that each menu button to have a duplicate and different instance names so i can then target them to the specific language page ... hope u understand.
What's your opinion, is it ok like that or is there's a better way to do that ?
Thanks!
North America
Europe, Middle East and Africa
Asia Pacific