创建伸缩和拖拽的flex组件

flex-wrap:响应式布局中被低估的弹性安全阀 flex-wrap 是 CSS Flexbox 中控制弹性流换行行为的核心属性,其本质并非简单文本换行,而是依据主轴剩余空间与子元素 flex-basis 动态生成新 flex line 的布局机制。它解决了现代响应式开发中最常见的‘容器溢出’问题——如卡片错位、导航栏崩溃、表单挤压等,无需 JavaScript 或复杂 media query 即可实现内容驱动的自适应断行。结合 flex-direction 可定义换行方向,配合 gap 和 min-width: 0 等实践技巧,能稳定应对文本长度不可控、 阅读详情

主程序

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"  xmlns:myComp="myComponents.*"  creationComplete="creationCompleteHandler();">   

   <mx:Script>       

<![CDATA[        

    import mx.managers.DragManager;     

       import mx.core.DragSource;      

      import mx.events.DragEvent;       

     import flash.events.MouseEvent;   

         import mx.containers.Canvas;        

    import mx.containers.Panel;  

 import myComponents.DragPanel;

   // Define static constant for event type. 

 public static const RESIZE_CLICK:String = "resizeClick";

   // Creation complete event handler adds the resizing event.

   // resizeButtonClicked is a custom event type for this application.   

protected function creationCompleteHandler():void    { 

   addEventListener(RESIZE_CLICK, resizeHandler);

   }

// // D&D event handlers. //

            // Creation complete handler for each panel to add the     

       // mouseMove event handler to the title bar.     

       // Clicking the mouse button, then moving the mouse on the title bar     

       // initiates the d&d operation.            

private function myPanelCCHandler(event:Event):void             {              event.currentTarget.myTitleBar.addEventListener(MouseEvent.MOUSE_DOWN, tbMouseMoveHandler);             }

            // Variables used to hold the mouse pointer's location in the title bar.    

        // Since the mouse pointer can be anywhere in the title bar, you have to 

           // compensate for it when you drop the panel.          

  public var xOff:Number;           

public var yOff:Number;                      

  // Function called by the canvas dragEnter event; enables dropping            

private function doDragEnter(event:DragEvent):void {                 DragManager.acceptDragDrop(Canvas(event.target));          

  }

            // Drag initiator event handler for           

// the title bar's mouseMove event.            

private function tbMouseMoveHandler(event:MouseEvent):void {

                var dragInitiator:Panel=Panel(event.currentTarget.parent); 

               var ds:DragSource = new DragSource(); 

               ds.addData(event.currentTarget.parent, 'panel');

                             // Update the xOff and yOff variables to show the

             // current mouse location in the Panel. 

                xOff = event.currentTarget.mouseX; 

               yOff = event.currentTarget.mouseY;  

                              // Initiate d&d.               

DragManager.doDrag(dragInitiator, ds, event);  

                             }           

            // Function called by the Canvas dragDrop event;

            // Sets the panel's position,            

// "dropping" it in its new location.           

private function doDragDrop(event:DragEvent):void             { 

   // Compensate for the mouse pointer's location in the title bar.   

 var tempX:int = event.currentTarget.mouseX - xOff;   

 event.dragInitiator.x = tempX;         

var tempY:int = event.currentTarget.mouseY - yOff;    

event.dragInitiator.y = tempY;         

// Put the dragged panel on top of all other components.    

v1.setChildIndex(Panel(event.dragInitiator), v1.numChildren-1);               

}

// // Resizing event handlers. //

   // Save panel being resized.   

protected var resizingPanel:Panel;   

// Global coordinates of lower left corner of panel.  

 protected var initX:Number;   

protected var initY:Number;

   // Resize area of panel clicked.   

protected function resizeHandler(event:MouseEvent):void    {   

 resizingPanel = Panel(event.target);   

 initX = event.localX;   

 initY = event.localY;         

// Place the rubber band over the panel.    

rbComp.x = event.target.x;    

rbComp.y = event.target.y;    

rbComp.height = event.target.height;    

rbComp.width = event.target.width;        

 // Make sure rubber band is on top of all other components.    

v1.setChildIndex(rbComp, v1.numChildren-1);   

 rbComp.visible=true;        

 // Add event handlers so that the SystemManager handles    

// the mouseMove and mouseUp events.    

// Set useCapure flag to true to handle these events    

// during the capture phase so no other component tries to handle them.     systemManager.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler, true);     systemManager.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler, true);   

}       

// Resizes the rubber band as the user moves the cursor  

 // with the mouse key down.   

protected function mouseMoveHandler(event:MouseEvent):void    {      event.stopImmediatePropagation();              

rbComp.height = rbComp.height + event.stageY - initY;     

 rbComp.width = rbComp.width + event.stageX - initX;           

initX = event.stageX;      initY = event.stageY;        

 }     

  // Sizes the panel to the size of the rubber band when the  

 // user releases the mouse key.  

 // Also removes the event handlers from the SystemManager.   

protected function mouseUpHandler(event:MouseEvent):void    {    

event.stopImmediatePropagation();  

    // Use a minimum panel size of 150 x 50.   

 if (rbComp.height <= 50)     {    

 resizingPanel.height = 50;     

}     else     {    

 resizingPanel.height = rbComp.height;         

 } 

            if (rbComp.width <= 150)     { 

    resizingPanel.width = 150;       

 }     else     { 

    resizingPanel.width = rbComp.width;     

   }    

    // Put the resized panel on top of all other components.    

v1.setChildIndex(resizingPanel, v1.numChildren-1);

    // Hide the rubber band until next time.    

rbComp.x = 0;    

rbComp.y = 0;   

 rbComp.height = 0;  

  rbComp.width = 0;   

 rbComp.visible = false;         

systemManager.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler, true);     systemManager.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler, true );  

 }         ]]>   

