Skip navigation
Currently Being Moderated

1120:Access of undefined property error

Apr 12, 2009 7:42 PM

I'll try and be clear about my problem. I'm working on a site and have a MovieClip, named "form" on the main timeline that I want to play when a button is clicked. I keep getting this error and it's driving me crazy, I'm obiously missing something. The button instance name is "sub_btn". Below is my code , it's the subscription button code, but not quite sure what's up, I'm not an actionscript guru but am gaining a small understanding of it. If anyone can help that be awesome. Also I have a close button on that movie clip is there a simple close script I can attach. Thanks again.

 

Dt

 

 

 

stop();
import flash.events.MouseEvent;
var getHCSG:URLRequest = new URLRequest("http://www.houstonceliacs.org");
var twitter:URLRequest = new URLRequest("http://www.dggrafix.com/glutenfree/twitter.html");

 


// --- Page Button navigation --- \\

 

home_btn.addEventListener(MouseEvent.CLICK, hClick);
glutenfree_btn.addEventListener(MouseEvent.CLICK, gClick);
menu_btn.addEventListener(MouseEvent.CLICK, mClick);
restaurant_btn.addEventListener(MouseEvent.CLICK, rClick);
contact_btn.addEventListener(MouseEvent.CLICK, cClick);

 

function hClick(event:MouseEvent):void{
    gotoAndPlay("home");
}
function gClick(event:MouseEvent):void{
    gotoAndPlay("glutenfree");
}
function mClick(event:MouseEvent):void{
    gotoAndPlay("menu");
}
function rClick(event:MouseEvent):void{
    gotoAndPlay("restaurants");
}
function cClick(event:MouseEvent):void{
    gotoAndPlay("contact");
}

 

// -- Get URL Button -- \\

 

supportgrp_btn.addEventListener(MouseEvent.CLICK, hcClick);

 

function hcClick(event:MouseEvent):void{
    navigateToURL(getHCSG);
}
twitter_btn.addEventListener(MouseEvent.CLICK, tClick);

 

function tClick(event:MouseEvent):void{
    navigateToURL(twitter);
}

 

// --- Subcribtion Button navigation --- \\

 

sub_btn.addEventListener(MouseEvent.CLICK, clClick);

 

