meddlingwithfir
01-18-2007, 11:25 PM
It seems there are attributes available to me in Flex that I cannot use inside my .AS classes.
For example, take the Button class. If I add a button via MXML:
<mx:Canvas id="myCanvas">
<mx:Button
id="myButton"
icon="@Embed('assets/myButtonImage.jpg')"
/>
</mx:Canvas>
That will compile just fine. But when I attempt to create a Button object via AS3 inside my <script> tag, the same set of attributes no longer exists:
var test:Button = new Button();
test.icon = "assets/myButtonImage.jpg";
myCanvas.addChild(test);
I get a compile time error:
1119: Access of possibly undefined property icon through a reference with static type mx.controls:Button.
So it's not liking my attempt to assign an icon dynamically. I am also confused as to why it states mx.controls.Button is a "static type"? Button isn't a static class, nor do I think I am trying to call a static attribute of Button.
Looking through the Button class in the API, I can see that "icon" attribute is of type "Class":
icon
Type: Class
CSS Inheritance: no
Name of the class to use as the default icon. Setting any other icon style overrides this setting. The default value is null."
But it doesn't tell me which class it is expecting -- is it a DisplayObject, a Sprite, what?
For example, take the Button class. If I add a button via MXML:
<mx:Canvas id="myCanvas">
<mx:Button
id="myButton"
icon="@Embed('assets/myButtonImage.jpg')"
/>
</mx:Canvas>
That will compile just fine. But when I attempt to create a Button object via AS3 inside my <script> tag, the same set of attributes no longer exists:
var test:Button = new Button();
test.icon = "assets/myButtonImage.jpg";
myCanvas.addChild(test);
I get a compile time error:
1119: Access of possibly undefined property icon through a reference with static type mx.controls:Button.
So it's not liking my attempt to assign an icon dynamically. I am also confused as to why it states mx.controls.Button is a "static type"? Button isn't a static class, nor do I think I am trying to call a static attribute of Button.
Looking through the Button class in the API, I can see that "icon" attribute is of type "Class":
icon
Type: Class
CSS Inheritance: no
Name of the class to use as the default icon. Setting any other icon style overrides this setting. The default value is null."
But it doesn't tell me which class it is expecting -- is it a DisplayObject, a Sprite, what?