Skip navigation
Currently Being Moderated

error 1009 code cant see my buttons

Apr 21, 2012 9:51 PM

Tags: #error #as3 #3.0 #actionscript

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

          at ife3m_fla::MainTimeline/frame41()[ife3m_fla.MainTimeline::frame41:9]

 

Code of frame 41

 

 

 

line 9 boton2_btn.addEventListener(MouseEvent.MOUSE_DOWN, playSplitDuct);

 

 

               function playSplitDuct(event:MouseEvent):void{

 

          }

 

On the time line i have alone on its layer i have the boton2_btn placed where I need it. It first appears on frame 15 with brightness to the max then i do a classic tween to end up with the button as i want it on frame 19. I have several buttons with that same arrangment none of them can be recognized by the code.

 

How can i make sure the buttons are instantiated correctly?

Could the tween have anything to do with problem?

Or is ther a problem if i have mc inside my button?

 

Thanks f

 
Replies
  • kglad
    72,322 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 21, 2012 10:05 PM   in reply to shenaness

    if you're using cs5, there's a bug that invalidates instance names when objects are used in timeline tweens.

     
    |
    Mark as:
  • kglad
    72,322 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 22, 2012 6:53 AM   in reply to shenaness

    the best way is to avoid using timeline tweening.

     

    but once you are in the middle of a project that may have a lot of timeline tweening you can work around the problem by removing that instance name (boton2_btn) from all the existing instances, then create a new layer above your button and, in the frame where your button first exists, add a keyframe (if that's not frame 1).  drag a copy of your button to the stage, position it over your existing button and assign its name to boton2_btn and its alpha to 0. 

     

    if there are certain frames (possibly including the first) where you don't want boton2_btn to be clickable, use actionscript to assign its visible (or mouseEnabled) property to false.  in frames where you want it to be clickable assign it visble (or mouseEnabled) property to be true.

     
    |
    Mark as:
  • kglad
    72,322 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 22, 2012 7:12 PM   in reply to shenaness

    not necessarily frame 1, but every frame that contains that object should have that instance name.  and the all the keyframes need to be created after that initial one.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points