Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
Adobe Flex SDK Previous
-
None
-
None
-
Affected OS(s): All OS Platforms
Affected OS(s): All OS Platforms
Browser: Firefox 3.x
Language Found: English
Description
Steps to reproduce:
1. Create an application with this 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.core.DragSource;
import mx.core.IUIComponent;
import mx.events.DragEvent;
import mx.graphics.ImageSnapshot;
import mx.managers.DragManager;
var foo:ImageSnapshot
protected function mouseDownOnDragTarget(e:MouseEvent):void
protected function startDragging(event:MouseEvent):void
{ DragManager.doDrag(event.currentTarget as IUIComponent, new DragSource(), event, proxy); removeAll(); }protected function removeAll():void
{ dragMe.removeEventListener(MouseEvent.MOUSE_MOVE, startDragging); dragMe.removeEventListener(MouseEvent.MOUSE_UP, dontStartDragging); }protected function dontStartDragging(event:Event):void
{ removeAll(); }protected function onDragEnter(event:DragEvent):void
{ DragManager.acceptDragDrop(event.currentTarget as IUIComponent); } ]]
>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Group id="dragMe" width="100" height="100" mouseDown="mouseDownOnDragTarget(event)" dragEnter="onDragEnter(event)" dragComplete="removeAll()">
<s:Rect width="100%" height="100%">
<s:stroke>
<s:SolidColorStroke color="0" weight="2" />
</s:stroke>
<s:fill>
<s:SolidColor color="#FFFFFF" />
</s:fill>
</s:Rect>
</s:Group>
<s:Group width="100" height="100" y="110" id="proxy">
<s:Rect width="100%" height="100%">
<s:fill>
<s:SolidColor color="0" />
</s:fill>
</s:Rect>
</s:Group>
</s:Application>
2. Press the run button
3. Drag the white box
Actual Results:
Error: removeChild() is not available in this class. Instead, use removeElement() or modify the skin, if you have one.
at spark.components::Group/removeChild()[E:\dev\hero_private\frameworks\projects\spark\src\spark\components\Group.as:2136]
at mx.core::UIComponent/addChild()[E:\dev\hero_private\frameworks\projects\framework\src\mx\core\UIComponent.as:7136]
at mx.managers::DragManagerImpl/doDrag()[E:\dev\hero_private\frameworks\projects\framework\src\mx\managers\DragManagerImpl.as:290]
at mx.managers::DragManager$/doDrag()[E:\dev\hero_private\frameworks\projects\framework\src\mx\managers\DragManager.as:303]
at DnDError/startDragging()[C:\Users\Amy\Adobe Flash Builder 4.5\DnDError\src\DnDError.mxml:24]
Expected Results: The black box becomes the drag proxy.
Workaround (if any): I guess you could call removeElement before consigning your component to the tender mercies of the Dragmanager, or something like that, but it's only necessary because someone decided to throw an error in removeChild without considering how it would break existing MX code.
Note that the same thing happens if you set the child of a spark container as an MX Image source (one thing I tried as a workaround). I suspect there are a bunch of places in MX and probably even Spark where addChild is implicitly calling removeChild where you could have this issue.