开发者

Simple Primitive Elements in Flex 4?

Normally on other IDEs, I simply drag a Rectangle object to the body or content of my application then resize it, define colors, etc. What I discovered in Flex 4 (Flash Builder 4) was 开发者_运维知识库that it's not just like that (or is it?) and I can't seem to find something to drag to my application to create a Rectangle object.

My question is, how do I do it? How do I create a simple Rectangle?


There is no support for FXG elements in Flash Builder Design mode. What you can do is, use Flash Catalyst, draw your primitives with it and copy/paste the generated code in Flash Builder.


I think I just figured out how to deal with it. I just make a new component and base it on spark.primitives.Rect. Then after that, I just assign the fill's SolidColor to whatever I need just like my component code below.

<?xml version="1.0" encoding="utf-8"?>
<s:Rect xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" 
        xmlns:mx="library://ns.adobe.com/flex/mx">
    <fx:Script>
        <![CDATA[
            [Bindable]
            public var fillColor:String;
        ]]>
    </fx:Script>
    <s:fill>
        <s:SolidColor color="{fillColor}" />
    </s:fill>
</s:Rect>

Not sure if this is the best way but it works for me so I'll go along with it. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