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

Null object reference

Enthusiast ,
Oct 28, 2009 Oct 28, 2009

Converting an AS2 project to AS3 , in the main timeline of the AS2 I had a layer with all the navigation btns. The buttons were not on the first frame but the 30th frame as they appear after an intro finishes. When I added the AS to the 1st frame of the timeline in AS3 I got a null object reference error which I later found out happens because the button layer is blank in the first frame of the main timeline. The button functions will only work if I move the btns to frame one which does me no good as they need to appear in frame 30.

What do I do in this case?

rdee

TOPICS
ActionScript
770
Translate
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
Guest
Oct 28, 2009 Oct 28, 2009

what you can do if you are not able to change the code, is have an instance of your 30 frame buttons instance and place it on frame 1.  tell each button.visible=false and button.mouseEnabled=false..  then on frame 30 just turn all falses to true.

Code can not be targeted to an object if it does not exist,  So force it to exist or take out the code which references the buttons and add them on frame 30

Translate
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 ,
Oct 28, 2009 Oct 28, 2009

Either move the buttons to frame 1 and make them invisible until frame 30, or put the button code in frame 30.  I'd go with putting the code where the buttons are myself, but it's a matter of preference.

Translate
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
Contributor ,
Oct 28, 2009 Oct 28, 2009

Are you using a DocumentClass? If not, just move the code to the frame withthe buttons.

Other option is to create a custom class for each button so the buttons initialize themselves when they appear on stage. This would involve writing a class and set the buttons to export for ActionScript under the same name as the Class.

There's more ways to go, but that would be (and was) my first thought.

Translate
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
Enthusiast ,
Oct 28, 2009 Oct 28, 2009

Thanks for the replies, what has worked fine is just adding the code to the actions layer frame the buttons appear in and that did the trick. I realized that converting a site from AS2 to AS3 is a good way to compare and see the differences.

Instead of starting a new discussion I thought I would ask here about coding the following :

a button in a movieclip calling a "mailTo:" function

The original AS2 ran frame labels and called a loadmovie function off a button into level1 of frame "gallery"(its a photogallery)

in order for the photogallery to only appear in the 'gallery " frame there were "unloadmovie functions in all the rest of the navigation buttons so if a user clicked "home" the button function was a gotoAndPlay "home" and unloadMovie,1 follow?

I need to achieve these two functions in AS3

thanks so much for the help.

Translate
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 ,
Oct 28, 2009 Oct 28, 2009

You are better off starting new postings for each different question.  The discussion can end up going in multiple directions and will likely end up confusing you and anyone trying to help you... you may think one thing is being discussed while it's another (same for the folks helping)..

I think for the first one you are mentioning you need to look into using navigateToURL() instead of AS2's getURL.

Translate
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
Enthusiast ,
Oct 28, 2009 Oct 28, 2009
LATEST

Will start another post for each , thx

rrr

Translate
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