SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Error #1009

  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2008
    Location
    Albuquerque, NM
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Error #1009

    Hello--I'm wondering if anyone can help me figure out why I'm getting the following error message in my Flash doc:

    "TypeError: Error #1009: Cannot access a property or method of a null object reference. at senses_test_fla::SceneTwo_1/buttonClick()"

    The message appears after I click one of five buttons. Everything seems to work fine--clicking takes me to the frame with the corresponding label, and the animation within each frame plays without a hitch. I've double-checked the buttons to make sure that the instance names match what's in the actionscript.

    Here's my actionscript (3.0):
    Code Actionscript:
    stop();
    function buttonClick(event:MouseEvent):void
    {
    	gotoAndPlay(event.target.name);
     
    	earbtn.enabled = true;
    	eyebtn.enabled = true;
    	handbtn.enabled = true;
    	tonguebtn.enabled = true;
    	nosebtn.enabled = true;
     
    	event.target.enabled = false;
    }
     
    earbtn.addEventListener(MouseEvent.CLICK, buttonClick);
    eyebtn.addEventListener(MouseEvent.CLICK, buttonClick);
    handbtn.addEventListener(MouseEvent.CLICK, buttonClick);
    tonguebtn.addEventListener(MouseEvent.CLICK, buttonClick);
    nosebtn.addEventListener(MouseEvent.CLICK, buttonClick);

    Thanks in advance for your help! Please let me know if you need more information than what I've provided here.

    --J

  2. #2
    SitePoint Guru [Paul Ferrie]'s Avatar
    Join Date
    Oct 2007
    Location
    Glasgow, Scotland, UK
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    trace what event.target.name is and make sure you frame lable resembles that.
    .:To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Glasgow Flasher
    bringmadeleinehome.com

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2008
    Location
    Albuquerque, NM
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the response Paul!

    From what I understand, event.target.name takes the instance name of the button that triggers the "buttonClick" function and turns it into the target--thus clicking on "earbtn" button takes you to the frame with the label "earbtn." As long as the buttons and corresponding frames are named identically, it should work.

    I messed around with the code a bit and found out that the error message disappears if all the ".enabled = true" declarations are removed. I'd like to keep these in--any idea why they might be causing problems?

    Thanks again,

    --J


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •