Help Converting AS2 to AS3 Drag and Drop Event

Hi All,
This is the second post on help for converting AS2 to AS3. This code is used in Captivate to allow a drag and drop action between two areas (User presses down, drags, and releases in a second area - They are not dragging any object). If anyone can help me convert this please let me know.
Source for Drag and Drop: (Note: Single MovieClip)
// pause the Captivate movie
_root.rdcmndPause = 1;
// when the user's mouse is let go check if there was a successful drop
_root.onMouseUp = function(){
          // If the source area's center coordinate is nearby the destination area's center coordinate then advance the slide
          if ( Math.abs(_root.sourceX + _root.sourceWidth  / 2 + _root.sourceParentX - (_root.destX + _root.destWidth  / 2)) < (_root.destWidth  / 2) &&
                     Math.abs(_root.sourceY + _root.sourceHeight / 2 + _root.sourceParentY - (_root.destY + _root.destHeight / 2)) < (_root.destHeight / 2) )
                    _root.rdcmndNextSlide = 1;
          } else {
                    // show error movie clip for 2 seconds (60 frames at 30 frames per second)
                    _root.showErrorMessage = 60;
  mc.onEnterFrame = function(){
          // continuously update the source area's coordinates and size
          _root.sourceX = mc._x;
          _root.sourceY = mc._y;
          _root.sourceWidth = mc._width;
          _root.sourceHeight = mc._height;
          _root.sourceParentX = _parent._x;
          _root.sourceParentY = _parent._y;
mc.onPress = function(){
          // Uncomment following line to have control click capabilities
          //if(key.isDown(Key.CONTROL))
          // when user clicks on the source area click start the drag
                    startDrag(this);
mc.onRelease = function(){
          // stop drag when user releases the source area
          stopDrag();
Source for Destination Area (Single MovieClip named destArea)
// Set a root variable to control when the error message is displayed
_root.showErrorMessage = -1;
// Use setCoords variable so we only set the destination coordinates once
var setCoords = 0;
destArea.onEnterFrame = function(){
          if (setCoords == 0){
                    // set the destination x, y, width, and height
                    _root.destX = _parent._x;
                    _root.destY = _parent._y;
                    _root.destWidth = _parent._width;
                    _root.destHeight = _parent._height;
          // destination coordinates have been set, change setCoords so it doesn't get set again
          setCoords = 1;
Code for the Error Message (Single MovieClip named errorMessage)
// Don't display the error message initially
errorMessage._alpha = 0;
errorMessage.onEnterFrame = function (){
          // If the drag and drop method detects a missed drop
          // then show this error message by setting _alpha to 100
          if (_root.showErrorMessage > 0){
                    errorMessage._alpha = 100;
                    // decrementing this variable controls the time the
                    // error message will be displayed
                    _root.showErrorMessage--;
          } else {
                    // Don't display the error message
                    errorMessage._alpha = 0;

use:
MovieClip(parent.parent.parent).rdcmndPause=1;
this.addEventListener(KeyboardEvent.KEY_DOWN,keydownF);
function keydownF(e:KeyboardEvent):void{
fscommand("KEYPRESSED", e.keyCode);
if(e.keyCode==32){
MovieClip(parent.parent.parent).rdcmndNextSlide=1;

Similar Messages

  • ADF Drag and drop event inside the single af:treetable

    Hi Experts,
    I have a af:treeTable in my ADF web project and i would like to implement the drag and drop event to the same tree table for supporting my sample test project use case. Currently i am facing some issue to get the source tree node and the destination tree node of the drop and drop event inside my drop listener method. How can i get those object since i need to perform some business operation inside the listener. Please note that i am not using ADF BC4j in my project. The service layer is implemented as EJB and it's being called from the backing bean.
    Looking forward some guide lines to resolve this issue from you experts.
    Thank you.

    It's not a perfect solution, but a work in progress that i'm currently using in my backing bean:
    private RichTree navTree;
    private void exitContainers() {
    boolean success = false;
    while (!success) {
    try {
    navTree.exitContainer();
    } catch (Exception e) {
    success = true;
    private void clearDisclosedRowKeys() {
    if (navTree != null && navTree.getDisclosedRowKeys() != null) {
    RowKeySet rks = navTree.getDisclosedRowKeys();
    Iterator rksIter = rks.iterator();
    while (rksIter.hasNext()) {
    exitContainers();
    List<Integer> rowkey = (List<Integer>) rksIter.next();
    List<Integer> newRowkey = new ArrayList<Integer>();
    for (Integer row : rowkey) {
    if (navTree.isRowAvailable(row)) {
    navTree.setRowIndex(row);
    navTree.enterContainer();
    newRowkey.add(row);
    } else {
    // Row is no longer available
    break;
    if (newRowkey.size() == 0) {
    rks.remove(rowkey);
    } else {
    rowkey.clear();
    rowkey.addAll(newRowkey);
    Whenever you make a 'delete' or 'move' in the tree, call clearDisclosedRowKeys(), it will remove anything that's no longer valid, so your tree won't collapse, and you won't get the error anymore.
    I took out my logging and debug statements, but essentially this just gets all the rows, checks to see if they're valid, and if so creates a new RowKeySet with the valid rows in it.
    Of course make sure you have the setNavTree and getNavTree accessor's created and that they're bound in your JSFF, otherwise navTree will always be null.
    I haven't yet found a way to 'nicely' find out if you're at the top level container, so i'm relying on an Exception to occur to give me that information, if anyone knows a better solution please feel free to share it.

  • AS3 drag and drop masked bitmaps - not working

    I have a drag and drop project using bitmaps that were masked using fireworks. All bitmaps are PNG (fireworks files) and one object is GIF. All objects were converted into movie clips.
    PROBLEM
    All movie clips from PNG's can be dragged, but they can't be dropped. However, the GIF movie clip responds to both drag and drop.
    ActionScript worked when all movie clips had GIF's.
    Is this problem because the objects were masked or for any other reason?
    Note: Objects were masked because their border is very fussy and cropping them doesn't help with the quality of their image.
    // ACTION SCRIPT
    var startX:Number;
    var startY:Number;
    var counter:Number = 0;
    name_mc1.addEventListener(MouseEvent.MOUSE_DOWN, placeUP);
    name_mc1.addEventListener(MouseEvent.MOUSE_UP, placeDown);
    name_mc2.addEventListener(MouseEvent.MOUSE_DOWN, placeUP);
    name_mc2.addEventListener(MouseEvent.MOUSE_UP, placeDown);
    name_mc3.addEventListener(MouseEvent.MOUSE_DOWN, placeUP);
    name_mc3.addEventListener(MouseEvent.MOUSE_UP, placeDown);
    name_mc4.addEventListener(MouseEvent.MOUSE_DOWN, placeUP);
    name_mc4.addEventListener(MouseEvent.MOUSE_UP, placeDown);
    name_mc5.addEventListener(MouseEvent.MOUSE_DOWN, placeUP);
    name_mc5.addEventListener(MouseEvent.MOUSE_UP, placeDown);
    name_mc6.addEventListener(MouseEvent.MOUSE_DOWN, placeUP);
    name_mc6.addEventListener(MouseEvent.MOUSE_UP, placeDown);
    name_mc7.addEventListener(MouseEvent.MOUSE_DOWN, placeUP);
    name_mc7.addEventListener(MouseEvent.MOUSE_UP, placeDown);
    function placeUP(event:MouseEvent):void {
    event.target.startDrag(true);
    mess_txt.text = "";
    event.target.parent.addChild(event.target);
    startX = event.target.x;
    startY = event.target.y;
    function placeDown(event:MouseEvent):void {
    event.target.stopDrag();
    var myTargetName:String = "target" + event.target.name;
    var myTarget:DisplayObject = getChildByName(myTargetName);
    if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){
      mess_txt.text = "Good Job!";
      event.target.removeEventListener(MouseEvent.MOUSE_DOWN, placeUP);
      event.target.removeEventListener(MouseEvent.MOUSE_UP, placeDown);
      event.target.buttonMode = false;
      event.target.x = myTarget.x;
      event.target.y = myTarget.y;
      counter++;
    } else {
      mess_txt.text = "Try Again!";
      event.target.x = startX;
      event.target.y = startY;
    if(counter == 7){
            mess_txt.text = "Congratulations, you're finished!";
    name_mc1.buttonMode = true;
    name_mc2.buttonMode = true;
    name_mc3.buttonMode = true;
    name_mc4.buttonMode = true;
    name_mc5.buttonMode = true;
    name_mc6.buttonMode = true;
    name_mc7.buttonMode = true;
    Thanks for any help!
    German

    Kglad:
    Thanks. Your code worked as well.
    German

  • As3 drag and drop

    hi all
    i have a problem with my drag and drop jigsaw
    everything worked fine before i added the draggable content to a movieclip called pieces_mc which should goto the nextFrame after a target has been filled.
    wondering if you can see what is wrong, i believe i need to point the movieclip to event.target but how to do this??
    stop();
    var startX:Number;
    var startY:Number;
    var counter:Number=0;
    var tries:Number=0;
    finished_mc.visible=false;
    help_file_mc.visible=false;
    pieces_mc.jig1_mc.buttonMode=true;
    pieces_mc.jig2_mc.buttonMode=true;
    pieces_mc.jig3_mc.buttonMode=true;
    pieces_mc.jig4_mc.buttonMode=true;
    pieces_mc.jig5_mc.buttonMode=true;
    pieces_mc.jig6_mc.buttonMode=true;
    pieces_mc.jig7_mc.buttonMode=true;
    pieces_mc.jig8_mc.buttonMode=true;
    pieces_mc.jig9_mc.buttonMode=true;
    pieces_mc.jig10_mc.buttonMode=true;
    pieces_mc.jig1_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    pieces_mc.jig1_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    pieces_mc.jig2_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    pieces_mc.jig2_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    pieces_mc.jig3_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    pieces_mc.jig3_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    pieces_mc.jig4_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    pieces_mc.jig4_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    pieces_mc.jig5_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    pieces_mc.jig5_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    pieces_mc.jig6_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    pieces_mc.jig6_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    pieces_mc.jig7_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    pieces_mc.jig7_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    pieces_mc.jig8_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    pieces_mc.jig8_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    pieces_mc.jig9_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    pieces_mc.jig9_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    pieces_mc.jig10_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    pieces_mc.jig10_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    function pickUp(event:MouseEvent):void {
    event.target.startDrag(true);
    //reply_txt.text="";
    event.target.parent.addChild(event.target);
    startX=event.target.x;
    startY=event.target.y;
    function dropIt(event:MouseEvent):void {
    event.target.stopDrag();
    var myTargetName:String="target"+event.target.name;
    var myTarget:DisplayObject=getChildByName(myTargetName);
    if (event.target.dropTarget!=null&&event.target.dropTarget.parent==myTarget) {
      event.target.play();
      pieces_mc.nextFrame();
      borders_mc.parent.setChildIndex(borders_mc, borders_mc.parent.numChildren-1);
      //reply_txt.text="Good Job!";
      event.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickUp);
      event.target.removeEventListener(MouseEvent.MOUSE_UP, dropIt);
      event.target.buttonMode=false;
      event.target.x=myTarget.x;
      event.target.y=myTarget.y;
      counter++;
    } else {
      //reply_txt.text="Try Again!";
      event.target.x=startX;
      event.target.y=startY;
      tries++;
    if (tries>=15) {
      //tries_txt.text="fi";
    if (counter==10) {
      borders_mc.visible=false;
      targetjig1_mc.visible=false;
      targetjig2_mc.visible=false;
      targetjig3_mc.visible=false;
      targetjig4_mc.visible=false;
      targetjig5_mc.visible=false;
      targetjig6_mc.visible=false;
      targetjig7_mc.visible=false;
      targetjig8_mc.visible=false;
      targetjig9_mc.visible=false;
      targetjig10_mc.visible=false;
      pieces_mc.jig1_mc.visible=false;
      pieces_mc.jig2_mc.visible=false;
      pieces_mc.jig3_mc.visible=false;
      pieces_mc.jig4_mc.visible=false;
      pieces_mc.jig5_mc.visible=false;
      pieces_mc.jig6_mc.visible=false;
      pieces_mc.jig7_mc.visible=false;
      pieces_mc.jig8_mc.visible=false;
      pieces_mc.jig9_mc.visible=false;
      pieces_mc.jig10_mc.visible=false;
      finished_mc.visible=true;
      //reply_txt.text="Congrats, you're finished!";
    thanks in advance for any help
    fonzio

    hi kglad
    well the problem is before i put all of the separate jigsaw pieces into a movieclip called pieces_mc everything was fine, but not now
    i think i need to tell event.target where to find the pieces but i dont know how
    you see i have the target clips in a movieclip on the stage and the pieces themselves inside another movieclip on stage
    so i can no longer pick up a piece
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at gameone_fla::gameone_3/frame1()
    at flash.display::MovieClip/gotoAndPlay()
    at gameone_fla::MainTimeline/nextk()
    I get this error but this has nothing to do with it as it worked fine before and i havent touched this
    this just moves it to the next frame ie the jigsaw
    intro_2.my_btn.addEventListener(MouseEvent.CLICK, nextk);
    function nextk(event:MouseEvent):void {
      gotoAndPlay(2);
    any ideas?
    thanks
    fonzio

  • Help on Final Step for Drag and Drop Exercise

    Does anyone know the best way to create a test item where the learner has to place a check mark in the correct cells and hit submit to succeed. 
    I was using a drag and drop  but I am lost on step three. 
    I am using the check marks as drag sources, square shapes located in all cells will the correct cell/box assigned as the correct drop target.
    The issue is when I get to step three, how do I allow the user to drag ANY checkmark (drag target) to the correct cell/box (drop target).  When I get to step 3, I have to assign each individual  checkmark to ONE specific cell/box and I want the learner to be able to drag any checkmark, as long as it is dropped in a designated drop target.
    If there is another way I should approach this test item instead of drag and drop, I am open to any suggestions.
    Here is an example:

    I purchased the Master Widget from Infosemantics a few months back but between my day job and my schooling for my ID Certification from UC Irvine Extension, I have not had the time to figure it out.
    I thought there would be an easier way but as usual, nothing is a quick fix anymore.  Even when you think your just missing a simple step.
    Thanks,
    Jeff

  • Listening to Drag and Drop event from the extension panel

    How is it possible to detect a drop event from a Layer to a text field in a panel developer using the SDK?
    Drag and drop operation between panel elements are not the issues, but drag and drop from Photoshop and the panel might be an issue.
    Is it possible to implement them?
    If yes, could I be redirected to the documentation topic or can someone post some code snippet ?
    Thanks

    What model of camcorder is your video from and what resolution is it?
    What operating system are you using? Have you ensured that you have the latest version of Quicktime, per the program's requirements?
    Do not convert your video. The program will best with video directly from a camcorder, and converting it may will turn it into a format that it may be LESS likely to work well with.

  • How to drag and drop events across months while in month view?

    Is there a way to drag an event across months when the view is set to monthly view?  I know the events can be dragged and dropped across the days in the month on the screen, but how can I carry through the end of the month - there does not seem to be a way to move the screen view to the next month while the event is being dragged!

    Hi,
    You can do it with keyboard shortcuts.
    Select the event. Press Cmd+X. Press Cmd and right or left arrow (depending if it is forward or back in months) until you are in the correct month. Press Cmd+V to pase on the same day in the new month.
    Best wishes
    John M

  • Help needed with virtual bookshelf - drag and drop between components?

    Hi there,
    Im trying to create a virtual bookshelf, where book spines are individual movie clips that can be dragged and re-ordered on the shelf.  At the moment i can drag the spines to one assigned target, but not any target or 'nudge' the position of the other books along.
    Im sorry if this is a bit vague i'm not that experienced in as3, please feel free to ask any questions and i'll do my best to answer.  Im thinking that an array is necessary which holds the positions, but im not sure how to put it all together!
    Any help greatly appreciated! The code i have so far is:
    import flash.events.MouseEvent;
    import flash.display.MovieClip;
    var dragArray:Array = [red, blue, green, purple, yellow];
    var matchArray:Array = [target1, target2, target3, target4, target5];
    var currentClip:MovieClip;
    var startX:Number;
    var startY:Number;
    for(var i:int = 0; i < dragArray.length; i++) {
    dragArray[i].buttonMode = true;
    dragArray[i].addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);
    matchArray[i].alpha = 0.2;
    function item_onMouseDown(event:MouseEvent):void {
    currentClip = MovieClip(event.currentTarget);
    startX = currentClip.x;
    startY = currentClip.y;
    addChild(currentClip); //bring to the front
    currentClip.startDrag();
    stage.addEventListener(MouseEvent.MOUSE_UP, stage_onMouseUp);
    function stage_onMouseUp(event:MouseEvent):void {
    stage.removeEventListener(MouseEvent.MOUSE_UP, stage_onMouseUp);
    currentClip.stopDrag();
    var index:int = dragArray.indexOf(currentClip);
    var matchClip:MovieClip = MovieClip(matchArray[index]);
    if(matchClip.hitTestPoint(currentClip.x, currentClip.y, true)) {
      //a match was made! position the clip on the matching clip:
      currentClip.x = matchClip.x;
      currentClip.y = matchClip.y;
      //make it not draggable anymore:
      currentClip.removeEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);
      currentClip.buttonMode = false;
    } else {
      //match was not made, so send the clip back where it started:
      currentClip.x = startX;
      currentClip.y = startY;

    Morning kglad, thanks for your help yesterday. I tried the code again and still have the same problems - you cant drop over another book and it nudges that book along aswell as the others to the right. Also if you drop a book back in its originally place - sometimes - it creates a gap next to it. The book still only seem happy in their original starting positions!
    Its very close, im continuing to try fiddle with it to get it working, have the whole of today to try and do this so the coffee is on!
    Ive taken some code out that I realise this morning I didnt't need - e.g the code that stops a book being dragged once you have positioned it (they need to be able to be repositioned more than once, and the code that sends a book back to its original position if you didnt reposition it over a target. If this was foolish please tell me! I have a feeling the latter was!
    so the code im trying to get working at the moment is:
    import flash.events.MouseEvent;
    import flash.display.MovieClip;
    var dragArray:Array = [red, blue, green, purple, yellow];
    var matchArray:Array = [target1, target2, target3, target4, target5];
    var currentClip:MovieClip;
    var startX:Number;
    var startY:Number;
    for(var i:int = 0; i < dragArray.length; i++) {
    // REMOVED
    //dragArray[i].buttonMode = true;
    dragArray[i].addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);
    matchArray[i].alpha = 0.2;
    function item_onMouseDown(event:MouseEvent):void {
    currentClip = MovieClip(event.currentTarget);
    startX = currentClip.x;
    startY = currentClip.y;
    addChild(currentClip); //bring to the front
    currentClip.startDrag();
    stage.addEventListener(MouseEvent.MOUSE_UP, stage_onMouseUp);
    function stage_onMouseUp(event:MouseEvent):void {
    stage.removeEventListener(MouseEvent.MOUSE_UP, stage_onMouseUp);
    currentClip.stopDrag();
    var index:int = dragArray.indexOf(currentClip);
    var matchClip:MovieClip = MovieClip(matchArray[index]);
    if(matchClip.hitTestPoint(currentClip.x, currentClip.y, true)) {
      //a match was made against a target:
      currentClip.x = matchClip.x;
      currentClip.y = matchClip.y;
    //REMOVED
    //make it not draggable anymore:
      //currentClip.removeEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);
      //currentClip.buttonMode = false;
    for(var i:int=dragArray.indexOf(currentClip)+1;i<dragArray.length;i++){
    dragArray[i].x+=currentClip.width;
      // REMOVED
      //else {
      //match was not made, so send the clip back where it started:
      //currentClip.x = startX;
      //currentClip.y = startY;

  • HELP! Why does my Drag and Drop not work Completely?

    Hello! I'm working on an ActionScript 3 movie clip in Adobe Flash. In the interactive movie I want the user to create a snowman with the parts on the left side. (Picture below.)
    On the right side I have the snowman slightly visible, so the user knows where to put the parts. Most of it seems to work... but after I put on the body, hat, and arms the other pieces don't work; like the eyes, nose, mouth, etc. Why does it not work? Can someone help me?
    This is how it should look at the end, when the user complets it.
    I think I coded this correctly. But I'm not sure. Please take a look at my code and see what the problem is. Thanks!!!
    var startX:Number;
    var startY:Number;
    var counter:Number = 0;
    SNOWMAN1_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    SNOWMAN1_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    SNOWMAN2_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    SNOWMAN2_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    SNOWMAN3_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    SNOWMAN3_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    LEFTARM_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    LEFTARM_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    HAT_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    HAT_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    RIGHTARM_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    RIGHTARM_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    SCARF_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    SCARF_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    EYES_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    EYES_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    MOUTH_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    MOUTH_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    CARROT_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    CARROT_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    COLE1_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    COLE1_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    COLE2_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    COLE2_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    COLE3_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    COLE3_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    function pickUp(event:MouseEvent):void {
    event.target.startDrag(true);
    MYTEXTBOX.text = "";
    event.target.parent.addChild(event.target);
    startX = event.target.x;
    startY = event.target.y;
    function dropIt(event:MouseEvent):void {
    event.target.stopDrag();
    var myTargetName:String = "T" + event.target.name;
    var myTarget:DisplayObject = getChildByName(myTargetName);
    if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){
    MYTEXTBOX.text = "Good Job!";
    event.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    event.target.removeEventListener(MouseEvent.MOUSE_UP, dropIt);
    event.target.buttonMode = false;
    event.target.x = myTarget.x;
    event.target.y = myTarget.y;
    counter++;
    } else {
    MYTEXTBOX.text = "Try Again!";
    event.target.x = startX;
    event.target.y = startY;
    if(counter == 13){
            MYTEXTBOX.text = "Congrats, you're finished!";
    SNOWMAN1_mc.buttonMode = true;
    SNOWMAN2_mc.buttonMode = true;
    SNOWMAN3_mc.buttonMode = true;
    LEFTARM_mc.buttonMode = true;
    HAT_mc.buttonMode = true;
    RIGHTARM_mc.buttonMode = true;
    SCARF_mc.buttonMode = true;
    EYES_mc.buttonMode = true;
    MOUTH_mc.buttonMode = true;
    CARROT_mc.buttonMode = true;
    COLE1_mc.buttonMode = true;
    COLE2_mc.buttonMode = true;
    COLE3_mc.buttonMode = true;

    Below is a more efficient code. I am not sure about chasing parents you do in the code (always bad idea) so this code may be buggy:
    var startX:Number;
    var startY:Number;
    var counter:Number = 0;
    // reference to currently dragged object
    var currentTarget:Sprite;
    var objectCollection:Array = [SNOWMAN1_mc, SNOWMAN2_mc, SNOWMAN3_mc, LEFTARM_mc, HAT_mc, RIGHTARM_mc, SCARF_mc, EYES_mc, MOUTH_mc, CARROT_mc, COLE1_mc, COLE2_mc, COLE3_mc];
    activateObjects();
    function activateObjects():void {
         for (var i:int = 0; i < objectCollection.length; i++) {
              currentObject = objectCollection[i] as Sprite;
              currentObject.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
              currentObject.buttonMode = true;
    function pickUp(event:MouseEvent):void {
         currentTarget = event.currentTarget as Sprite;
         currentTarget.startDrag(true);
         MYTEXTBOX.text = "";
         currentTarget.parent.addChild(currentTarget);
         startX = currentTarget.x;
         startY = currentTarget.y;
         stage.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    function dropIt(event:MouseEvent):void {
         stage.removeEventListener(MouseEvent.MOUSE_UP, dropIt);
         stopDrag();
         var myTarget:DisplayObject = getChildByName("T" + currentTarget.name);
         if (currentTarget.dropTarget != null && currentTarget.dropTarget.parent == myTarget){
              MYTEXTBOX.text = "Good Job!";
              currentTarget.removeEventListener(MouseEvent.MOUSE_DOWN, pickUp);
              currentTarget.buttonMode = false;
              currentTarget.x = myTarget.x;
              currentTarget.y = myTarget.y;
              counter++;
         } else {
              MYTEXTBOX.text = "Try Again!";
              currentTarget.x = startX;
              currentTarget.y = startY;
         if (counter == 13) MYTEXTBOX.text = "Congrats, you're finished!";
         currentTarget = null;

  • Help Converting AS2 to AS3 (Spacebar Action in Captivate)

    Hi All,
    There seems to be a lot of these posts on this forum so I thought I would see if anyone could help me out. I had some code developed for me that was in AS2 and I need this in AS3 due to the upgrade in software. Below is the AS2 code:
    _parent._parent._parent.rdcmndPause = 1;
    myListener = new Object();
    myListener.onKeyDown = function () {
              fscommand("KEYPRESSED", Key.getCode());
        If (Key.getCode() == 32)
                        _parent._parent._parent.rdcmndNextSlide = 1;
              EndIf
    Key.addListener(myListener);
    The code is simple really. It was suppose to allow the Spacebar to be used as an input key to go to the next slide in Captivate. There is a single MovieClip in the file. Please let me know.
    Thanks

    use:
    MovieClip(parent.parent.parent).rdcmndPause=1;
    this.addEventListener(KeyboardEvent.KEY_DOWN,keydownF);
    function keydownF(e:KeyboardEvent):void{
    fscommand("KEYPRESSED", e.keyCode);
    if(e.keyCode==32){
    MovieClip(parent.parent.parent).rdcmndNextSlide=1;

  • Please need help converting AS2 to AS3 code

    Hi, I want to convert an AS2 code to AS3. Someone can tell
    what is wrong. (it is about a speed effect) - Thanks a lot.
    mport flash.filters.BlurFilter;
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    var duration:Number = 15;
    var t1:Tween = new Tween(mcToTween1, "_x", Elastic.easeIn,
    133, 367, duration, 0);
    var t2:Tween = new Tween(mcToTween1, "blur", Elastic.easeIn,
    0, 0, 1, true);
    t1.onMotionChanged = function() {
    oldx = x;
    oldy = y;
    x = mcToTween1._x;
    y = mcToTween1._y;
    speedx = Math.round(Math.abs((x-oldx)));
    speedy = Math.round(Math.abs((y-oldy)));
    mcToTween1.filters = [new BlurFilter(speedx*2, speedy*2, 1)];
    trace(speedx);
    t1.onMotionFinished = function() {
    t1.yoyo();
    };

    use:
    MovieClip(parent.parent.parent).rdcmndPause=1;
    this.addEventListener(KeyboardEvent.KEY_DOWN,keydownF);
    function keydownF(e:KeyboardEvent):void{
    fscommand("KEYPRESSED", e.keyCode);
    if(e.keyCode==32){
    MovieClip(parent.parent.parent).rdcmndNextSlide=1;

  • WebView inside JFXPanel: No drag and drop events received

    Hi,
    I'd like to manage Dnd between apps and a Swing application with a JFXPanel which embeds a WebView component.
    Currently, all drops are forbidden on top of the WebView, and I'd like to find a way for the WebView to accept transferable object such as URL...
    Moreover, code like this does not display anything in console. If I create a native JFX application (without JFXPanel Swing layer) the drag events occur.
                    webView.setOnDragDetected(new EventHandler<MouseEvent>() {
                   public void handle(MouseEvent event) {
                        System.err.println(event.toString());
              webView.setOnDragEntered(new EventHandler<DragEvent>() {
                   public void handle(DragEvent event) {
                        System.err.println(event.toString());
              webView.setOnDragOver(new EventHandler<DragEvent>() {
                   @Override
                   public void handle(DragEvent event) {
                        System.err.println(event.toString());                    
              webView.setOnDragDropped(new EventHandler<DragEvent>() {
                   @Override
                   public void handle(DragEvent event) {
                        System.err.println(event.toString());                    
              });I guess JFXPanel catches events, or I missed something...
    If anyone could help, thanks in advance!

    Hi,
    For people who can help, here is the entire code to reproduce the problem.
    JFXPanel seems to consume the DND event, and the JFX WebView component does not receive anything.
    Thanks a lot.
    import java.awt.Dimension;
    import javafx.application.Platform;
    import javafx.embed.swing.JFXPanel;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.input.DragEvent;
    import javafx.scene.input.Dragboard;
    import javafx.scene.input.TransferMode;
    import javafx.scene.paint.Color;
    import javafx.scene.web.WebView;
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    public class WebViewInJFXPanel {
         private void initAndShowGUI() {
              // This method is invoked on Swing thread
              JFrame frame = new JFrame("WebView in JFXPanel");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              final JFXPanel fxPanel = new JFXPanel();
              fxPanel.setOpaque(false);
              fxPanel.setPreferredSize(new Dimension(800,600));
              frame.add(fxPanel);
              frame.pack();
              frame.setVisible(true);
              // Init JFX
              Platform.runLater(new Runnable() {
                   @Override
                   public void run() {
                        initFX(fxPanel);
         private void initFX(JFXPanel fxPanel) {
              // This method is invoked on JavaFX thread
              WebView webView = new WebView();
              webView.getEngine().load("http://javafx.com");
              // The following triggers are never invoked once in a JFXPanel
              webView.setOnDragEntered(new EventHandler<DragEvent>() {
                   public void handle(DragEvent event) {
                        System.err.println(event.toString());
              webView.setOnDragOver(new EventHandler<DragEvent>() {
                   @Override
                   public void handle(DragEvent event) {
                        System.err.println(event.toString());
                        Dragboard db = event.getDragboard();
                        if (db.hasString()) {
                             event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
                        event.consume();
              webView.setOnDragDropped(new EventHandler<DragEvent>() {
                   @Override
                   public void handle(DragEvent event) {
                        System.err.println(event.toString());          
                        Dragboard db = event.getDragboard();
                        boolean success = false;
                        if (db.hasString()) {
                             System.out.println("Dropped: " + db.getString());
                             success = true;
                        event.setDropCompleted(success);
                        event.consume();
              Scene scene = new Scene(webView, 800, 650, Color.BLACK);
              scene.setFill(Color.BLACK);
              fxPanel.setScene(scene);
         public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                   @Override
                   public void run() {
                        new WebViewInJFXPanel().initAndShowGUI();
    }

  • Help with Basics! Dragging and dropping clips

    Good Morning! I've been frustrating myself for weeks just trying to get started. I've uploaded all my video clips through a firewire connection and they look fine. However, when I simply want to drag and drop a clip into the timeline it doesn't work. I have tried it on both the clip and the timeline viewer and have tried cropped and uncroppd videos clips. HELP! I thought this was the easy part. I even have a book, video and online help, but everything says simply "drag and drop clip" Any help is welcome. Thanks! Quail

    Hi Matthew:
    Maybe he could try deleting the iMovie preference files? Seems to fix some of the strangest of problems at times-do you agree?
    Quail:
    Try deleting the imovie preference file. Locate a file named com.apple.imovie.plist and get rid of it. Then empty the trash, run a permissions repair with disk utility and restart. That should do it. The files you need to delete are found in:
    /Users/YourName/Library/Preferences/com.apple.imovie.plist
    Sue

  • Drag and Drop in custom components..

    hello friends,
    I am trying to devlop a schedule component. on part of this i trying to develop a functionality where the user can reschedure the appointment by drag and drop.  the dragdrop event in the container component is not triggered when ther user drag the appointment and drop it in the another container. can any one help me on this please. i have given below my source codes.
    Testbox.as
    package layouts.DayViewControl.containers
        import mx.core.Container;
        public class TestBox extends Container
            private var __timeAndXYCoOrdArray:Array;
            private var __xyDiff:int=0;
            public function TestBox()
                super();
                __timeAndXYCoOrdArray=new Array();
            protected override function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
                super.updateDisplayList(unscaledWidth,unscaledHeight);
                var totalSlots:int=24*2;
                var __lineThickness:int=1;
                var __lineAlpha:int=0.2;
                var boxHeight:uint=unscaledHeight/totalSlots;
                graphics.clear();
                var xPos:int=0;
                var ypos:int=0;
                graphics.lineStyle(2,0x000000,0.5);
                graphics.drawRect(0,0,unscaledWidth,unscaledHeight);
                var __boxHeight:int=unscaledHeight/totalSlots;
                var __minusCount:int=1;
                for(var i:int=0;i<totalSlots;i++){
                    var timeStr:String="";
                    if(i%2 == 0){
                        __lineThickness=2;
                        graphics.lineStyle(__lineThickness,0x000000,0.4);               
                    }else{
                        __lineThickness=1;
                        graphics.lineStyle(__lineThickness,0x000000,0.2);   
                    graphics.moveTo(xPos,ypos);
                    var tempYpos:int=ypos;
                    if(__xyDiff == 0){
                        __xyDiff=ypos-xPos;
                    graphics.lineTo(xPos+unscaledWidth,tempYpos);
                    ypos+=boxHeight;
                    var newYPos:int=0;
                    if(i == 0){
                        timeStr="00:00";
                    }else if(i%2 != 0){
                        if(i<=9){
                            timeStr="0"+(i-__minusCount).toString()+":30";
                        }else{
                            timeStr=(i-__minusCount).toString()+":30";                       
                        newYPos=ypos-__xyDiff;
                    }else if(i%2 == 0){
                        if(i<=9){
                            timeStr="0"+(i-__minusCount).toString()+":00";
                        }else{
                            timeStr=(i-__minusCount).toString()+":00";                       
                        __minusCount+=1;
                        newYPos=ypos-__xyDiff;
                    __timeAndXYCoOrdArray.push({XPos:xPos,YPos:newYPos,Time:timeStr});
            public function getXFromtime(inputTime:String):int{
                var returnVal:int=0;
                if(inputTime && inputTime != ""){
                    for (var j:int=0;j<__timeAndXYCoOrdArray.length;j++){
                        if(__timeAndXYCoOrdArray[j].Time.toString() == inputTime){
                            returnVal=parseInt(__timeAndXYCoOrdArray[j].XPos)
                            break;
                return returnVal;
            public function getYFromtime(inputTime:String):int{
                var returnVal:int=0;
                if(inputTime && inputTime != ""){
                    for (var j:int=0;j<__timeAndXYCoOrdArray.length;j++){
                        if(__timeAndXYCoOrdArray[j].Time.toString() == inputTime){
                            returnVal=parseInt(__timeAndXYCoOrdArray[j].YPos)
                            break;
                return returnVal;
            public function getTimeDifference():int{
                return __xyDiff;
    TimeDividerLines.as
    package layouts.DayViewControl
        import flash.events.MouseEvent;
        import flash.utils.Dictionary;
        import layouts.DayViewControl.containers.TestBox;
        import mx.collections.ArrayCollection;
        import mx.core.DragSource;
        import mx.core.EventPriority;
        import mx.core.UIComponent;
        import mx.events.DragEvent;
        import mx.managers.DragManager;
        public class TimeDividerLines extends TestBox
            private var __linesPerHour:int=4;
            private var __currentDate:Date;
            private var __timeAndXYCoOrdArray:Array;
            private var __dataComponentArry:Array;
            private var __totalAppointment:int=5;
            private var __xyDiff:int=0;
            private var __apptDataInfoArry:Array;
            private var __dataProviderChanged:Boolean=false;
            private var __reArrangeDataArrayCol:ArrayCollection;
            private var __sortedArrayCollection:ArrayCollection;
            private var __dragDropEnabled:Boolean=false;
            public function TimeDividerLines()
                super();
                //__timeAndXYCoOrdArray=new Array();
                __dataComponentArry=new Array();
                __apptDataInfoArry=new Array();
                __sortedArrayCollection=new ArrayCollection();   
            public function set dragDropEnabled(inputVal:Boolean):void{
                if(inputVal){
                    //set youself for drag and drop event
                    this.addEventListener(DragEvent.DRAG_ENTER,dragEnterEventHandler,false,EventPriority.DEFA ULT_HANDLER);
                    this.addEventListener(DragEvent.DRAG_OVER,dragOverEventHandler,false,EventPriority.DEFAUL T_HANDLER);
                    this.addEventListener(DragEvent.DRAG_DROP,dragDropEventHandler,false,EventPriority.DEFAUL T_HANDLER);
                    this.addEventListener(DragEvent.DRAG_COMPLETE,dropCompleteHandler);               
                }else{
                    this.removeEventListener(DragEvent.DRAG_ENTER,dragEnterEventHandler,false);
                    this.removeEventListener(DragEvent.DRAG_OVER,dragOverEventHandler,false);
                    this.removeEventListener(DragEvent.DRAG_DROP,dragDropEventHandler,false);               
                __dragDropEnabled=inputVal;
            private function dropCompleteHandler(event:DragEvent):void{
                trace("inside drop complete handler");
            private function dragEnterEventHandler(event:DragEvent):void{
                if(event.dragSource.hasFormat("Appointment")){
                    var dropTarget:UIComponent=UIComponent(event.currentTarget);
                    DragManager.acceptDragDrop(dropTarget);           
                    DragManager.showFeedback(event.ctrlKey ? DragManager.COPY : DragManager.MOVE);   
                    return;
                DragManager.showFeedback(DragManager.NONE);
            private function dragOverEventHandler(event:DragEvent):void{
                /* if(event.dragSource.hasFormat("Appointment")){
                    if(event.ctrlKey){
                        DragManager.showFeedback(DragManager.COPY);
                        return
                    }else{
                        DragManager.showFeedback(DragManager.MOVE);
                        return
                DragManager.showFeedback(DragManager.NONE); */
            private function dragDropEventHandler(event:DragEvent):void{
                //We need to do two things here. you need to add the dropped data to the data provider list.
                //and need need to update this entry to DB
                 /* if(event.dragSource.hasFormat("Appointment")){
                     var draggedbox:AppointmentDisplayBox=event.dragSource.dataForFormat("Appointment") as AppointmentDisplayBox;
                     var dropBox:TimeDividerLines=event.currentTarget as TimeDividerLines;
                     //create a new copy
                     var newBox:AppointmentDisplayBox=new AppointmentDisplayBox();
                     newBox=draggedbox;
                     newBox.x=dropBox.mouseX;
                     newBox.y=dropBox.mouseY;
                     this.addChild(newBox);
                 trace("11111111111111111111111111111111111111111")
            private function mouseDownHandler(event:MouseEvent):void{
                var draginit:AppointmentDisplayBox=AppointmentDisplayBox(event.currentTarget);
                var ds:DragSource=new DragSource();
                ds.addData(draginit,"Appointment");
                DragManager.doDrag(draginit,ds,event);
            override protected function createChildren():void{
                super.createChildren();
            override protected function commitProperties():void{
                 if(__dataProviderChanged){
                     __dataComponentArry=new Array();
                    for (var k:int=0;k<__apptDataInfoArry.length;k++){
                        var tempDispBox:AppointmentDisplayBox=new AppointmentDisplayBox();
                        tempDispBox.currentDate=this.currentDate;
                        tempDispBox.startTime=__apptDataInfoArry[k].StartTime.toString();
                        tempDispBox.endTime=__apptDataInfoArry[k].EndTime.toString();
                        tempDispBox.apptDataXml=__apptDataInfoArry[k].Data as XML;       
                        tempDispBox.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);           
                        this.addChild(tempDispBox);
                        __dataComponentArry.push(tempDispBox);
                    __dataProviderChanged=false;
            private function sortTheCollectionValues(__inputArrayCol:ArrayCollection):ArrayCollection{
                var returnArrayCollection:ArrayCollection=new ArrayCollection();
                var tempArray:Array=new Array();
                for(var i:int=0;i<__inputArrayCol.length;i++){
                    tempArray.push({Length:(__inputArrayCol[i] as Array).length,Index:i});
                tempArray.sortOn("Length",Array.DESCENDING|Array.NUMERIC);
                for(var j:int=0;j<tempArray.length;j++){
                    returnArrayCollection.addItem(__inputArrayCol[tempArray[j].Index]);
                return returnArrayCollection;
            override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
                super.updateDisplayList(unscaledWidth,unscaledHeight);
                if(__dataComponentArry.length > 0){
                    __sortedArrayCollection=new ArrayCollection();
                    sortArray(__dataComponentArry);
                if(__sortedArrayCollection.length > 0 ){
                    //you need to sort the arraycollection based on the length first to draw the highest no. child array first
                    __sortedArrayCollection=sortTheCollectionValues(__sortedArrayCollection);
                    var appGap:int=2;
                    var endGap:int=10;
                    //var drawnApptObj:Array=new Array();
                    var existingChildArray:Array=new Array();   
                    var drawnApptObj:Dictionary=new Dictionary();
                    for(var l:int=0;l<__sortedArrayCollection.length;l++){
                        var apptWidth:int=0;
                        var innerArry:Array=__sortedArrayCollection[l] as Array;
                        existingChildArray=new Array();
                        //you need to recalculate the width
                        //for the first iteration you need to sort by height
                        //if(l == 0){
                        //    innerArry.sortOn("apptHeight",Array.NUMERIC|Array.DESCENDING);
                        //}else{
                            innerArry.sortOn(["isChild","apptHeight"],Array.NUMERIC|Array.DESCENDING);   
                        //innerArry.sortOn("apptHeight",Array.NUMERIC|Array.DESCENDING);
                        //first we need to find out any intersection appointment is there
                        var count:int=0;
                         for each(var tempApptDispBox:AppointmentDisplayBox in innerArry){
                            if(drawnApptObj[tempApptDispBox] == tempApptDispBox){
                                if(apptWidth < tempApptDispBox.width){
                                    apptWidth=tempApptDispBox.width;
                                    existingChildArray.push({index:count,object:tempApptDispBox});
                            count++;
                        if(apptWidth == 0){
                            apptWidth=(unscaledWidth - (endGap + (appGap*innerArry.length)))/innerArry.length;
                        //now you need to layout the childrens
                        var canDraw:Boolean=false;
                        var ismatch:Boolean=false;
                        for (var childCnt:int=0;childCnt < innerArry.length;childCnt++){
                             var tempDispBox:AppointmentDisplayBox=innerArry[childCnt] as AppointmentDisplayBox;
                             for (var i:int=0;i<existingChildArray.length;i++){
                                 if(existingChildArray[i].index == childCnt){
                                     ismatch=true;
                                     break;
                            if(childCnt == 0 && !ismatch){
                                tempDispBox.x=this.getXFromtime(tempDispBox.startTime.toString())+2;
                                canDraw=true;
                            }else if(existingChildArray.indexOf(childCnt) > -1 && childCnt != 0){
                                //tempDispBox.x=(existingChildArray[childCnt] as AppointmentDisplayBox).x+apptWidth+appGap;
                                canDraw=false;
                            }else if(childCnt != 0 && !ismatch){
                                tempDispBox.x=((existingChildArray[childCnt-1].object) as AppointmentDisplayBox).x+apptWidth+appGap;
                                canDraw=true;
                            if(canDraw){
                                tempDispBox.y=this.getYFromtime(tempDispBox.startTime.toString());   
                                tempDispBox.width=apptWidth;
                                tempDispBox.height=tempDispBox.apptHeight-2;
                                if(tempDispBox.isChild){
                                    drawnApptObj[tempDispBox]=tempDispBox;
                                existingChildArray.push({index:childCnt,object:tempDispBox});
                            canDraw=false;
                            ismatch=false;
                //first we need to sort the component array based on the height property to position the biggest appointment first
            private function sortArray(tempArry:Array):void{
                //var tempArry:Array=arrayClone(__datacompArray);
                 for(var i:int=0;i<tempArry.length;i++){
                     var tempDispBox:AppointmentDisplayBox=tempArry[i] as AppointmentDisplayBox;
                    var start:int=this.getYFromtime(tempDispBox.startTime.toString());
                    var end:int=this.getYFromtime(tempDispBox.endTime.toString());
                    tempDispBox.apptHeight=end-start;
                var indexArray:Array=new Array();
                var canContinue:Boolean=false;
                var loopArray:Array=new Array();
                loopArray=tempArry.concat(); // this will copy the array to loopArray
                var copyArry:Array=new Array();
                var k:int=0;
                while(k<loopArray.length){
                    loopArray.sortOn("apptHeight",Array.NUMERIC|Array.DESCENDING);
                    if(indexArray.length > 0){
                        if(indexArray.indexOf(k) >= 0){
                            canContinue=false;
                        }else{
                            canContinue=true;
                    }else{
                        canContinue=true;
                    if(canContinue){
                        var newArry:Array=new Array();
                        //newArry.push(tempArry[k]);                   
                        for (var innerCnt:int=0;innerCnt<loopArray.length;innerCnt++){
                            var locCanContinue:Boolean=false;
                            if(indexArray.length > 0){
                                if(indexArray.indexOf(innerCnt) >= 0){
                                    locCanContinue=false;
                                }else{
                                    locCanContinue=true;
                            }else{
                                locCanContinue=true;
                            if(locCanContinue && k != innerCnt){
                                var outerstartTime:Number=parseFloat(loopArray[k].startTime.toString().replace(":","."));
                                var outerendtime:Number=parseFloat(loopArray[k].endTime.toString().replace(":","."));
                                var innerStartTime:Number=parseFloat(loopArray[innerCnt].startTime.toString().replace(":","." ));
                                var innerEndtime:Number=parseFloat(loopArray[innerCnt].endTime.toString().replace(":","."));
                                if(outerstartTime == innerStartTime && outerendtime == innerEndtime){
                                    //newArry.push(tempArry.splice(innerCnt,1));
                                    newArry.push(loopArray[innerCnt]);
                                    indexArray.push(innerCnt);
                                }else if(outerstartTime == innerStartTime && outerendtime > innerEndtime){
                                    //newArry.push(tempArry.splice(innerCnt,1));
                                    newArry.push(loopArray[innerCnt]);
                                    indexArray.push(innerCnt);
                                }else if(outerstartTime  < innerStartTime && outerendtime == innerEndtime){
                                    //newArry.push(tempArry.splice(innerCnt,1));
                                    newArry.push(loopArray[innerCnt]);
                                    indexArray.push(innerCnt);
                                }else if(outerstartTime  < innerStartTime && outerendtime > innerEndtime){
                                    //newArry.push(tempArry.splice(innerCnt,1));
                                    newArry.push(loopArray[innerCnt]);
                                    indexArray.push(innerCnt);
                                }else if(outerstartTime > innerStartTime && outerendtime > innerEndtime && innerEndtime > outerstartTime){
                                    //newArry.push(tempArry.splice(innerCnt,1));
                                    newArry.push(loopArray[innerCnt]);
                                    loopArray[innerCnt].isChild=true;
                                    //indexArray.push(innerCnt);
                                }else if(outerstartTime < innerStartTime && outerendtime < innerEndtime && innerStartTime < outerendtime){
                                    //newArry.push(tempArry.splice(innerCnt,1));
                                    newArry.push(loopArray[innerCnt]);
                                    loopArray[innerCnt].isChild=true;
                                    //indexArray.push(innerCnt);
                                }else if(outerstartTime == innerStartTime && outerendtime < innerEndtime){
                                    newArry.push(loopArray[innerCnt]);
                                    loopArray[innerCnt].isChild=true;
                                }else if(outerstartTime > innerStartTime && outerendtime == innerEndtime){
                                    newArry.push(loopArray[innerCnt]);
                                    loopArray[innerCnt].isChild=true;
                        //newArry.push(tempArry.splice(k,1));
                        indexArray.push(k);
                        newArry.push(loopArray[k]);
                        __sortedArrayCollection.addItem(newArry);                   
                    copyArry=loopArray.concat();
                    loopArray=new Array();
                    for (var j:int=0;j<copyArry.length;j++){
                        if(indexArray.indexOf(j) < 0){
                            loopArray.push(copyArry[j]);
                    indexArray=new Array();               
            private function arrayClone(source:Array):Array{
                var returnArray:Array=new Array();
                for(var j:int=0;j<source.length;j++){
                    returnArray.push(source[j]);
                return returnArray;
            public function set currentDate(inputVal:Date):void{
                if(__currentDate != inputVal){
                    __currentDate=inputVal;
            public function get currentDate():Date{
                return __currentDate;
            public function set apptDataArray(inputVal:Array):void{
                if(!__dataProviderChanged && inputVal.length > 0){
                    __apptDataInfoArry=inputVal;
                    __dataProviderChanged=true;
                    invalidateProperties();
                    invalidateDisplayList();
    AppointmentDisplayBox.as
    package layouts.DayViewControl
        import mx.controls.TextInput;
        import mx.core.UIComponent;
        public class AppointmentDisplayBox extends UIComponent
            private var __startTime:String;
            private var __EndTime:String;
            private var __currentDate:Date;
            private var __apptData:XML;
            private var __height:Number;
            private var __isChild:Boolean=false;
            private var __modifiedWidth:Boolean=false;
            private var __docNameLable:TextInput;
            private var __appDetails:TextInput;
            public function AppointmentDisplayBox()
                super();
                this.setStyle("horizontalScrollPolicy","off");
                this.setStyle("verticalScrollPolicy","off");
                this.setStyle("borderStyle","solid");
                this.setStyle("verticalGap","0");
                this.setStyle("borderStyle","outset");       
                this.buttonMode=true;           
            protected override function createChildren():void{
                super.createChildren();
                if(!__docNameLable){
                    __docNameLable=new TextInput();
                    __docNameLable.editable=false;
                    __docNameLable.setStyle("horizontalScrollPolicy","off");
                    __docNameLable.setStyle("verticalScrollPolicy","off");
                    __docNameLable.setStyle("borderStyle","none");
                    //__docNameLable.setStyle("borderThickness","0");
                    __docNameLable.buttonMode=true;
                    addChild(__docNameLable);
                if(!__appDetails){
                    __appDetails=new TextInput();
                    __appDetails.editable=false;   
                    __appDetails.setStyle("horizontalScrollPolicy","off");
                    __appDetails.setStyle("verticalScrollPolicy","off");
                    __appDetails.setStyle("borderStyle","none");
                     __appDetails.setStyle("backgroundColor","0xB1FB17");
                     __appDetails.buttonMode=true;
                //    __appDetails.setStyle("borderThickness","0");
                    addChild(__appDetails);
            protected override function commitProperties():void{
                super.commitProperties();
                 if(__apptData != null){
                    __docNameLable.text=__apptData.DocName.toString();
                    __appDetails.text=__apptData.PatientID.toString()+"\n"+__apptData.Description.toString();                
                    invalidateDisplayList();
            protected override function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
                super.updateDisplayList(unscaledWidth,unscaledHeight);
                __docNameLable.setActualSize(unscaledWidth-1,20);
                __docNameLable.move(1,1);
                graphics.clear();
                var lineColor:uint=0x000000;
                graphics.lineStyle(1,lineColor,1);
                graphics.beginFill(0xFEFDFD,1)
                graphics.drawRect(0,0,unscaledWidth,22);
                graphics.endFill();
                __appDetails.setActualSize(unscaledWidth-1,unscaledHeight-22);
                __appDetails.move(1,23);
                graphics.drawRect(0,22,unscaledWidth,unscaledHeight-20);
            public function set startTime(inputVal:String):void{
                __startTime=inputVal;
            public function get startTime():String{
                return __startTime;
            public function set endTime(inputVal:String):void{
                __EndTime=inputVal;
            public function get endTime():String{
                return __EndTime;
            public function set currentDate(inputVal:Date):void{
                __currentDate=inputVal;
            public function get currentDate():Date{
                return __currentDate;
            public function set apptHeight(inputVal:Number):void{
                __height=inputVal;
            public function get apptHeight():Number{
                return __height;
            public function set isChild(inputVal:Boolean):void{
                __isChild=inputVal;
            public function get isChild():Boolean{
                return __isChild;
            public function set isModifiedWidth(inputVal:Boolean):void{
                __modifiedWidth=inputVal;
            public function get isModifiedWidth():Boolean{
                return __modifiedWidth;
            public function set apptDataXml(inputVal:XML):void{
                if(__apptData != inputVal){
                    __apptData=inputVal;
                    invalidateProperties();
                    invalidateDisplayList();
            public function get apptDataXml():XML{
                return __apptData;
    Test.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:layouts="layouts.*"
        xmlns:DayViewControl="layouts.DayViewControl.*" xmlns:test="layouts.DayViewControl.containers.*">
        <mx:Script>
            <![CDATA[
                import mx.controls.TextInput;
                import layouts.DayViewControl.TimeDividerLines;
                import mx.events.DragEvent;
                import mx.managers.DragManager;
                import mx.core.DragSource;
                import layouts.DayViewControl.AppointmentDisplayBox;
                private function mouseDownHandler(event:MouseEvent):void{
                    var dragint:AppointmentDisplayBox=AppointmentDisplayBox(event.currentTarget);
                    //var dragint:TextInput=TextInput(event.currentTarget);
                    var ds:DragSource=new DragSource();
                    ds.addData(dragint,"Appoitment");
                    DragManager.doDrag(dragint,ds,event);               
                private function dragEnterHandler(event:DragEvent):void{
                    if(event.dragSource.hasFormat("Appoitment")){
                        var droptarget:TimeDividerLines=TimeDividerLines(event.currentTarget);
                        DragManager.acceptDragDrop(droptarget);
                        DragManager.showFeedback(event.ctrlKey?DragManager.COPY:DragManager.MOVE);
                        return;
                    DragManager.showFeedback(DragManager.NONE);
                private function dragDropHandler(event:DragEvent):void{
                    if(event.dragSource.hasFormat("Appoitment")){
                        var droppedObj:AppointmentDisplayBox=AppointmentDisplayBox(event.dragSource.dataForFormat("Ap poitment"));
                        //var droppedObj:TextInput=TextInput(event.dragSource.dataForFormat("Appoitment"));
                        var dropTarget:TimeDividerLines=TimeDividerLines(event.currentTarget);
                        droppedObj.x=dropTarget.mouseX;
                        droppedObj.y=dropTarget.mouseY;
                        dropTarget.addChild(droppedObj);
            ]]>
        </mx:Script>
        <mx:HBox width="100%" height="100%">
            <DayViewControl:TimeDividerLines width="50%" height="100%">
                <DayViewControl:AppointmentDisplayBox width="50" height="100" mouseDown="mouseDownHandler(event)"/>
            </DayViewControl:TimeDividerLines>
            <DayViewControl:TimeDividerLines width="50%" height="100%" dragEnter="dragEnterHandler(event)" dragDrop="dragDropHandler(event)"/>
        </mx:HBox>
    </mx:Application>

    First 3 .as are the component
    source. in the last test.mxml file i have written the drag and drop functionality.
    can any help me?? please

  • Drag and drop tracks in a playlist problem

    I have created a playlist and now want to reorganize the current alphabetically-organized tracks a bit. I don't see any specific discussion of how to do this in iTunes Help but it alludes to "dragging and dropping". I have tried this and I am able to "drag" a track but when I try to "drop" it at a new spot it returns to its original spot. Also, I expected that I could cause the page to scroll by dragging the track to the bottom of the page but when I do nothing happens. What am I missing?

    Make sure you click the leftmost header (for the column with the numbers) to sort before you attempt to change the track order. If you have the playlist sorted by any other column, you won't be able to drag the track order. Also make sure the playlist isn't set to shuffle.
    Hope this helps.
    Message was edited by: Dave Sawyer

Maybe you are looking for

  • Cpu caller 0

    Mac mid 2010. Some weeks ago my mac started to shut down randomly. Either i was browsing the internet or using photoshop. When i starts up again by itself it says, "Cpu caller 0, 1, 2 and sometimes 3. I have tried to reinstall OS X, but with no luck.

  • Upgrade MDS 9124E Fabric Switch hor HP c-Class

            Hi all SAN switches MDS95XX and MDS9124e24 port  must be upgraded from NX-OS 4.1.3a to NX-OS 5.2.2d I have no details on the process for switch HP 9124 e. Is it disruptif  . How many steps from 4.1.3a to 5.2.2d . Generally is the process the

  • Re: Apple Email Address for Customer Complaints?

    The problem is that since Apple charges a premium, the buyer deserves a trouble free product for the price. If the P.O.S. needs repairs in the first six months of service then obviously something went wrong during the manufacturing process. Apple oug

  • ORA-01092 Error When Attempting to Create Database

    hi all, i'm attempting to run the following SQL in order to create a database called LEAF. however, i'm receiving an ORA-01092 error message as shown when I attempt to do this. does anyone see any problem with my database creation script or have any

  • HT4623 Unable to install iOS6

    I have an iPhone4 and after downloading the update it says "unable to install update. An error occurred installing iOS6. Now what?