Skip to main content
Participant
November 11, 2013
Answered

TypeError: Error #2007: Parameter child must be non-null.

  • November 11, 2013
  • 1 reply
  • 6868 views

Hello,

I am new to actionscript 3.0, I have Adobe Flash Builder 4.7 installed and I am creating a ActionScript project (File -> New -> ActionScript Project) named as Test. As you know flash builder does not include fl.controls package by default. I have added this package to my project as source path or swc file so that I can use the default components (e.g. Buttons, RadioButtons, Checkboxes) and now I am writing the following code.

package

{

          import flash.display.Sprite;

          import fl.controls.Button;

 

          [SWF(width = "640", height = "480", frameRate = "60", backgroundColor = "#FFFFFF")]

 

          public class Test extends Sprite

          {

                         private var btn:Button;

 

       public function Test()

                    {

                              btn = new Button();

                              btn.label = "CLICK ME!";

                              btn.x = 100;

                              btn.y = 100;

               addChild(btn);

                    }

          }

}

I am creating a fl.controls.Button instance in Test class and trying to add it on stage. When I run the project, it always gives me the following error for the bold red line.

TypeError: Error #2007: Parameter child must be non-null.

          at flash.display::DisplayObjectContainer/addChildAt()

          at fl.controls::BaseButton/drawBackground()

          at fl.controls::LabelButton/draw()

          at fl.controls::Button/draw()

          at fl.core::UIComponent/callLaterDispatcher()

Pleae help me out to get rid of this problem. Thanks in advance.

Thanks,

momersaleem

This topic has been closed for replies.
Correct answer Ned Murphy

If you think that bold line is the cause of the error due to the error saying "addChildAt" is involved, that is not the same command. 

The error looks more like it is pointing at something in the Button class and is having a problem.

Normally when you work in Flash, having the class of the component is not sufficient for a file to run without werror.  You also need to drag a Button into the library so that the 'physical' entity is available to the file when you try to create a new instance... components are, after all, not created from code alone.  THey are objects that are hand crafted using bits and pieces of graphics and textfields and buttons and whatever was used to create them. 

In short, I think you are missing the Button object in the library and when the class file tries to run it can't find a piece of the coded puzzle.

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
November 11, 2013

If you think that bold line is the cause of the error due to the error saying "addChildAt" is involved, that is not the same command. 

The error looks more like it is pointing at something in the Button class and is having a problem.

Normally when you work in Flash, having the class of the component is not sufficient for a file to run without werror.  You also need to drag a Button into the library so that the 'physical' entity is available to the file when you try to create a new instance... components are, after all, not created from code alone.  THey are objects that are hand crafted using bits and pieces of graphics and textfields and buttons and whatever was used to create them. 

In short, I think you are missing the Button object in the library and when the class file tries to run it can't find a piece of the coded puzzle.

Participant
November 13, 2013

Hello Ned,

Thanks for your reply.

I know that in Adobe Flash Professional CS4, you have to add a control in library to place it on stage using an as3 class without any error. But here I am talking about Adobe Flash Builder.

So now my question is how can I import the built-in controls in Flash Builder's library to avoid above mentioned error.

Please do guide me.

Thanks,

momersaleem

Ned Murphy
Legend
November 13, 2013

I know you are talking about Flash Builder but the same has to be true of Flash Builder as far as having the objects that go with the classes, especially if they are the objects that Flash Pro utilizes.

I do not use Flash Builder so I can't answer from experience how you go about getting the components into the library.  What I normally do to find answers to desgn issues is to start looking thru Google.

If I search Google using the terms "Flash Builder use AS3 components" I get several results that might provide a solution.  Here's one...

http://stackoverflow.com/questions/5602962/getting-flash-ui-components-into-builder

See if the answer for that one works for you, and if not, try some of the others in that search's results.