• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

TypeError: Error #1009: Cannot access a property or method of a null object reference.

New Here ,
Mar 27, 2011 Mar 27, 2011

Copy link to clipboard

Copied

I've designed a wesbite for a friend in Flash, having never used the programme for anything before other than an image sequencer for animation. The website is here http://my-jordan.org/

When I run the swf file on my computer it seems to work fine, every button, every animation runs smoothly. When I use the test movie option in Flash it still runs fine, but I get this error stack when I click the Contact button.

TypeError: Error #1009: Cannot access a property or method of a null object reference.

     at MyJordanAgain_fla::MainTimeline/frame35()

     at flash.display::MovieClip/gotoAndStop()

     at MyJordanAgain_fla::MainTimeline/contactBtnClick()

Here's the script relating to it:

{

     contactBtn.addEventListener(MouseEvent.CLICK,contactBtnClick);

function contactBtnClick(m:MouseEvent):void

{

     homeBtn.visible=true;

     dinnerAtHomeBtn.visible=true;

     activitiesBtn.visible=true;

     sightsBtn.visible=true;

     sampleItinBtn.visible=true;

     contactBtn.visible=true;

     enterBtn.visible=false;

     upBtn1.visible=false;

     downBtn1.visible=false;

     petraBtn.visible=false;

     madabaBtn.visible=false;

     karakBtn.visible=false;

     shobakBtn.visible=false;

     ajlounBtn.visible=false;

     wadirumBtn.visible=false;

     ammanBtn.visible=false;

     jerashBtn.visible=false;

     gotoAndStop("contactPage");

}

}

And here's the only sript to be found on frame 35:

stop();

sampleItinScroll.scrollTarget = sampleItinTxt;

I don't know what the error stack is trying to tell me. Help.

I also put the website up despite the error, because the swf worked fine. But as you can see, the website breaks down and stops working at the Sights button. I assume this is also something to do with the unsolved error...

Thank you very much for any help you can give.

TOPICS
ActionScript

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Mar 27, 2011 Mar 27, 2011

The second line of code you show for frame 35 would be the most suspect due to the nature of the 1009 error.

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 not in the display list
- 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

...

Votes

Translate

Translate
LEGEND ,
Mar 27, 2011 Mar 27, 2011

Copy link to clipboard

Copied

The second line of code you show for frame 35 would be the most suspect due to the nature of the 1009 error.

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 not in the display list
- 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 confirm which line is involved.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 27, 2011 Mar 27, 2011

Copy link to clipboard

Copied

Perfect. Thank you. I had no idea that that debugging option existed. Very useful thing to know. The error stack is history.

I don't suppose you could give me an idea where to (begin to) look at why it might not be running properly once uploaded onto the server?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 27, 2011 Mar 27, 2011

Copy link to clipboard

Copied

I can't tell much without knowing more about what isn't running properly.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 27, 2011 Mar 27, 2011

Copy link to clipboard

Copied

It's on the Sights page that everything after stops working. http://my-jordan.org/

The two buttons for up and down should scroll through pictures, but the pictures aren't present at all, and the buttons shouldn't scroll through the pages, just the pictures. It does this correctly on my computer, it's only once uploaded it goes wrong.

{

     sightsBtn.addEventListener(MouseEvent.CLICK,sightsBtnClick);

function sightsBtnClick(m:MouseEvent):void

{

     homeBtn.visible=true;

     dinnerAtHomeBtn.visible=true;

     activitiesBtn.visible=true;

     sightsBtn.visible=true;

     sampleItinBtn.visible=true;

     contactBtn.visible=true;

     enterBtn.visible=false;

     upBtn1.visible=true;

     downBtn1.visible=true;

     petraBtn.visible=true;

     madabaBtn.visible=true;

     karakBtn.visible=true;

     shobakBtn.visible=true;

     ajlounBtn.visible=true;

     wadirumBtn.visible=true;

     ammanBtn.visible=true;

     jerashBtn.visible=true;

     gotoAndStop("sightsPage");

}

}

