开发者

how to get the checkbox icon from checkbox class of flex actionscript?

i want to get the checkBox image that is 开发者_运维问答present in the checkBox class of flex Framework how can i access that image.

help needed

regards.


As Chris mentioned, the checkmark is drawn using FXG rather than stored as a bitmap. Here's the checkmark FXG, taken from CheckBoxSkin (and cleaned up a little):

<s:Path left="2" top="0" id="check"
        data="M 9.2 0.1 L 4.05 6.55 L 3.15 5.0 L 0.05 5.0 L 4.6 9.7 L 12.05 0.1 L 9.2 0.1">        
    <s:fill>
        <s:SolidColor id="checkMarkFill" color="0" alpha="0.8" />
    </s:fill>
</s:Path>

You could create a custom component that just displays this path and insert it wherever you like. Hope that helps.


If you are using Flex 4 components, the checkbox Icon is not an image but a vector path inside the standard Skin of the checkbox component. If you wanted to access that from within the class you could do:

var mySkin:CheckBoxSkin = this.skin as CheckBoxSkin;
mySkin.check = WhateverYouWannaDoWithIt;

But if you simply want to change the look of your checkbox, just create a custom CheckBoxSkin (you can also add image Icons then) and assign it to your checkbox component.


Im presuming you want to change the image?

If so, this is a good example for Flex 3:

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/08/25/changing-a-checkbox-controls-icon/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Script>
        <![CDATA[
            [Bindable]
            [Embed(source="assets/icon_accept.gif")]
            public var AcceptIcon:Class;

            [Bindable]
            [Embed(source="assets/icon_alert.gif")]
            public var AlertIcon:Class;
        ]]>
    </mx:Script>

    <mx:CheckBox id="checkBox"
            label="Custom icon test (selected={checkBox.selected})"

            disabledIcon="{AlertIcon}"
            downIcon="{AlertIcon}"
            overIcon="{AlertIcon}"
            upIcon="{AlertIcon}"

            selectedDisabledIcon="{AcceptIcon}"
            selectedDownIcon="{AcceptIcon}"
            selectedOverIcon="{AcceptIcon}"
            selectedUpIcon="{AcceptIcon}"
         />

</mx:Application>

Example from blog.flexexamples.com (which is almost always down these days!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