Ask a Question related to Macromedia Flex General Discussion, Design and Development.
-
Mister Quest #1
Extending an existing component
Hi...I'm trying to create a custom and I'm having problems adding child
components to it, even though I think I"ve followed all the documentation I've
read to create it. Here's my setup:
- I extend TitleWindow in a class called MiniView. MiniView is defined in a
class file called MiniView.as.
- I attempt to add a ControlBar as a child component by overriding
createChildren() in MiniView.as. I also add a call to super.createChildren().
function createChildren(): Void {
super.createChildren();
- I create a child component via the recommended procedure
var toolBar:ControlBar;
toolBar = ControlBar(createClassObject(ControlBar, "toolBar1", 1,
{width:"100%", backgroundColor:"#ff00ff", height:"25", marginTop:"0",
marginBottom:"0", marginLeft:"0", horizontalAlign:"right"}));
- At this point, I would expect my toolbar to be the only component visibile
when I instantiate a MiniView object. That didn't work, but I continued on. Now
I add two buttons to the toolbar
toolBar.createChild(Button, "btnFreeze", 0, {label:"Freeze",
backgroundColor:"#00ff00"});
toolBar.createChild(Button, "btnResume", 0, {label:"Resume",
backgroundColor:"#ff0000"});
- Per some documentation I came across, I make a call to invalidate(). I also
tried invalidateLayout(), but it had no effect either.
//invalidateLayout();
invalidate();
- Debug to verifiy this method was called and made it to the end
Alert.show("done creating children...");
- In my main.mxml file, I add MiniView component to my application dynamically
depending on a selection in a ComboBox.
function doSomething(event): Void {
var strTitle:String = event.target.selectedItem;
views.createChild(MiniView, undefined, {title:strTitle, id:"view1",
width:"100%", height:"290"})//, backgroundImage:strTitle + ".jpg"});
}
- While I do get the TitleWindow on the screen and the Alert box to display,
none of my sub-components are visible. Am I missing something? I did come
across a different procedure that tells how to use the compile tool to compile
a class into a .swc file, but it's my impression that's completely optional.
Since no one else posted regarding this, I'm assuming that I'm missing a vital
step when it comes to overriding a component. Would appreciate the assistance...
Thanks,
Quest
General Dynamics
Any ideas???
--------------------------------------------------------------------------------
----
class vmoc.MiniView extends mx.containers.TitleWindow {
import mx.containers.ControlBar;
import mx.controls.Alert;
import mx.controls.Button;
import mx.controls.Label;
/*
The local value of _myName is private, while the getter and setter methods
are public.
In getters and setters, you cannot use the same name of the property in the
function name.
As a result, you should use some convention, such as prefixing the member
name with an underscore character (_).
*/
private var _myName:String = "abc";
public function get myName():String {
return _myName;
}
public function set myName(name:String) {
_myName = name;
}
/*
function MiniView() {
super.TitleWindow();
// var toolBar:ControlBar = ControlBar(createChild(ControlBar, "toolBar",
{width:"100%", backgroundColor:"#ff00ff", height:"25", marginTop:"0",
marginBottom:"0", marginLeft:"0", horizontalAlign:"left"}));
}
*/
function createChildren(): Void {
super.createChildren();
var toolBar:ControlBar;
var buttonPress:Button;
toolBar = ControlBar(createClassObject(ControlBar, "toolBar1", 1,
{width:"100%", backgroundColor:"#ff00ff", height:"25", marginTop:"0",
marginBottom:"0", marginLeft:"0", horizontalAlign:"right"}));
toolBar.createChild(Button, "btnFreeze", 0, {label:"Freeze",
backgroundColor:"#00ff00"});
toolBar.createChild(Button, "btnResume", 0, {label:"Resume",
backgroundColor:"#ff0000"});
// invalidateLayout();
invalidate();
Alert.show("done creating children...");
}
}
Mister Quest Guest
-
Is it possible to set an existing component as child ofa container?
Hi, I have a container, a HBox named hbox. This container will have only one child. Every time I destory the previous child, then create a new... -
Extending CF PoP.
Is there anyway to extend CFPoP to support additional encoding types? I am getting ' java.io.UnsupportedEncodingException: iso-3979-1. ' Could... -
How to make a protected property in the base component public in the derived component?
I have a base component, from which several components derive. What I want is to just publish some of the protected properties in the base... -
Extending the Window Component in Flash MX 2004
Hi All, I have looked for information on the Window component in Flash MX 2004 and the only examples I can find are examples of 3rd party... -
Problem with creating a Component and using existing functions
Ok, I've got the MovieClip setup as a component, adding code to the #initclip pragma to declare the class and link it to the ID in the library... -
insguy #2
Re: Extending an existing component
Your problem here may be that the third argument to your calls to
createClassObject are both zero, they should be different values. The third
argument is the z index of the child created, if they're both zero, you
effectively replace the first child at index 0 with 2nd child.
insguy Guest



Reply With Quote

