Simple drag and drop application where mc is dragged out of one parent mc and dropped into another parent mc.
All works OK until I added 2 text boxes to the mc's -- one is a non-selectable dynamic text box (a label) which is set by the code, the other is selectable input text that the user can amend.
The text boxes cause some problems:
- Finger cursor disappears when user hovers over the section of the mc that contains the text fields (even non-selectable text??)
- When the user trys to drag the mc by inadvertantly click-dragging anywhere within both text areas it causes this error: TypeError: Error #1034: Type Coercion failed: cannot convert flash.text::TextField@2374a381 to flash.display.MovieClip (same error appears for both text boxes)
- The input text box may confuse the user - how do they sometimes click to drag and sometimes click to amend? I'm thinking the input text needs to be clearly a non-click-drag 'zone' in the mc. (hope that makes sense)
Not sure, but maybe I need to create an overlay area within the mc that is click-detected for the drag?
Any other suggestions?
Here's the relevant bits of code:
var itemArray:Array = [
{iname:"police",ititle:"POLICE OFFICER"},
{iname:"insurance_assessor",ititle:"INSURANCE ASSESSOR"},
{iname:"estimator",ititle:"ESTIMATOR"}
];
for (var i:int=0; i < itemArray.length; i++)
{
var itemname:String = itemArray[i].iname;
var curritem:MovieClip = MovieClip(scrollitems.getChildByName(itemname));
if (curritem != null)
{
curritem.ititle.text = itemArray[i].ititle;
curritem.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
curritem.addEventListener(MouseEvent.MOUSE_UP, dropIt);
curritem.buttonMode = true;
}
}
function pickUp(event:MouseEvent):void
{
var dragIt:MovieClip = MovieClip(event.target); //type casting
var dragPoint:Point = dragIt.parent.localToGlobal(new Point(dragIt.x,dragIt.y));
dragIt.parent.removeChild(dragIt); // remove item from current parent mc
stage.addChild(dragIt); //temp add to stage
dragIt.x = dragPoint.x;
dragIt.y = dragPoint.y;
dragIt.startDrag();
}