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

Error with buttons

Guest
May 19, 2015 May 19, 2015

Copy link to clipboard

Copied

I have a game with multiple frames (Menu, Instructions and Game). I have a button in frame 1(menu) to take me to frame 2 and 3, the one for frame 2(game) works like a charm, the one for frame 3 on the other hand, sends me an error. Frame 2 is complete, all the coding is done for it, all I have in frame 3 is a button. I have tested the animation with debug thing, and the error points too the button itself. The button is custom made and imported into the library. However, if I use one of the buttons "premade" in flash, it works fine, it wouldnt be the end of the world if I used their buttons, but mine are prettier, anyone have any idea?

this is the error

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

  at NimGame_fla::MainTimeline/frame1()

  at flash.display::MovieClip/gotoAndStop()

  at NimGame_fla::MainTimeline/toMenu()

TOPICS
ActionScript

Views

620

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

Community Expert , May 21, 2015 May 21, 2015

i don't download and correct files unless i'm hired.  free help i offer via the adobe forums and this problem is solvable via the fourms.

it would be faster to pay me to fix the problem but, if you're patient, you should be able to solve this free of charge.

delete your problematic button everywhere in your project.

create a new layer on the main timeline that extends to the last frame of the main timeline.

then drag the problematic button from the library to the new layer's frame 1 of the main tim

...

Votes

Translate

Translate
Community Expert ,
May 19, 2015 May 19, 2015

Copy link to clipboard

Copied

whatever you think is referencing your button, isn't.  it's not possible to say more because of lack of info.

you could post the line of code triggering the error for more info.  if you button is part of a tween, that can be problematic.

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
Guest
May 19, 2015 May 19, 2015

Copy link to clipboard

Copied

I believe this is the line that is causing the error. And no there is no tween. All the button is doing so far is sitting in a fram. I have code in the actions window for it so that it will proceed the animation to specified frames, as seen in code below.

button_error.PNG

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
Community Expert ,
May 19, 2015 May 19, 2015

Copy link to clipboard

Copied

you should tick 'permit debugging' so you're certain that's the line causing the error, or comment that out and see if the error resolves.

if that's the problematic line, btn_AuJeu doesn't exist when your code executes.

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
Guest
May 19, 2015 May 19, 2015

Copy link to clipboard

Copied

I did the debuggin, and thats the line causing the error. But that button does exist, thats why im confused. Although if i use a button that flash provides, it works, does that mean there is a property im not associating that button with properly? If so would you happen to know this property?

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
Community Expert ,
May 19, 2015 May 19, 2015

Copy link to clipboard

Copied

assigning that reference correctly depends on how that object is created.

if you used code, show the code.  if you dragged a symbol from your library to the stage or created that object on-stage, while the object is selected assign its name in the properties panel.

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
Guest
May 19, 2015 May 19, 2015

Copy link to clipboard

Copied

I have it as a symbol in my library.

Here is the button is library :

instructions_btn.PNG

And here are the properties for that button :

instructions_btn_properties.PNG

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
Community Expert ,
May 20, 2015 May 20, 2015

Copy link to clipboard

Copied

open the properties panel so it's visible>click that button that's on stage (to select it)>check the name property of your button.

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
Guest
May 20, 2015 May 20, 2015

Copy link to clipboard

Copied

When you say the name property of the button, I assume you mean the instance name? If so this is the instance name :"btn_Instructions"

Here is a picture :

on_screen_properties.png

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
Community Expert ,
May 20, 2015 May 20, 2015

Copy link to clipboard

Copied

now, copy that instance name and paste it into line 1 of the same frame shown in message 8.  then surround the pasted name by trace( and ), so you can trace the object.  test.

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
Guest
May 20, 2015 May 20, 2015

Copy link to clipboard

Copied

Okay, so I traced it twice, first when the game loads, the it traces "[object SimpleButton]". Which is what it is supposed to be I believe? And the second time it is traced after the button in the instructions frame is clicked (so when it is supposed to go back to menu from the instructions frame, that is also when the error occurs) and it traces nul, which is where the error is coming from, but why?

