简体   繁体   中英

How to draw in Panel Flex?

I have a problem when i want to draw the line in the panel. I don't know how to do that, please explain me...

I'm trying to put the SpriteVisualElement in the panel but i get "component declaration is not allowed here" from Flex builder. Here is my code:

<?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()" />
<mx: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"/>
</mx:Panel>
</s:Application>

使用火花面板

<s:Panel>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM