A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: AS3 controlling timeline - PLEASE HELP!!!

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    2

    AS3 controlling timeline - PLEASE HELP!!!

    Just started with AS3 and I'm pulling my hair out!

    I have a complex Flash file with a ton of buttons and timeline references from within MCs. I pulled out one button and created a simple file for troubleshooting and I am STUCK!

    I have a main timeline with movie clips at various points. Inside those MCs I need to link BACK to the main timeline at defined labels - in my example, it's a frame labeled: LOCATIONS. Here is what I have inside the MC_About:


    btn_locations.addEventListener(MouseEvent.CLICK, btnLocations);
    function btnLocations(e:MouseEvent):void
    {
    MovieClip(this.root).gotoAndPlay("LOCATIONS");
    }


    And there is a button with this instance name: btn_locations

    When that button is clicked, it is supposed to go back to the main (root) timeline and play at the label: LOCATIONS

    BUT, I keep getting this error:


    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at TEST_fla::MC_About_1/frame1()

    PLEASE HELP! I am under the gun and need to get a working file out the door tomorrow afternoon. PLEASE...

    Here's my TEST file:
    TEST.zip

    Thank you.

    Dennnnis

  2. #2
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    Just move the code on frame1 of MC_About to frame 29.
    You have to do this because your code refers to an object called btn_locations but it doesn't exist yet. It doesn't get created until frame 29 so it's only safe to reference it on or after that frame.

  3. #3
    Senior Member
    Join Date
    Aug 2006
    Posts
    322
    First frame Code:

    PHP Code:
    stop();

    function 
    look_up(location) {
        
    gotoAndStop(location);
    }
    function 
    btnLocations(evt:MouseEvent):void {
        
    look_up(evt.target.location);
    }

    btn1.location="market";
    btn1.label.text="Market";
    btn1.addEventListener(MouseEvent.CLICKbtnLocations); 
    In other frames just put the button number and the location:

    PHP Code:
    btn30.location="home";
    btn30.label.text="Home";
    btn30.addEventListener(MouseEvent.CLICKbtnLocations); 

    marlopax

  4. #4
    Junior Member
    Join Date
    Mar 2013
    Posts
    2

    Red face

    Quote Originally Posted by jAQUAN View Post
    Just move the code on frame1 of MC_About to frame 29.
    You have to do this because your code refers to an object called btn_locations but it doesn't exist yet. It doesn't get created until frame 29 so it's only safe to reference it on or after that frame.
    THANK YOU so much! So simple, but Flash's error codes are so confusing. Waking up and figuring this out has made my morning! Thank you again.

    Dennnnis

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center