</mx:Script>       

<!-- The Canvas is the drag target -->    

<mx:Canvas id="v1"         width="500" height="500"          borderStyle="solid"         backgroundColor="#DDDDDD"         dragEnter="doDragEnter(event);"         dragDrop="doDragDrop(event);">                    

<myComp:DragPanel  id="dp1" title="Drag Panel 1"      paddingLeft="10" paddingRight="10" paddingTop="10" paddingBottom="10"      x="19" y="10"      creationComplete="myPanelCCHandler(event);">

  <mx:TextArea text="Location in Canvas: x = {String(dp1.x)}, and y = {String(dp1.y)}" width="90%"/>     </myComp:DragPanel>

    <myComp:DragPanel  id="dp2"  title="Drag Panel 2"      paddingLeft="10" paddingRight="10" paddingTop="10" paddingBottom="10"      x="149" y="149"      creationComplete="myPanelCCHandler(event);"> 

 <mx:TextArea text="Location in Canvas: x = {String(dp2.x)}, and y = {String(dp2.y)}" width="90%"/>                    

</myComp:DragPanel>

    <myComp:DragPanel id="dp3"  title="Drag Panel 3"      paddingLeft="10" paddingRight="10" paddingTop="10" paddingBottom="10"       x="241" y="283"      creationComplete="myPanelCCHandler(event);">  

<mx:TextArea text="Location in Canvas: x = {String(dp3.x)}, and y = {String(dp3.y)}" width="90%"/>                     

</myComp:DragPanel>

    <myComp:RubberBandComp id="rbComp" x="0" y="0" height="0" width="0" visible="false"/>

    </mx:Canvas>

</mx:Application>

DragPanel类

package myComponents {

 import mx.containers.Panel; 

import mx.core.UIComponent; 

import mx.core.SpriteAsset; 

import mx.events.FlexEvent;

 import flash.events.MouseEvent; 

import flash.events.Event;

 public class DragPanel extends Panel  { 

 // Add the creationCOmplete event handler.  

public function DragPanel()   {   

super();   

addEventListener(FlexEvent.CREATION_COMPLETE, creationCompleteHandler); 

 }    

 // Expose the title bar property for draggin and dropping. 

 [Bindable]  

public var myTitleBar:UIComponent;        

private function creationCompleteHandler(event:Event):void   {   

myTitleBar = titleBar; 

     // Add the resizing event handler.    

addEventListener(MouseEvent.MOUSE_DOWN, resizeHandler);  

}

protected var minShape:SpriteAsset;  

protected var restoreShape:SpriteAsset;

  override protected function createChildren():void   { 

   super.createChildren();      

 // Create the SpriteAsset's for the min/restore icons and  

 // add the event handlers for them.   

minShape = new SpriteAsset();   

minShape.addEventListener(MouseEvent.MOUSE_DOWN, minPanelSizeHandler);    titleBar.addChild(minShape);

   restoreShape = new SpriteAsset();    restoreShape.addEventListener(MouseEvent.MOUSE_DOWN, restorePanelSizeHandler);    titleBar.addChild(restoreShape);   }       override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void   {    super.updateDisplayList(unscaledWidth, unscaledHeight);        // Create invisible rectangle to increase the hit area of the min icon.    minShape.graphics.clear();    minShape.graphics.lineStyle(0, 0, 0);    minShape.graphics.beginFill(0xFFFFFF, 0.0);    minShape.graphics.drawRect(unscaledWidth - 35, 12, 8, 8);

   // Draw min icon.    minShape.graphics.lineStyle(2);    minShape.graphics.beginFill(0xFFFFFF, 0.0);    minShape.graphics.drawRect(unscaledWidth - 35, 18, 8, 2);         // Draw restore icon.    restoreShape.graphics.clear();    restoreShape.graphics.lineStyle(2);    restoreShape.graphics.beginFill(0xFFFFFF, 0.0);    restoreShape.graphics.drawRect(unscaledWidth - 20, 12, 8, 8);    restoreShape.graphics.moveTo(unscaledWidth - 20, 15);    restoreShape.graphics.lineTo(unscaledWidth - 12, 15);

   // Draw resize graphics if not minimzed.        graphics.clear()    if (isMinimized == false)    {     graphics.lineStyle(2);     graphics.moveTo(unscaledWidth - 6, unscaledHeight - 1)     graphics.curveTo(unscaledWidth - 3, unscaledHeight - 3, unscaledWidth - 1, unscaledHeight - 6);           graphics.moveTo(unscaledWidth - 6, unscaledHeight - 4)     graphics.curveTo(unscaledWidth - 5, unscaledHeight - 5, unscaledWidth - 4, unscaledHeight - 6);          }   }         private var myRestoreHeight:int;   private var isMinimized:Boolean = false;         // Minimize panel event handler.   private function minPanelSizeHandler(event:Event):void   {    if (isMinimized != true)    {     myRestoreHeight = height;      height = titleBar.height;     isMinimized = true;      // Don't allow resizing when in the minimized state.     removeEventListener(MouseEvent.MOUSE_DOWN, resizeHandler);    }       }      // Restore panel event handler.   private function restorePanelSizeHandler(event:Event):void   {    if (isMinimized == true)    {     height = myRestoreHeight;     isMinimized = false;      // Allow resizing in restored state.         addEventListener(MouseEvent.MOUSE_DOWN, resizeHandler);    }   }

  // Define static constant for event type.   public static const RESIZE_CLICK:String = "resizeClick";

  // Resize panel event handler.   public  function resizeHandler(event:MouseEvent):void   {    // Determine if the mouse pointer is in the lower right 7x7 pixel    // area of the panel. Initiate the resize if so.        // Lower left corner of panel    var lowerLeftX:Number = x + width;    var lowerLeftY:Number = y + height;         // Upper left corner of 7x7 hit area    var upperLeftX:Number = lowerLeftX-7;    var upperLeftY:Number = lowerLeftY-7;         // Mouse positionin Canvas    var panelRelX:Number = event.localX + x;    var panelRelY:Number = event.localY + y;

   // See if the mousedown is in the lower right 7x7 pixel area    // of the panel.    if (upperLeftX <= panelRelX && panelRelX <= lowerLeftX)    {     if (upperLeftY <= panelRelY && panelRelY <= lowerLeftY)     {        event.stopPropagation();        var rbEvent:MouseEvent = new MouseEvent(RESIZE_CLICK, true);      // Pass stage coords to so all calculations using global coordinates.      rbEvent.localX = event.stageX;      rbEvent.localY = event.stageY;      dispatchEvent(rbEvent);      }    }       }    } }

RubberBandComp类

package myComponents {  import mx.core.UIComponent;

 public class RubberBandComp extends UIComponent  {   public function RubberBandComp()   {    super();   }

  override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void   {    super.updateDisplayList(unscaledWidth, unscaledHeight);         // Draw rubber band with a 1 pixel border, and a grey fill.         graphics.clear();            graphics.lineStyle(1);    graphics.beginFill(0xCCCCCC, 0.5);    graphics.drawRect(0, 0, unscaledWidth, unscaledHeight);   }     } }

Flex图表导出为图片的实用教程 Flex图表组件为数据可视化领域提供了一种高效的解决方案。它能够将复杂的数据集转化为直观的图表形式,便于用户理解和分析。组件不仅适用于展示静态数据,还可以动态展示数据变化,增强数据的表达力。在Web开发中,由于浏览器的同源策略,当一个域下的Web应用尝试去访问另一个域下的资源时,就会触发跨域请求问题。对于开发者来说,这种限制可能会影响诸如Flex图表导出图片的功能实现,尤其是当图表服务器和Web应用服务器不是同一个时。 阅读详情

相关推荐

flex实现的拖拽控件

一个自定义的拖拽flex控件,可以实现复制拖拽,不复制拖拽,可以拖拽图片,也可以由文字拖拽后变成图片。

ADO Recodset对象-CursorType

CursorType 属性指示在 Recordset 对象中使用的游标类型。设置和返回值设置或返回以下某个 CursorTypeEnum 值。常量说明AdOpenForwardOnly仅向前游标,默认值。除了只能在记录中向前滚动外,与静态游标相同。当只需要在记录集中单向移动时,使用它可提高性能。AdOpenKeyset键集游标。尽管从

思源领航 1328

UE4-(IK)实现人物脚贴合地面解决斜坡上脚无旋转无法贴合地面问题

在斜面上脚陷入模型中,需要设置旋转值对脚的骨骼进行一个旋转。 解决思路:在射线检测中可以获取到检测点的法线方向,根据法线方向来计算出脚应该向哪个方向进行适当的旋转,在斜坡上,人物脚需要旋转的轴为x轴和y轴以便来贴合地面,z轴方向的旋转是不需要进行修改的。 如图所示,我们需要求得水平面与斜坡的夹角用来得出人物在x轴上的脚旋转量,在蓝图中提供反正切函数,反正切 = 锐角的邻边/对边 所以 反正切值(脚x轴值(roll)) = 法线Y轴值/法线Z轴 值。 现在将上图的人物想象成面向屏幕,脚需...

Stone的博客 3317

Flex拖动实现方法

    在交互性要求较高的系统中,拖动是一种比较常用的技术,例如,我们经常用到权限定制、数据导入导出定制等功能,这种情况下,一般是目标数据集合已经确定,用户需要从已有的集合中选择条目,使用拖动完成实现起来比较直观,友好;有些场景下需要允许容器内的元素能够自由拖动,例如一些图形设计工具。在Flex中,它本身就提供了很多支持拖动的特性,很多情况下,这些特性能够简化我们的开发,但是也有一些情况是需要我们...

weixin_33894640的博客 213

AltiumDesigner 高效封装库管理 -- samacsys插件实战指南

本文详细介绍了如何利用samacsys插件高效管理AltiumDesigner封装库。通过实战指南,指导用户完成插件安装、云端元件搜索与放置,并分享将海量资源整合为个人标准库的管理策略,从而大幅提升PCB设计效率与可靠性,杜绝封装错误。

weixin_28285943的博客 125

rv1126 SDK编译【2020-0912版本SDK包】

rv1126 sdk 编译

学习记录 1万+

flex控件拖拽效果

<![CDATA[ internal function InitLs():void { var srcArr:Array = new Array(); srcArr.push("China Soft"); srcArr.unshift("BOCO"); srcArr.unshift("PCCW"); SrcLs.dataProvider = sr

jianghuihong2012的专栏 949

【CVPR2025 DEIM】超详细!手把手训练自己的数据集教学:从源码下载,配置虚拟环境,准备数据集、训练、验证、推理测试 ,实现0到1的完整教学过程。本文在win系统上训练,最强实时目标检测算法!

本文详细介绍了CVPR2025 DEIM目标检测模型的完整使用流程。内容包含:1)源码下载与虚拟环境配置;2)Visdrone2019数据集准备与配置文件修改;3)训练参数设置及Windows系统常见问题解决方案;4)模型验证、推理测试及热力图生成方法。特别针对Windows用户提供了虚拟环境配置指导,并详细说明了数据集路径设置、参数调整等关键步骤。通过本文的指导,小伙伴可以快速掌握DEIM模型的使用方法,用于学术论文研究和实验分析。

Ai缝合怪、助力小伙伴高效发论文 7640

antd table源码:虚拟列表和可拖拽/可伸缩列样式互斥解决

所以需要判断是否开启了虚拟列表,如果开启了就使用flex布局,不开启就使用’table-row’使用虚拟列表时,需要实时获取行高,否则内容会显示不全。不开启虚拟列表时,表格内部行元素为td。

weixin_51332774的博客 992

【虚幻引擎UE】UE5 仅需6步轻松实现关卡顺滑切换

【虚幻引擎UE】UE5 仅需6步轻松实现关卡切换

灵境引路人 2万+

QGis二次开发 —— 5、基于qgis开发多种在线地图预览,并加入经纬度坐标显示等(附:源码)

QGis二次开发 —— 5、基于qgis开发多种在线地图预览,并加入经纬度坐标显示等(附:源码

369

CSS3-flex伸缩布局

概述 CSS3 中在布局方面做了非常大的改进,新增了伸缩布局通过该布局方式开发人员对块级元素的布局排列会变得十分灵活,其强大的伸缩性,在响应式开中发挥极大的作用。 将指定元素的 CSS 样式中的 display 属性设置为 flex,这个元素就是一个伸缩布局的容器,其内部的子元素会从左到右水平排列(效果很像浮动)。 简单例子: .box { width: 800px; /* 设置父级盒子为...

weixin_44486539的博客 600

swl安装无法与服务器建立链接,如何解决?

🏆本文收录于《全栈Bug调优(实战版)》专栏,主要记录项目实战过程中所遇到的Bug或因后果及提供真实有效的解决方案,希望能够助你一臂之力,帮你早日登顶实现财富自由🚀;同时,欢迎大家关注&&收藏&&订阅!持续更新中,up!up!up!! 备注:部分问题/疑难杂症搜集于互联网。

**My Coding Family** 2075

element弹框拖拽伸缩

/* * 定义公共js里,在入口文件main.js中import; * 给elementUI的dialog上加上 v-dialogDrag 指令就可以实现弹窗的全屏和拉伸了。 */ // v-dialogDrag: 弹窗拖拽+水平方向伸缩 Vue.directive('alldialogDrag', { bind(el, binding, vnode, oldVnode) { //弹框可拉伸最小宽高 let minWidth = 400; let minHeight..

weixin_38999134的博客 362

【毕设实战】飞行器目标识别系统:基于YOLOv5的智能检测全流程教程,助你毕设脱颖而出

亲爱的同学,毕设是不是让你既期待创新又担心技术门槛?如果你的毕设方向是计算机视觉、智能检测,那这个绝对能成为你的“毕设王牌”。从数据准备到界面开发,我会把整个项目拆成“傻瓜式”步骤,让你能一步步做出属于自己的毕设成果。

know_F0727的博客 104

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

flex布局

flex布局

qq_38806666的博客 223

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

box-sizing、overflow、resize、display、flex

box-sizing 原先说的盒子 margin border padding content 新盒子的计算方式与之不同 旧盒子:boxWidth = width + border2 + padding2; contentWidth = width; 新盒子:boxWidth = width; contentWidth = width - border2 - padding2; ie6混...

weixin_30475039的博客 341

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

REST和Flex

本文来自:http://www.insideria.com/2010/01/rest-and-flex.html 在这个指导文章里,我们开始应用REST和Flex,你是不是在询问,什么是REST,怎么使用REST啊? REST是表述性状态转移(Representational State Transfer),可帮助你提供服务,通过XML与你的数据库沟通。不仅如此,你

lihe111的专栏 3826

可伸缩区域

PC端伸缩效果实现;包括左右区域样式及鼠标拖拽事件

北寻北爱 120

vue拖拽滑动分割面板

需求背景 左边是列表,右边是详情。 想更大范围的查看详情,所以要拖拽滑块,进行面板的分割 整体思路 在布局上,采用flex布局,单位采用百分比。设置flex:1,让其自动伸缩 滑动滑块,计算滑块在滑动过程中,占整个页面的百分比 将百分比,通过动态样式赋值给列表页的宽度 同时改变滑块的位置(也是百分比形式) 其次就是在vue里对鼠标事件的使用 代码实现 在template里 写事件 @mousedown.prevent="mousedown" 在methods里写方法 /** * 按下鼠标

不想起床 1199

Rest和Flex

本文来自:http://www.insideria.com/2010/01/rest-and-flex.html 在这个指导文章里,我们开始应用REST和 Flex ,你是不是在询问,什么是REST,怎么使用REST啊?  REST是表述性状态转移(Representational State Transfer),可帮助你提供服务,通过XML与你的数据库沟通。不仅如此,你可以组合R

guojun828的专栏 966

基于react开发的可伸缩tabs选项卡

1.效果如下所示: 2.自己安装查看效果 先克隆该项目 git clone https://github.com/suwu150/react-flex-tabs.git 然后通过以下命令安装依赖 npm install 通过以下命令运行项目 npm start 3.flex-tabs组件简介 a. 能够通过传入的对...

suwu150 2819

如何听节拍器_如何用Flex Pitch修人声音准节奏?

在Logic Pro X中进行人声修音节奏进行修复,不需要安装例如autotune、melodyne等第三方插件,使用软件自带的Flex Pitch编辑器即可,只不过好像很多同学不知道这个功能在哪儿,这篇文章就简单介绍以下。如何进入Flex Pitch编辑模式?在人声轨的检查器(如果看不到检查器窗口,按一下键盘上的 I 键),找到flex选项,选择fiex pitch。之后双击人声轨道上...

weixin_39623620的博客 1877
上一篇: ValueObject 介绍(VO 模式)
下一篇: Flash中的鼠标右键
marshane
博客等级 码龄19年 6粉丝 22原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值