我刚刚使我的 itemrenderer(它在视图堆栈中)可拖动,但现在我遇到了以下问题,即我可以在我的视图堆栈中拖动所有东西。我只想拖动整个 itemrenderer 或它的一部分(封面)。此时我还可以拖动整个导航器内容和滚动条(!)。有人可以解决我的问题吗?提前谢谢!
(故障示例及其方式-> http://d.pr/i/hjti)
<fx:Script>
<![CDATA[
// imports
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.controls.Alert;
import mx.core.DragSource;
import mx.managers.DragManager;
import mx.events.DragEvent;
[Bindable]
private var quantity : int = 0;
private function initiateDrag(event:MouseEvent):void {
var dragInitiator:List = event.currentTarget as List;
var source:DragSource = new DragSource();
source.addData(dragInitiator,"cart");
var proxy:Image = new Image();
proxy.source = event.target;
proxy.width = 120;
proxy.height = 150;
proxy.x = (mouseX - (proxy.width * 3.25));
proxy.y = (mouseY - (proxy.height * 3.25));
DragManager.doDrag(dragInitiator, source, event, proxy);
}
private function dragEnterHandler(event:DragEvent):void {
if (event.dragSource.hasFormat("cart")){
DragManager.acceptDragDrop(event.currentTarget as Image);
}
}
private function dragDropHandler(event:DragEvent):void{
Alert.show("Gift added to your favorites");
}
]]>
</fx:Script>
<mx:ViewStack id="myStack" width="100%" height="241" change="doFilter();" creationComplete="doFilter()">
<s:NavigatorContent label="Shooter" >
<!-- hier zet je een tussenruimte van 5-->
<s:List left="10" top="7" width="100%" height="237" borderColor="#CC0000"
borderVisible="false" contentBackgroundAlpha="0.0"
dataProvider="{GamesLijst}" itemRenderer="itemrenderers.GameRenderer"
rollOverColor="#0492B1" dragMoveEnabled="true" dropEnabled="true" mouseDown="initiateDrag(event)">
<s:layout >
<s:TileLayout horizontalGap="10" verticalGap="10" horizontalAlign="left" verticalAlign="top"/>
</s:layout>
</s:List>
</s:NavigatorContent>
<s:NavigatorContent label="Sport">
<!-- hier zet je een tussenruimte van 5-->
<s:List left="10" top="7" width="100%" height="231" borderColor="#CC0000"
borderVisible="false" contentBackgroundAlpha="0.0"
dataProvider="{GamesLijst}" itemRenderer="itemrenderers.GameRenderer"
rollOverColor="#0492B1" dragMoveEnabled="true" dropEnabled="true" mouseDown="initiateDrag(event)">
<s:layout >
<s:TileLayout horizontalGap="10" verticalGap="10" horizontalAlign="left" verticalAlign="top"/>
</s:layout>
</s:List>
</s:NavigatorContent>
我想将图像从视图堆栈中拖到图像中,这是代码:
<s:HGroup includeIn="Home" x="225" width="310" height="90" gap="30" textAlign="left" verticalAlign="middle"> <s:Image width="100" height="100" source="menu/home.png" click.Home="home_clickHandler(event)"/> <s:Image width="100" height="100" source="menu/fav.png" click.Home="favorites_clickHandler(event)" dragEnter="dragEnterHandler(event)" dragDrop="dragDropHandler(event)"/> <s:Image width="100" height="100" source="menu/cart.png" click.Home="cart_clickHandler(event)"/> </s:HGroup>