{

     petraBtn.addEventListener(MouseEvent.CLICK,petraBtnClick);

function petraBtnClick(m:MouseEvent):void

{

     gotoAndStop("petra");

}

}

{

     madabaBtn.addEventListener(MouseEvent.CLICK,madabaBtnClick);

function madabaBtnClick(m:MouseEvent):void

{

     gotoAndStop("madaba");

}

}

{

     karakBtn.addEventListener(MouseEvent.CLICK,karakBtnClick);

function karakBtnClick(m:MouseEvent):void

{

     gotoAndStop("karak");

}

}

{

     shobakBtn.addEventListener(MouseEvent.CLICK,shobakBtnClick);

function shobakBtnClick(m:MouseEvent):void

{

     gotoAndStop("shobak");

}

}

{

     ajlounBtn.addEventListener(MouseEvent.CLICK,ajlounBtnClick);

function ajlounBtnClick(m:MouseEvent):void

{

     gotoAndStop("ajloun");

}

}

{

     jerashBtn.addEventListener(MouseEvent.CLICK,jerashBtnClick);

function jerashBtnClick(m:MouseEvent):void

{

     gotoAndStop("jerash");

}

}

{

     wadirumBtn.addEventListener(MouseEvent.CLICK,wadirumBtnClick);

function wadirumBtnClick(m:MouseEvent):void

{

     gotoAndStop("wadirum");

}

}

{

     ammanBtn.addEventListener(MouseEvent.CLICK,ammanBtnClick);

function ammanBtnClick(m:MouseEvent):void

{

     gotoAndStop("amman");

}

}

{

upBtn1.addEventListener(MouseEvent.CLICK,backward);

downBtn1.addEventListener(MouseEvent.CLICK,forward);

function forward (event:MouseEvent):void{

   if(currentFrameLabel == "amman2"){

      gotoAndStop("petra");

   }else{

      nextFrame();

   }

}

}