trace.PNG

trace2.PNG

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
Community Expert ,
May 20, 2015 May 20, 2015

Copy link to clipboard

Copied

if you're changing to a frame where your button no longer exists, that's a problem.

don't remove it in the ide.  use removeChild() (and then addChild() when needed), to remove it.  or use its visible property.

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
Guest
May 21, 2015 May 21, 2015

Copy link to clipboard

Copied

Am I not able to reference it through another frame? Even if it exists in another frame within the same timeline? What do you mean by "ide" ?

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
Community Expert ,
May 21, 2015 May 21, 2015

Copy link to clipboard

Copied

you can reference it for as long as it exists.  if you do something so it no longer exists, then the previous reference is lost.

per google

ide = An integrated development environment (IDE) or interactive development environment is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of a source code editor, build automation tools and a debugger.

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
Guest
May 21, 2015 May 21, 2015

Copy link to clipboard

Copied

Okay, so I must be accidentally doing something for it to no longer exist? As far as I know I haven't written anything that would cause it to no longer exist. The only code that runs from frame 1 to frame 3 is this :

exists..PNG

Any ideas? If not would there be another method to accomplish this? (frame hopping with a button)

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
Community Expert ,
May 21, 2015 May 21, 2015

Copy link to clipboard

Copied

it's not a code issue.  it's the way you set up your fla.  ie, your button does not exist (unchanged) in all frames of your main timeline.

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
Guest
May 21, 2015 May 21, 2015

Copy link to clipboard

Copied

So what would you suggest I do to fix it? Would it work if I have the button in all frames but only visible in the ones I want it to be?

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
Community Expert ,
May 21, 2015 May 21, 2015

Copy link to clipboard

Copied

yes, that's what i suggested in message 11.

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
Guest
May 21, 2015 May 21, 2015

Copy link to clipboard

Copied

If I do that it sends a message saying it cannot do that because the object is null.

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
Guest
May 21, 2015 May 21, 2015

Copy link to clipboard

Copied

This might be asking a lot of you, and would totally understand if you didn't want to do this. If I shared the files with you over dropbox would you be able to look at it and see what you can do? I am very new to this (as you can most likely tell) and still have very limited knowledge to what I am doing. I might be over my head with this frame hopping.

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
Community Expert ,
May 21, 2015 May 21, 2015

Copy link to clipboard

Copied

i don't download and correct files unless i'm hired.  free help i offer via the adobe forums and this problem is solvable via the fourms.

it would be faster to pay me to fix the problem but, if you're patient, you should be able to solve this free of charge.

delete your problematic button everywhere in your project.

create a new layer on the main timeline that extends to the last frame of the main timeline.

then drag the problematic button from the library to the new layer's frame 1 of the main timeline and assign the problematic instance name.

test.

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
Guest
May 21, 2015 May 21, 2015

Copy link to clipboard

Copied

Fair enough, very fair indeed.

I see what you are doing, and with what I have done so far everything seems to be working. Is this because now the button is available everywhere on the timeline and not restricted to the one frame it previously was?

And with this solution it just becomes a matter of playing with the visibility of the buttons in the actions panel?

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
Community Expert ,
May 21, 2015 May 21, 2015

Copy link to clipboard

Copied

yes, the button continues to exist at all times, so that code will always work.

and yes, now you need to add keyframes where you want your button to 'disappear' and where you want it to reappear (if that's not just at frame 10.

what you cannot do is remove the button from the stage at one keyframe and then add it to the stage in another keyframe (even with the same instance name) and expect your reference to continue to work.

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
Guest
May 21, 2015 May 21, 2015

Copy link to clipboard

Copied

Well thank you very much for your time and your help kglad. I appreciate it! Thank you!

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
Community Expert ,
May 21, 2015 May 21, 2015

Copy link to clipboard

Copied

LATEST

you're welcome.

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