Copy link to clipboard
Copied
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
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
...Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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:
Find more inspiration, events, and resources on the new Adobe Community
Explore Now