In Widget instead of doing anything inthe
constructor you can do it in commitProperties()
function commitProperties() : Void
{
super.commitProperties();
//your code here
}
Matt
From: ckovey
[mailto:[EMAIL PROTECTED]
Sent: Wednesday, February 09, 2005
7:33 PM
To: [email protected]
Subject: [flexcoders] Accessing
tag attributes at construction
Greetings!
I was
wondering if or how it would be possible to access a tag's
attributes
at constuction time. Or must you always just use the
initialize=""
to start using the attributes after an object is
constructed?
Here is a
simple example of test.mxml and Wiget.as to illustrate what
I'm trying
to get at:
<!--
test.mxml -->
<?xml
version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.macromedia.com/2003/mxml"
xmlns:local="*"
>
<local:Widget id="widget1" attrib="foo"
initialize="widget1.initWidget();"
/>
</mx:Application>
//Wiget.as
class Widget
extends mx.containers.HBox {
import mx.controls.*;
public var attrib:String;
public function Widget() {
Alert.show("this.attrib="+this.attrib
+ "\r" +
"attrib="+attrib,"Constructor");
}
public function initWidget():Void {
Alert.show("this.attrib="+this.attrib
+ "\r" +
"attrib="+attrib,"Initialize");
}
}
The first
alert box should show both as undefined, while the second
will give
you the value of the attribute attrib="foo"
TIA
|