The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 4 of 4

Thread: Help with Error # 1009

  1. #1

    Barcode Help with Error # 1009

    Hi friends
    If you know me, you would also know that I was working AS2 and I can do almost anything with AS2, but Im migrating to AS3 and I'm a newbe.
    considering that, I realized, this error is happen when something that not suppose to be Null, be Null. but I can't figure it out in my project, even after debugging!

    Here is what's happened:
    I used this guy class of frames fade transition and it works fine on one of my frames but on another frame it works but with this error!!

    My declaration which gives me error:
    PHP Code:
    Fade.fadeIntoFrame(root,stage,"step2"); 
    well root and stage are predefined! "step2" is my frame label! I have same situation on my previous frame too! I cant figure it out! what should I do?
    my whole code:
    PHP Code:
    //mainMenu Frame
    stop();

    //EVENT LISTENERS
    tt_btn.addEventListener(MouseEvent.CLICK,onClick1);
    uw_btn.addEventListener(MouseEvent.CLICK,onClick1);
    ec_btn.addEventListener(MouseEvent.CLICK,onClick1);
    pp_btn.addEventListener(MouseEvent.CLICK,onClick1);
    ut_btn.addEventListener(MouseEvent.CLICK,onClick1);

    //EVENT HANDLERS;
    function onClick1(event:MouseEvent):void
    {
        switch (
    event.target)
        {
            case 
    tt_btn :
                
    Fade.fadeIntoFrame(root,stage,"tT");
                break;
            case 
    uw_btn :
                
    gotoAndStop("uW");
                break;
            case 
    ec_btn :
                
    gotoAndStop("eC");
                break;
            case 
    pp_btn :
                
    gotoAndStop("rP");
                break;
            case 
    ut_btn :
                
    gotoAndStop("uT");
                break;
        }
    }

    //tt Frame
    stop();
    b0_btn.addEventListener(MouseEvent.CLICK,onClick2);
    b1_btn.addEventListener(MouseEvent.CLICK,onClick2);
    b2_btn.addEventListener(MouseEvent.CLICK,onClick2);
    b3_btn.addEventListener(MouseEvent.CLICK,onClick2);
    b4_btn.addEventListener(MouseEvent.CLICK,onClick2);
    b5_btn.addEventListener(MouseEvent.CLICK,onClick2);
    b6_btn.addEventListener(MouseEvent.CLICK,onClick2);
    b7_btn.addEventListener(MouseEvent.CLICK,onClick2);
    b8_btn.addEventListener(MouseEvent.CLICK,onClick2);
    b9_btn.addEventListener(MouseEvent.CLICK,onClick2);
    next_btn.addEventListener(MouseEvent.CLICK,onClick2);
    prev_btn.addEventListener(MouseEvent.CLICK,onClick2);
    del_btn.addEventListener(MouseEvent.CLICK,onClick2);

    function 
    onClick2(event:MouseEvent):void
    {
        var 
    num:String = new String("");
        
    error_txt.text "";
        switch (
    event.target)
        {
            case 
    b0_btn :            num "0";            break;
            case 
    b1_btn :            num "1";            break;
            case 
    b2_btn :            num "2";            break;
            case 
    b3_btn :            num "3";            break;
            case 
    b4_btn :            num "4";            break;
            case 
    b5_btn :            num "5";            break;
            case 
    b6_btn :            num "6";            break;
            case 
    b7_btn :            num "7";            break;
            case 
    b8_btn :            num "8";            break;
            case 
    b9_btn :            num "9";            break;
            case 
    del_btn :
                
    capacity_txt.text capacity_txt.text.substring(0,capacity_txt.text.length 1);
                break;
            case 
    prev_btn :
                
    Fade.fadeIntoFrame(root,stage,"mainMenu");
                break;
            case 
    next_btn :
                if ((
    capacity_txt.text.length==0) || (capacity_txt.text == "0"))
                {
                    
    error_txt.text "No Capacity Entered";
                }
                else if (
    Number(capacity_txt.text) > 240)
                {
                    
    error_txt.text "Maximum Capacity Overflow";
                }
                else
                {
                    
    Fade.fadeIntoFrame(root,stage,"step2");
                }
                break;
        }
        if (
    capacity_txt.text.length 3//This is line 76 which error says
        
    {
            if ((
    capacity_txt.text == "0")&&(num!=""))
            {
                
    capacity_txt.text num;
            }
            else
            {
                
    capacity_txt.text +=  num;
            }
        }

    And the error:
    HTML Code:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
        at NewProject_fla::MainTimeline/onClick2()[NewProject_fla.MainTimeline::frame5:76]
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
        at NewProject_fla::MainTimeline/onClick2()[NewProject_fla.MainTimeline::frame5:76]

  2. #2
    Well as I tested more, there is nothing to do with the class.
    I have problems with using event.target in my function!
    When I use a switch(event.target) and in case I give the commands for all of the buttons which using the same event handler, this error pops out! not in my first time!!
    I use the same structure (not same function names) for example:

    function onClick(event:MouseEvent):void
    {
    switch (event.target)
    {
    case next_btn:
    gotoAndStop ("nextFrameName");
    break;
    case prev_btn:
    gotoAndStop ("prevFrameName");
    break;
    }
    }

    in all of my frames and I get the #1009 error for all of them except the first one!
    the funny thing is it works fine! I named all the buttons and frames, but it gives me this error! I can fix it with making each button an event handler but its making my codes too much and I want to brief my code as it possible!
    why is that happening and how can I fix it?!
    Last edited by mrhartsclube; September 28th, 2014 at 08:17 AM.

  3. #3
    try using: event.currentTarget
    I used to be a paranoid-psychotic-schizophrenic, but don't worry, he's dead now.

  4. #4
    Quote Originally Posted by snickelfritz View Post
    try using: event.currentTarget
    thanks for reply.
    it doesn't change anything! I still getting that error and I figured out that the error is because of the gotoandstop and timeline navigating functions, but I don't know how to solve it!
    Please help

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012