PDA

View Full Version : Simple/Stupid UI questions...


Hak
01-28-2007, 05:07 PM
I'm a pro user of AS2, I like AS3, but Flex frameworks seems to be full of pitfalls to me.

Few questions:
1. <mx:Application ... backgroundImage="{ApplicationBackground}" >
When the application is created, say in onCreationComplete - how do I access the "backgroundImage" object that contains the image?
I want to have a click handler on the background of the application.
Also - what object "backgroundImage" transposes to - Image?

2. I'm coding my component as .as class. I have an Image, and two Labels.
How do I tell the programatically created label (var l:Label = new Label() ) to align itself to the right? Also - how do I tell it what font to use and if I want the font to be embedded or not (antialiased vs sharp)

3. Regarding component above - I'm embedding a symbol from swf, say:
[@Embed(source="../../assets/skin.swf", symbol="panelPopover")].
public var bPanel:Class;
...
img = new Image();
img.source = bPanel;

And this symbol/swf contains a background and two text fields, called _info_, and _title_. How do I access this loaded swf and how do I set value of these textfields? I tried pretty much everything in the area of
SomeType(img.content)._info_.text - and nothing!
Where is this embedded swf and what type of object it is?
How do I access its contents? Embedded symbol is exported in the first frame.

4. Now this is stupid. I'm using Canvases quite a lot, and sometimes I want Canvas to be of specified color, say red, alpha 50%.
[backgroundAlpha="0.5" backgroundColor="red"].

Superb, I have my canvas, but why the hell it covers all what's behind it?
I have no mouse handler on it or antyhing, it should be "transparent" to mouse clicks! Is Flex creating some MovieClip/Sprite/Whatever with rectangle of that red color that eats up all the mouse events?

Seems all components eat mouse events up, even if I have no mouse event handlers attached to them. How do I make them transparent and allow movieclips/displayobjects under them to receive mouse events?

Any help will be appreciated. Flex is nice, but when I try walk off the paved area, I run into trouble...

Tink
01-28-2007, 05:25 PM
some quick replies

1. Not sure u can do that. Just add a Canvas that covers the whole app and add the click handler to that.

2. setStyle( "textAlign", "right" );
setStyle( "fontFamily" "Font" );
setStyle( "fontAntiAliasType", "normal" );
all these are listed under Label in the docs.

3. If you embed an SWF you can't access these props, you'd need to load it at runtime. embeding just embeds the symbols.

4. it should not be transparent to mouse click else wot would happen if you wanted to detect a click on it??? Yes its creatig a Canvas, and a Canvas will extend a Sprite at some point. If you want to disable mouse events from being pcked up set its mouseEnabled property to false.

dr_zeus
01-29-2007, 05:34 PM
You'll need to access backgroundImage as a style. This should work:

var bg:Sprite = this.getStyle("backgroundImage");