function backward (event:MouseEvent):void{

   if(currentFrameLabel == "petra"){

     gotoAndStop("amman2");

   }else{

     prevFrame();

   }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 27, 2011 Mar 27, 2011

Copy link to clipboard

Copied

The code doesn't look wrong, though it doesn't explain anything about how the design is done, so there's really no telling at this point what the problem might be.  You might try using currentLabel instead of currentFrameLabel unless you know for sure that you can only be in the frame that has that label when you test for it.

The fact that your Sights page controls seem to exist in parallel with the other sections of the site has me wondering just what you have laid out along your timeline.  If you can show a screenshot of that and explain how the design is intended to work that could help lead to solving something.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 27, 2011 Mar 27, 2011

Copy link to clipboard

Copied

Picture 2.png

I tried to put the buttons for the sights page on the page itself, but I ran into too many problems that I wasn't equipped to deal with. It seemed simpler to keep all the buttons in one frame on one layer.

ActionScript is the script for the whole site. The script is posted below.

Button Names is simply the text over the buttons at the top of the page. I'm not sure why I put them in a separate layer, but they don't seem to do any harm there.

Buttons, has all the buttons, except for the text scrolls.

Page Actions, all of them have the stop(); code, except for the pages with scroll bars, where the scroller code is underneath the stop();.

Tags is just the frame labels for buttons on Sights page.

Sights Text and Sights Photos are just the photos and text that should be there when the up and down buttons are pressed.

Pages are the pages. Each one is labelled for the buttons.

Background's backgrounds.

Does it make sense?

AS3 from the ActionScript layer

     enterBtn.visible=true;

     homeBtn.visible=false;

     dinnerAtHomeBtn.visible=false;

     activitiesBtn.visible=false;

     sightsBtn.visible=false;

     sampleItinBtn.visible=false;

     contactBtn.visible=false;

     upBtn1.visible=false;

     downBtn1.visible=false;

     petraBtn.visible=false;

     madabaBtn.visible=false;

     karakBtn.visible=false;

     shobakBtn.visible=false;

     ajlounBtn.visible=false;

     wadirumBtn.visible=false;

     ammanBtn.visible=false;

     jerashBtn.visible=false;

{

     enterBtn.addEventListener(MouseEvent.CLICK,enterBtnClick)

function enterBtnClick(m:MouseEvent):void

{

     homeBtn.visible=true;

     dinnerAtHomeBtn.visible=true;

     activitiesBtn.visible=true;

     sightsBtn.visible=true;

     sampleItinBtn.visible=true;

     contactBtn.visible=true;

     enterBtn.visible=false;

     upBtn1.visible=false;

     downBtn1.visible=false;

     petraBtn.visible=false;

     madabaBtn.visible=false;

     karakBtn.visible=false;

     shobakBtn.visible=false;

     ajlounBtn.visible=false;

     wadirumBtn.visible=false;

     ammanBtn.visible=false;

     jerashBtn.visible=false;

     gotoAndStop("homePage")

}

}

{

     homeBtn.addEventListener(MouseEvent.CLICK,homeBtnClick);

function homeBtnClick(m:MouseEvent):void

{

     homeBtn.visible=true;

     dinnerAtHomeBtn.visible=true;

     activitiesBtn.visible=true;

     sightsBtn.visible=true;

     sampleItinBtn.visible=true;

     contactBtn.visible=true;

     enterBtn.visible=false;

     upBtn1.visible=false;

     downBtn1.visible=false;

     petraBtn.visible=false;

     madabaBtn.visible=false;

     karakBtn.visible=false;

     shobakBtn.visible=false;

     ajlounBtn.visible=false;

     wadirumBtn.visible=false;

     ammanBtn.visible=false;

     jerashBtn.visible=false;

     gotoAndStop("homePage");

}

}

{

     dinnerAtHomeBtn.addEventListener(MouseEvent.CLICK,dinnerAtHomeBtnClick);

function dinnerAtHomeBtnClick(m:MouseEvent):void

{

     homeBtn.visible=true;

     dinnerAtHomeBtn.visible=true;

     activitiesBtn.visible=true;

     sightsBtn.visible=true;

     sampleItinBtn.visible=true;

     contactBtn.visible=true;

     enterBtn.visible=false;

     upBtn1.visible=false;

     downBtn1.visible=false;

     petraBtn.visible=false;

     madabaBtn.visible=false;

     karakBtn.visible=false;

     shobakBtn.visible=false;

     ajlounBtn.visible=false;

     wadirumBtn.visible=false;

     ammanBtn.visible=false;

     jerashBtn.visible=false;

     gotoAndStop("dinnerAtHomePage");

}

}

{

     activitiesBtn.addEventListener(MouseEvent.CLICK,activitiesBtnClick);

function activitiesBtnClick(m:MouseEvent):void

{

     homeBtn.visible=true;

     dinnerAtHomeBtn.visible=true;

     activitiesBtn.visible=true;

     sightsBtn.visible=true;

     sampleItinBtn.visible=true;

     contactBtn.visible=true;

     enterBtn.visible=false;

     upBtn1.visible=false;

     downBtn1.visible=false;

     petraBtn.visible=false;

     madabaBtn.visible=false;

     karakBtn.visible=false;

     shobakBtn.visible=false;

     ajlounBtn.visible=false;

     wadirumBtn.visible=false;

     ammanBtn.visible=false;

     jerashBtn.visible=false;

     gotoAndStop("activitiesPage");

}

}

{

     sightsBtn.addEventListener(MouseEvent.CLICK,sightsBtnClick);

function sightsBtnClick(m:MouseEvent):void

{

     homeBtn.visible=true;

     dinnerAtHomeBtn.visible=true;

     activitiesBtn.visible=true;

     sightsBtn.visible=true;

     sampleItinBtn.visible=true;

     contactBtn.visible=true;

     enterBtn.visible=false;

     upBtn1.visible=true;

     downBtn1.visible=true;

     petraBtn.visible=true;

     madabaBtn.visible=true;

     karakBtn.visible=true;

     shobakBtn.visible=true;

     ajlounBtn.visible=true;

     wadirumBtn.visible=true;

     ammanBtn.visible=true;

     jerashBtn.visible=true;

     gotoAndStop("sightsPage");

}

}

{

     petraBtn.addEventListener(MouseEvent.CLICK,petraBtnClick);

function petraBtnClick(m:MouseEvent):void

{

     gotoAndStop("petra");

}

}

{

     madabaBtn.addEventListener(MouseEvent.CLICK,madabaBtnClick);

function madabaBtnClick(m:MouseEvent):void

{

     gotoAndStop("madaba");

}

}

{

     karakBtn.addEventListener(MouseEvent.CLICK,karakBtnClick);

function karakBtnClick(m:MouseEvent):void

{

     gotoAndStop("karak");

}

}

{

     shobakBtn.addEventListener(MouseEvent.CLICK,shobakBtnClick);

function shobakBtnClick(m:MouseEvent):void

{

     gotoAndStop("shobak");

}

}

{

     ajlounBtn.addEventListener(MouseEvent.CLICK,ajlounBtnClick);

function ajlounBtnClick(m:MouseEvent):void

{

     gotoAndStop("ajloun");

}

}

{

     jerashBtn.addEventListener(MouseEvent.CLICK,jerashBtnClick);

function jerashBtnClick(m:MouseEvent):void

{

     gotoAndStop("jerash");

}

}

{

     wadirumBtn.addEventListener(MouseEvent.CLICK,wadirumBtnClick);

function wadirumBtnClick(m:MouseEvent):void

{

     gotoAndStop("wadirum");

}

}

{

     ammanBtn.addEventListener(MouseEvent.CLICK,ammanBtnClick);

function ammanBtnClick(m:MouseEvent):void

{

     gotoAndStop("amman");

}

}

{

upBtn1.addEventListener(MouseEvent.CLICK,backward);

downBtn1.addEventListener(MouseEvent.CLICK,forward);

function forward (event:MouseEvent):void{

   if(currentFrameLabel == "amman2"){

      gotoAndStop("petra");

   }else{

      nextFrame();

   }

}

}

function backward (event:MouseEvent):void{

   if(currentFrameLabel == "petra"){

     gotoAndStop("amman2");

   }else{

     prevFrame();

   }

}

          

          

{

     sampleItinBtn.addEventListener(MouseEvent.CLICK,sampleItinBtnClick);

function sampleItinBtnClick(m:MouseEvent):void

{

     homeBtn.visible=true;

     dinnerAtHomeBtn.visible=true;

     activitiesBtn.visible=true;

     sightsBtn.visible=true;

     sampleItinBtn.visible=true;

     contactBtn.visible=true;

     enterBtn.visible=false;

     upBtn1.visible=false;

     downBtn1.visible=false;

     petraBtn.visible=false;

     madabaBtn.visible=false;

     karakBtn.visible=false;

     shobakBtn.visible=false;

     ajlounBtn.visible=false;

     wadirumBtn.visible=false;

     ammanBtn.visible=false;

     jerashBtn.visible=false;

     gotoAndStop("sampleItinPage");

}

}

{

     contactBtn.addEventListener(MouseEvent.CLICK,contactBtnClick);

function contactBtnClick(m:MouseEvent):void

{

     homeBtn.visible=true;

     dinnerAtHomeBtn.visible=true;

     activitiesBtn.visible=true;

     sightsBtn.visible=true;

     sampleItinBtn.visible=true;

     contactBtn.visible=true;

     enterBtn.visible=false;

     upBtn1.visible=false;

     downBtn1.visible=false;

     petraBtn.visible=false;

     madabaBtn.visible=false;

     karakBtn.visible=false;

     shobakBtn.visible=false;

     ajlounBtn.visible=false;

     wadirumBtn.visible=false;

     ammanBtn.visible=false;

     jerashBtn.visible=false;

     gotoAndStop("contactPage");

}

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 27, 2011 Mar 27, 2011

Copy link to clipboard

Copied

LATEST

It's got me confused, so here's what I can offer... take your sights sections and make it a movieclip in itself, containing its up/down buttons, such that it only occupies one frame of the main timeline.  That way, you can keep those buttons from telling the main timeline to travel elsewhere, which is what is somehow happening.  Your up/down buttons can work solely within the sights movieclip and cannot then possibly appear in other sections of the site.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines