加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

actionscript-3 – 在flex中运行时向组添加边框

发布时间:2020-12-15 01:48:02 所属栏目:百科 来源:网络整理
导读:我试图在运行时在flex中创建一组spark类型.我在运行时将几个按钮作为该组的子项.我想为所有组添加边框.但是,当我使用边框容器时,它隐藏所有其他子项和组容器中的东西,只显示边框容器屏幕.如何向组添加边框. 请注意,我在运行时添加边框容器作为组容器的子容器
我试图在运行时在flex中创建一组spark类型.我在运行时将几个按钮作为该组的子项.我想为所有组添加边框.但是,当我使用边框容器时,它隐藏所有其他子项和组容器中的东西,只显示边框容器屏幕.如何向组添加边框.

请注意,我在运行时添加边框容器作为组容器的子容器.

最好的祝福

解决方法

您可以在特定索引处添加s:Rect子项作为边框.

<?xml version="1.0" encoding="utf-8"?>
<s:Application 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[
        import mx.graphics.SolidColorStroke;

        import spark.primitives.Rect;

        protected function addNewBorderButtonClick(event:MouseEvent):void
        {
            var borderRect:Rect = new Rect();
            var solidStroke:SolidColorStroke = new SolidColorStroke(0,3);
            borderRect.stroke = solidStroke;
            borderRect.percentWidth = borderRect.percentHeight = 100;

            targetGroup.addElementAt(borderRect,0);
        }
    ]]>
</fx:Script>

<fx:Declarations>
</fx:Declarations>

<s:Group id="targetGroup" 
         width="100" height="100"
         horizontalCenter="0" verticalCenter="0">
    <!-- some visual elements here -->
    <s:Button id="addNewBorderButton" 
              label="Add Border"
              horizontalCenter="0" verticalCenter="0"
              click="addNewBorderButtonClick(event)" />
</s:Group>
</s:Application>

希望这可以帮助,

火焰

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读