【问题标题】:How to draw not out of panel borders in Flex?如何在 Flex 中不超出面板边框绘制?
【发布时间】:2013-03-03 12:26:59
【问题描述】:

我想画一些线,它们不能越过面板边界,我不知道该怎么做...... 线越过面板边界,但我希望该线进入面板,然后我可以缩放它。 这是我的代码:

<?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" minWidth="955" minHeight="600"
               >

<fx:Script>
    <![CDATA[
        import mx.graphics.SolidColorStroke;

        import spark.primitives.Line;



        private function drawLine():void 
        {
            var myShape:Shape = new Shape();
            myShape = new Shape() ;


            myShape.graphics.lineStyle(2, 0x00008B, .75);
            myShape.graphics.moveTo(500, 500);

            myShape.graphics.lineTo(25, 45);
            spr.addChild(myShape);
        }
    ]]>
</fx:Script>


<mx:Button label="Click" click="drawLine()" />
<s:Panel  y="30" width="400" height="250" layout="vertical" title="Panel" borderColor="#008040" fontFamily="Arial" fontWeight="bold" fontSize="13">

<mx:Text text="Drawing.." fontWeight="bold"/>
        <s:SpriteVisualElement width="500" height="500" id="spr"/>
</s:Panel>
</s:Application>

【问题讨论】:

    标签: apache-flex actionscript line mxml


    【解决方案1】:

    一种简单的方法是将内容放入Group 并设置clipAndEnableScrolling

    <s:Panel>
        <s:VGroup height="100%" width="100%" clipAndEnableScrolling="true">
            <mx:Text text="Drawing.." fontWeight="bold"/>
            <s:SpriteVisualElement width="500" height="500" id="spr"/>            
        </s:VGroup>
    </s:Panel>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-24
      • 1970-01-01
      • 2019-01-15
      • 1970-01-01
      • 2014-02-21
      • 1970-01-01
      • 1970-01-01
      • 2016-06-19
      相关资源
      最近更新 更多