Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Oct 2009
    Location
    London, ON
    Posts
    112
    Thanks
    4
    Thanked 0 Times in 0 Posts

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

    Code:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    	at portfolio_fla::MainTimeline/frame1()
    frame1 is my actionscript (AS3)

    Code:
    //ADD EVENT LISTENERS (make a button work) (.addEventListener(MouseEvent.CLICK))
    design_btn.addEventListener (MouseEvent.CLICK, designSlide);
    flash_btn.addEventListener (MouseEvent.CLICK, flashSlide);
    
    //ADD FUNCTIONS
    
    Design.addEventListener(MouseEvent.CLICK, designSlide);
    function designSlide(event:MouseEvent):void {
    	navigateToURL(new URLRequest("http://www.flickr.com/photos/30766015@N08/"));
    	trace ("design clicked");
    	gotoAndStop ("design");
    }
    
    
    Flash.addEventListener(MouseEvent.CLICK, flashSlide);
    function flashSlide(event:MouseEvent):void {
    	navigateToURL(new URLRequest("http://nickhiebert.com/emi-project-directory.html"));
    	trace ("flash clicked");
    	gotoAndStop ("flash");
    }
    I have labels on the timeline along with 3 second animations for the flash and design slide.

    Help would be great.

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    One of your objects doesn't exist when you are trying to call a method of it(such as addEventListener). Comment them out one-by-one until you find the culprit.

  • #3
    Regular Coder
    Join Date
    Oct 2009
    Location
    London, ON
    Posts
    112
    Thanks
    4
    Thanked 0 Times in 0 Posts
    I did the debug action ctrl+shift+enter and it says the problem is coming from line 3 which is
    Code:
    flash_btn.addEventListener (MouseEvent.CLICK, flashSlide);
    Any Ideas? I haven't touched Flash in awhile. Thanks for the reply though.

  • #4
    Regular Coder
    Join Date
    Oct 2009
    Location
    London, ON
    Posts
    112
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by nickHiebert View Post
    I did the debug action ctrl+shift+enter and it says the problem is coming from line 3 which is
    Code:
    flash_btn.addEventListener (MouseEvent.CLICK, flashSlide);
    Any Ideas? I haven't touched Flash in awhile. Thanks for the reply though.
    Also the Design MC is a psd and the Flash MC is a jpg converted to a MC could that be the problem? The flash_btn and design_btn are both psd files imported in as well.

  • #5
    Regular Coder
    Join Date
    Oct 2009
    Location
    London, ON
    Posts
    112
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Also the Design MC is a psd and the Flash MC is a psd The flash_btn and design_btn are both psd files imported in as well.

  • #6
    Regular Coder
    Join Date
    Oct 2009
    Location
    London, ON
    Posts
    112
    Thanks
    4
    Thanked 0 Times in 0 Posts

  • #7
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    You haven't added any new information. flash_btn still doesn't exist in that scope, or doesn't exist at the instant that this code is running.

  • #8
    Regular Coder
    Join Date
    Oct 2009
    Location
    London, ON
    Posts
    112
    Thanks
    4
    Thanked 0 Times in 0 Posts
    That's the tutorial I used
    Code:
    http://www.vineyardesigns.com/tutorials/flash/website/url_link.shtml
    Here is my AS3 code:
    Code:
    //ADD EVENT LISTENERS (make a button work) (.addEventListener(MouseEvent.CLICK))
    design_btn.addEventListener(MouseEvent.CLICK, designSlide);
    flash_btn.addEventListener(MouseEvent.CLICK, flashSlide);
    twitter_btn.addEventListener(MouseEvent.CLICK, twitterSlide);
    
    //ADD FUNCTIONS
    
    design_mc.addEventListener(MouseEvent.CLICK, designSlide);
    function designSlide(event:MouseEvent):void {
    	navigateToURL(new URLRequest("http://www.flickr.com/photos/30766015@N08/"));
    	trace ("design clicked");
    	gotoAndStop ("design");
    }
    
    flash_mc.addEventListener(MouseEvent.CLICK, flashSlide);
    function flashSlide(event:MouseEvent):void {
    	navigateToURL(new URLRequest("http://nickhiebert.com/emi-project-directory.html"));
    	trace ("flash clicked");
    	gotoAndStop ("flash");
    }
    
    twitter_mc.addEventListener(MouseEvent.CLICK, twitterSlide);
    function twitterSlide(event:MouseEvent):void {
    	navigateToURL(new URLRequest("http://twitter.com/nick_hiebert"));
    	trace ("twitter clicked");
    	gotoAndStop ("twitter");
    }
    This is what i get as an error. (in debug mode console mode)
    Code:
    Attemping to launch and connect to Player using URL C:\Documents and Settings\Nick\My Documents\My Projects\Coding\Portfolio Site XHTML&CSS\flash\project file\portfolio-flash-banner.swf
    [SWF] C:\Documents and Settings\Nick\My Documents\My Projects\Coding\Portfolio Site XHTML&CSS\flash\project file\portfolio-flash-banner.swf - 130364 bytes after decompression
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    	at portfolio_fla::MainTimeline/frame1()[portfolio_fla.MainTimeline::frame1:3
    It doesn't seem to like flash and twitter in this case i commented them out meaning
    Code:
    //flash_btn.addEventListener(MouseEvent.CLICK, flashSlide);
    //twitter_btn.addEventListener(MouseEvent.CLICK, twitterSlide);
    and
    Code:
    //flash_mc.addEventListener(MouseEvent.CLICK, flashSlide); //twitter_mc.addEventListener(MouseEvent.CLICK, twitterSlide);
    Then it seems to work with no #1009 error. But i want them both to work.

    There are no compiler errors. On the timeline and stage there is a twitter_btn, twitter_mc, design_btn, design_mc, and flash_btn, flash_mc.

    I used the same concept in the design code in the as3 for the other 2 (twitter,flash)

    Seems to me it has nothing to do with the code. The stage has the problem.
    Last edited by nickHiebert; 12-04-2009 at 08:56 PM.

  • #9
    Regular Coder
    Join Date
    Oct 2009
    Location
    London, ON
    Posts
    112
    Thanks
    4
    Thanked 0 Times in 0 Posts
    It's the timeline when I moved all the animations in the timeline (design,twitter,flash) for the btn's/mc's it/labels started to say an error on the line 2 which is
    Code:
    design_btn.addEventListener(MouseEvent.CLICK, designSlide);
    design_mc and design_btn start on frame 0 in the time line as apost to flash_mc and flash_btn starting on frame 38 and twitter_btn/twitter_mc on frame 75

  • #10
    Regular Coder
    Join Date
    Oct 2009
    Location
    London, ON
    Posts
    112
    Thanks
    4
    Thanked 0 Times in 0 Posts


  •  

    Tags for this Thread

    Posting Permissions

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