zoukankan      html  css  js  c++  java
  • Flex4中的拖动技术

    下面列一个最简单的例子,在Flex中,拖动原来如此简单

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    <?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">
        <s:layout>
            <s:BasicLayout/>
        </s:layout>
        <fx:Script>
            <![CDATA[
                private function startMove(event:Event):void{
                    Sprite(event.target).startDrag();  
                }     
                private function stopMove(event:Event):void{
                    Sprite(event.target).stopDrag();  
                }  
      
            ]]>
        </fx:Script>
        <fx:Declarations>
            <!-- 将非可视元素(例如服务、值对象)放在此处 -->
        </fx:Declarations>
          
        <mx:Button id="btn" mouseDown="startMove(event)" mouseUp="stopMove(event)" label="move"/>
    </s:Application>

    如果需要拖动的时候多个控件可以一起拖动,可以先用BorderContainer组件先把控件包含进来

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    <?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">
        <s:layout>
            <s:BasicLayout/>
        </s:layout>
          
            <fx:Script>
                <![CDATA[
                    private function startMove(event:Event):void{
                        Sprite(bc).startDrag();  
                    }     
                    private function stopMove(event:Event):void{
                        Sprite(bc).stopDrag();  
                    }  
                      
                ]]>
            </fx:Script>
      
        <fx:Declarations>
            <!-- 将非可视元素(例如服务、值对象)放在此处 -->
        </fx:Declarations>
        <s:BorderContainer id="bc" x="80" y="92" width="250" height="200" mouseDown="startMove(event)" mouseUp="stopMove(event)"  borderVisible="true">
            <s:Button x="62" y="62" label="按钮"/>
            <s:Button x="62" y="124" label="按钮"/>
        </s:BorderContainer>
    </s:Application>
  • 相关阅读:
    剑指offer编程题66道题 26-35
    剑指offer编程题66道题 1-25
    springboot的自动配置
    用智能的编译器来防错
    实现迭代器的捷径
    结束C#2的讲解:最后的一些特性
    进入快速委托通道
    可空类型
    用泛型实现参数化类型
    C#1所搭建的核心基础
  • 原文地址:https://www.cnblogs.com/wshsdlau/p/3510639.html
Copyright © 2011-2022 走看看