package tripvisUI { import flash.events.MouseEvent; import mx.containers.Box; import mx.controls.Image; import mx.core.DragSource; import mx.core.UIComponent; import mx.managers.DragManager; import tripvisModel.SimpleTripItem; import tripvisModel.TripItemType; public class MapTripitem extends Box { private var _simpleTripItem: SimpleTripItem; public function MapTripitem(simpleTripItem: SimpleTripItem) { super(); this._simpleTripItem = simpleTripItem; setStyle( "borderStyle", 'solid'); setStyle( "borderThickness", 3 ); setStyle( "dropShadowEnabled", true ); setStyle( "borderColor", TripItemColors.getTripItemColor(_simpleTripItem.type) ); this.addEventListener(MouseEvent.MOUSE_DOWN, mouseEvent_mouseDown); } override protected function createChildren(): void { super.createChildren(); var _image: Image = new Image(); if (_simpleTripItem.thumbnailUrl == "") { _image.source = TripItemDefaultIcons.getDefaultIcon(_simpleTripItem.type); } else { _image.source = _simpleTripItem.thumbnailUrl; } _image.width = 69; _image.height = 46; _image.scaleContent = true; _image.toolTip = _simpleTripItem.name; this.addChild(_image); } private function mouseEvent_mouseDown(event:MouseEvent): void { var dragSource: DragSource = new DragSource(); dragSource.addData(_simpleTripItem, 'SimpleTripItem'); var dragImage: Image = new Image(); dragImage.load(_simpleTripItem.thumbnailUrl); dragImage.width = 50; dragImage.height = 50; DragManager.doDrag(event.currentTarget as UIComponent, dragSource, event, dragImage); } public function get simpleTripItem(): SimpleTripItem { return this._simpleTripItem; } } }