A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [RESOLVED] TypeError: Error #1009 When adding custom class to stage

  1. #1
    Junior Member
    Join Date
    May 2009
    Posts
    3

    resolved [RESOLVED] TypeError: Error #1009 When adding custom class to stage

    Hey all,

    I have extended a RadioButton into a custom class in order to store some extra info. I want to dynamically add these RadioButtons to the stage to create a dynamic menu box. So I started simple in order to make sure I knew how to do this.

    Here's the error (I love Flash IDE error reporting):
    Code:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    	at fl.controls::RadioButton/drawLayout()
    	at fl.controls::LabelButton/draw()
    	at fl.controls::RadioButton/draw()
    	at fl.core::UIComponent/callLaterDispatcher()
    Here's the code:

    MuscleMenuRadioButton class
    PHP Code:
    package com.gs.muscleman
    {
        
    import flash.display.MovieClip;
        
    import fl.controls.RadioButton;
        
    import flash.events.Event;
        
        public 
    dynamic class MuscleMenuRadioButton extends RadioButton{
            private var 
    findingNumber:String = new String();
            
            public function 
    MuscleMenuRadioButton(_labeler:String_findingNumber:String){
                
    super();
                
    this.label _labeler;
                
    this.findingNumber _findingNumber;            
            }
            
            public function 
    getFindingNumber():String{
                return 
    this.findingNumber;
            }
        }

    And my actionscript on first frame of movie:
    PHP Code:
    import com.gs.muscleman.MuscleMenuRadioButton;

    var 
    Abutton:MuscleMenuRadioButton = new MuscleMenuRadioButton("A Button","F-34939");
    stage.addChild(Abutton);

    Abutton.50;
    Abutton.100
    Does anyone see what is going on here? Any help would be greatly appreciated.

    Thanks in advance,

    Wrathgrapes
    Last edited by wrathgrapes; 05-18-2009 at 08:56 PM.

  2. #2
    a.k.a gltovar deadlock32's Avatar
    Join Date
    May 2001
    Location
    Naperville,IL
    Posts
    489
    have you tried is as a non-dynamic class?

    also try getting rid of the constructing params, and add those in on the next line, (make them setters/getters) so:

    Code:
    var Abutton:MuscleMenuRadioButton = new MuscleMenuRadioButton();
    Abutton.label = "A Buton";
    Abutton.findingNumber = "F-34939";
    stage.addChild(Abutton);
    It might be because you are attemting to access 'label' from radiobutton class too early.

  3. #3
    Junior Member
    Join Date
    May 2009
    Posts
    3
    I tried that and it didn't work...

    While debugging I found that the properties label and findingNumber were being set before the drawLayout was called. So I tried something simpler:
    PHP Code:
    import fl.controls.RadioButton;

    var 
    Rbutton:RadioButton = new RadioButton();
    Rbutton.label "Radio Button";

    stage.addChild(Rbutton);

    Rbutton.50;
    Rbutton.100
    And amazingly...
    Code:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    	at fl.controls::RadioButton/drawLayout()[C:\Program Files\Adobe\Adobe Flash CS3\en\Configuration\Component Source\ActionScript 3.0\User Interface\fl\controls\RadioButton.as:356]
    	at fl.controls::LabelButton/draw()[C:\Program Files\Adobe\Adobe Flash CS3\en\Configuration\Component Source\ActionScript 3.0\User Interface\fl\controls\LabelButton.as:607]
    	at fl.controls::RadioButton/draw()[C:\Program Files\Adobe\Adobe Flash CS3\en\Configuration\Component Source\ActionScript 3.0\User Interface\fl\controls\RadioButton.as:506]
    	at fl.core::UIComponent/callLaterDispatcher()[C:\Program Files\Adobe\Adobe Flash CS3\en\Configuration\Component Source\ActionScript 3.0\User Interface\fl\core\UIComponent.as:1379]
    Still the same error. There is something fundamental I am doing wrong here and I can't figure it out... Does anyone have any other Ideas?

  4. #4
    Junior Member
    Join Date
    May 2009
    Posts
    3
    Ok, so I figured this one out and... drumroll plz:

    I never added the component to the library. Works fine now.

    Thanks for offering your help though.

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