Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

New Here ,
Nov 11, 2013 Nov 11, 2013

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

TOPICS
ActionScript
6.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Nov 11, 2013 Nov 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... com

...
Translate
LEGEND ,
Nov 11, 2013 Nov 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 13, 2013 Nov 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 13, 2013 Nov 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 13, 2013 Nov 13, 2013
LATEST

When you add an instance of something that's in the fl.controls package to the stage in Flash Pro, this gives you a library symbol that contains all of the physical structure necessary to implement the control. You don't have that in the AS-only project that you're using.

You can try one of two things:

  1. Point to the Flex SDK and use mx.controls instead (they don't need the physical "stuff" fl.controls does).
  2. Make a swc in Flash pro that contains the assets you need and reference the fl.controls Classes through that, rather than pointing to the "code behind" that you're currently pointing at.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines