flex-拖放

发布于 2024-11-01 22:26:11 字数 1099 浏览 1 评论 0 原文

我正在尝试在 SkinnableContainer 上拖放一个对象 - 遇到一个非常奇怪的问题

该下降仅发生在几个地方 - 在其他地方它只显示“X”符号,并且在下降时恢复到原始位置。我使用了非常标准的命令...从函数 2 到函数 3,如跟踪语句中所示,调用很少发生 - 关于为什么会发生这种情况有任何指导吗?

我将以下代码添加到 SkinnableContainer: dragEnter="dragEnterHandler(event);" DragDrop="dragDropHandler(event);

(1):

private function mouseMoveHandler(event:MouseEvent):void    
{
  var dragInitiator:Image = Image(event.currentTarget);   
  var ds:DragSource = new DragSource();    
  ds.addData(dragInitiator,"img"); //made change here    
  DragManager.doDrag(dragInitiator, ds, event);
}

(2):

private function dragEnterHandler(event:DragEvent):void {

if (event.dragSource.hasFormat("img"))
{
   trace("came here"); //comes here for each mouse move     
   DragManager.acceptDragDrop(SkinnableContainer(event.currentTarget));
}

(3):

private function dragDropHandler(event:DragEvent):void {    
trace("in drag drop handler"); //doesn't come here for most places

I am trying to drag and drop an object across the SkinnableContainer- am coming across a very strange issue

The drop occurs only at a few places- elsewhere it just shows the "X" sign and on dropping there, reverts to original position. I have used very standard commands... from function 2 to function 3, the call occurs very rarely as seen in trace statements- any guidance on why this happens?

I added the following code to SkinnableContainer: dragEnter="dragEnterHandler(event);" dragDrop="dragDropHandler(event);

(1):

private function mouseMoveHandler(event:MouseEvent):void    
{
  var dragInitiator:Image = Image(event.currentTarget);   
  var ds:DragSource = new DragSource();    
  ds.addData(dragInitiator,"img"); //made change here    
  DragManager.doDrag(dragInitiator, ds, event);
}

(2):

private function dragEnterHandler(event:DragEvent):void {

if (event.dragSource.hasFormat("img"))
{
   trace("came here"); //comes here for each mouse move     
   DragManager.acceptDragDrop(SkinnableContainer(event.currentTarget));
}

(3):

private function dragDropHandler(event:DragEvent):void {    
trace("in drag drop handler"); //doesn't come here for most places

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

遗心遗梦遗幸福 2024-11-08 22:26:11

根据使用 Flex 4 参考:

要将容器用作放置目标,您必须使用容器的 backgroundColor 属性来设置颜色。否则,容器的背景颜色是透明的,拖放管理器无法检测到鼠标指针位于可能的放置目标上。

在接下来的示例中,他们使用 mx 容器 (Canvas),但我检查了 AS3 参考,并且 spark.components.SkinnableContainer 确实有一个样式 背景颜色

我自己没有尝试过,所以请确认是否是这个问题。根据您的描述,只有容器的某些部分正在注册 dragEnter 事件,这似乎是会导致这种效果的考虑因素。

According to the Using Flex 4 reference:

To use a container as a drop target, you must use the backgroundColor property of the container to set a color. Otherwise, the background color of the container is transparent, and the Drag and Drop Manager is unable to detect that the mouse pointer is on a possible drop target.

In the subsequent example, they use an mx container (Canvas), but I checked the AS3 reference, and spark.components.SkinnableContainer does have a style backgroundColor.

I haven't tried this myself, so please confirm whether it is the issue. From your description that only certain parts of the container are registering the dragEnter event, this seems like a consideration that would lead to such effects.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文