function clClick(event:MouseEvent):void{
    form.play();
}

 
Replies
  • Currently Being Moderated
    Apr 12, 2009 7:57 PM   in reply to csgdon

    Can you provide the complete error message?

     
    |
    Mark as:
  • kglad
    72,220 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 13, 2009 7:22 AM   in reply to csgdon

    in the frame that causes that error to appear, if you click on an empty part of the stage and then click on sub_btn, do you see exactly sub_btn in the properties panel?

     

    if not, that's the problem.  if so, post a link to your fla or upload it after changing its extension.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 13, 2009 7:32 AM   in reply to csgdon

    The code for sub_btn looks okay, so it'll be a matter of going thru the usual suspects.

     

    The primary suspect is always the instance name.  So if you click on the button on the stage to select it, the instance name in the properties panel needs to be the same as the one you use in the code.  If there's any doubt, actually change the name in both places just to insure it's the same.

     

    Another suspect regards the location of code versus the location of the object.  Is sub_btn present in frame 1?

     

    Along a similar line, targeting can sometimes be the issue... is sub_btn a standalone object, not contained in some other object?

     

    If none of these lead to a resolution, can you make the fla file available for a look-see (I'm limited to Flash CS3 and below though).

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 13, 2009 8:35 AM   in reply to csgdon

    I suggest you strip the file down of unrelated content so that you can post it somewhere.  I don't hand out my email for having files sent to me--making it available to the general public is to your benefit.  I may not be around to look at it, but someone else may.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 13, 2009 2:36 PM   in reply to csgdon

    Yep... targeting may be the problem.  You don't necessarily need to have the code in the movieclip that the button is in.  You can target the code for the button from the maintimeline if you preclude it with the instance name of the movieclip it's sitting in...

     

    movieName.sub_btn.addEventListener....

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 13, 2009 7:36 PM   in reply to csgdon

    You're welcome

     
    |
    Mark as:
  • Currently Being Moderated
    May 12, 2010 5:21 AM   in reply to csgdon

    Hi,

     

    I also have almost similar problem to this.  Mine is going to a frame "reservationpage".  I set a button on  frame 3 in "treatmentspage" that should call on "reservationpage" in frame 8.

     

    I have been using this code:

     

    myreserve_btn.addEventListener(MouseEvent.CLICK, onReservClick);

     

    function onReservClick(evt:MouseEvent):void {
        gotoAndStop("reservation page");
       
        myreserve_btn.removeEventListener(MouseEvent.CLICK, onReservClick);
    }

     

    but keep getting:

     

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
        at SpaLuvicebestmassageoptionintown_fla::MainTimeline/frame3()
        at flash.display::Sprite/constructChildren()
        at flash.display::Sprite()
        at flash.display::MovieClip()
        at SpaLuvicebestmassageoptionintown_fla::innnerbody_25()
        at flash.display::Sprite/constructChildren()
        at flash.display::Sprite()
        at flash.display::MovieClip()
        at flash.display::MovieClip/gotoAndStop()
        at SpaLuvicebestmassageoptionintown_fla::MainTimeline/bodymassagebtn_cli cked()

     

    can I get help on this please?

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 21, 2010 11:30 AM   in reply to Ned Murphy

    I'm having a similar problem. I have in my project four flv video inside of a movieclip. I have a custom play/pause buttons for each of the four vids (well one generic playBtn & pauseBtn, instance names different for each vid on the generic play/pause buttons) The actionscript I have to play/pause video is this: 

              fishyPauseBtn.addEventListener(MouseEvent.CLICK, pauseHandler);

              fishyPlayBtn.addEventListener(MouseEvent.CLICK, playHandler);

     

              function pauseHandler(e:MouseEvent):void{

              fishyVid.pause();

     

              }

              function playHandler(e:MouseEvent):void{

              fishyVid.play();

              }

     

    This works fine & it stops & plays the video when there are pressed. But when I use the same script on other video it doesn't work I get this:

    Picture 1.png

    function pauseHandler(e:MouseEvent):void{  when I double click on the code error in the compiler error panel tab this is the line of code thats highlighted

    function playHandler(e:MouseEvent):void{  when I double click on the code error in the compiler error panel tab this is the line of code thats highlighted

     

    I then renamed the pauseHandler & playHandler to pauseHanddler_B, playHanddler_B, this stops the above error but it doesn't pause or play another

    video, I get this message in the output panel:

    Picture 2.png

    I've tired scripting all the buttons to play & pause the video's in one script like so:

     

     

    fishyPauseBtn.addEventListener(MouseEvent.CLICK, pauseHandler);

    fishyPlayBtn.addEventListener(MouseEvent.CLICK, playHandler);

    mashedPauseBtn.addEventListener(MouseEvent.CLICK, playHandler)

    mashedPlayBtn.addEventListener(MouseEvent.CLICK, playHandler)

     

    function pauseHandler(e:MouseEvent):void{

    fishyVid.pause();

    mashVid.pause();

    }

    function playHandler(e:MouseEvent):void{

    fishyVid.play();

    mashVid.play();

    }

    But yet again I get this message in the output panel:
    Picture 3.png

    I've tired putting the script at each section in the timeline where the video is playing and it doesn't work it will pause & play one of the videos. Can anybody bring me out of the darkness, please I'm going mad by this! Thanks

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 15, 2011 6:38 PM   in reply to Ned Murphy

    Ned, this totally saved my butt on a school project where I had my buttons moving in a movie clip file.

     

    Thanks bro!

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 15, 2011 6:43 PM   in reply to hawkmankt

    You're welcome

     
    |
    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