Hi help me with drag and drop with as3 if you please

Hello friends,

I am a newbie to as3 in flash and had a prob with drag and drop features

var dragArray:Array = [square_word, circle_word, triangle_word];

var matchArray:Array = [squareMatch, circleMatch, triangleMatch];

var posArray:Array = [{x: 276, y: 207}, {x: 443, y: 207}, {x: 107, y: 207}];

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 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 int index = dragArray.indexOf (currentClip);

var matchClip:MovieClip = MovieClip (matchArray [index]);

If (matchClip.hitTestPoint (currentClip.x, currentClip.y, true)) {}

a match was found. Position the clip using the values of posArray:

currentClip.x = posArray [index] .x;

currentClip.y = there posArray [index];

make not draggable:

currentClip.removeEventListener (MouseEvent.MOUSE_DOWN, item_onMouseDown);

currentClip.buttonMode = false;

} else {}

football match has not, so send the clip to the back where he began:

currentClip.x = startX;

currentClip.y = startY;

}

in this code, that I'm not the subject abruptly to its original position if he fell into a movieclip wrong (as we should have the availability of droping the drag square circle alse object) and then we should have a button to check if everything is correctly matched, if not after clicking another button 'correctitself', we should get the good objects droping on correct locations automatically

Please help with any suggestions ASAP

}

assign your listener matchall checkAllMatchF and use button:

var dragArray:Array = [square_word, circle_word, triangle_word];

var matchArray:Array = [squareMatch, circleMatch, triangleMatch];

var posArray:Array = [{x: 276, y: 207}, {x: 443, y: 207}, {x: 107, y: 207}];

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 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 int index = dragArray.indexOf (currentClip);

var matchClip:MovieClip = MovieClip (matchArray [index]);

If (matchClip.hitTestPoint (currentClip.x, currentClip.y, true)) {}

a match was found. Position the clip using the values of posArray:

currentClip.x = posArray [index] .x;

currentClip.y = there posArray [index];

make not draggable:

currentClip.removeEventListener (MouseEvent.MOUSE_DOWN, item_onMouseDown);

currentClip.buttonMode = false;

} else {}

football match has not, so send the clip to the back where he began:

currentClip.x = startX;

currentClip.y = startY;

}

}

function checkAllMatchF (): Boolean {}

for (var i: int = 0; i<>

If (dragArray [i] .x! = matchArray [i] .x | dragArray [i] there! = matchArray [i] there) {}

Returns false;

}

}

Returns true;

}

Tags: Adobe Animate

Similar Questions

  • Drag and Drop Listbox - help

    Hello! I'm back to LabVIEW programming and fell on a problem that I can't solve.

    I am trying to use dag and drop on a list box. I put to move only and it works fine. The problem is that if I drop the moved element event goes just far. I couldn't find examples or answers in the forums.

    Someone wants to teach me about drag and drop?

    Thank you

    It is not unstraightforward.  Shift register keeps the value of the listbox on departure of drag (ie. the index of the item).

  • Drag-and - drop AS3

    I am Luciano I Milano Italy, I have a problem with drag drop in AS3 and I would like to know if possible to use the correct method for this project, because I stopped and that's why on that I'm not not to be able to go.
    I started a project named Puzzle so I'd realizate with drag-and - drop in AS3 but I have some problems with it, and I am very strongly if something can help me.
    Imagine my project use the BitMap class to create and to use the copypixel method to create a grid brik which contains a call and that stored in a table and completely visible.
    (1) - first problem is to move all the brik for grilling at an another correct grill.
    (2) - second problem, I want to say where I can mix a brik stored in a table.
    to simply understand I attach my code

    Thank you for all that Luciano

    Sorry, but your advice is not good for this example because it is not working properly.
    I try to change a method setPres, but nothing happens when I click in a piece by dragging doesn't work.
    I thought a lot to try it, but I did not find the right solution, after my test I said, the problem consist to identify a table object because there is no property in a cell and that the event does not identify a specific piece that is stored in the table and the startDrag() method return false statement otherwise I can not know to solve using this change.

  • Drag and Drop development tool for OA Framework

    Hello! Are there Drag and Drop of the development tools for OAF for ebs R12? I know this has been asked before, but most of the positions have been since 2007 or 2009. Maybe there was a recent version of JDeveloper which supports Drag and Drop?

    Thank you!

    Hello

    According to my understanding.

    Drag and Drop the features not available in Office Tools framework Jdeveloper.

    You need to declaratively or programmatically implementation.

    Thank you

    Dilip

  • Drag and Drop in Captivate 6

    Hello

    I have a Captivate 6 company licensed version. I would like to know how to use interaction drag-and - drop.

    Thanking you.

    Regarding

    Leena

    What version of Captivate 6 do you have? Drag / move activity is included in Captivate 6.1 from. For earlier versions, the best would be to buy Infosemantics widget here:

    http://Infosemantics.com.au/Adobe-Captivate-widgets/drag-and-drop/which-Adobe-drag-and-DRA g-and-decline-widget-comparison

    Anthony

  • Drag and drop with a Flash response... Help, please

    Hello

    I just started with flash and actionscript3 about 5 weeks ago. I am in my first year uni and I have an assignment to slide / move (for a kindergarten class). His "little red hen" and they place the correct image to the right holder.

    I got drag and drop work but I can't seem to find a way display a check mark when they place in the correct holder.

    Help, please...

    It's my script (it may seem messy... still new)

    import flash.events.MouseEvent;

    / * Mouse event that ensures the function of hen movieclip to start dragging
    When the mouse is pressed * /.

    hen1_mc.addEventListener (MouseEvent.MOUSE_DOWN, opportunity);
    hen2_mc.addEventListener (MouseEvent.MOUSE_DOWN, opportunity);
    hen3_mc.addEventListener (MouseEvent.MOUSE_DOWN, opportunity);
    hen4_mc.addEventListener (MouseEvent.MOUSE_DOWN, opportunity);
    hen5_mc.addEventListener (MouseEvent.MOUSE_DOWN, opportunity);
    hen6_mc.addEventListener (MouseEvent.MOUSE_DOWN, opportunity);


    Ability to function (event: MouseEvent): void
    {
    event.target.startDrag ();
    }

    / * Mouse event that ensures the function of hen movieclip to drop
    When the mouse button is released with Condition statement, if
    owner = hen, hen snaps into place * /.

    hen1_mc.addEventListener (MouseEvent.MOUSE_UP, dragStop1);
    function dragStop1 (event: MouseEvent): void
    {
    hen1_mc.stopDrag ();
    If (hen1_mc.hitTestObject (holder1_mc) is true)

    {
    hen1_mc.x = holder1_mc.x;
    hen1_mc.y = holder1_mc.y;
    }
    }


    hen2_mc.addEventListener (MouseEvent.MOUSE_UP, dragStop2);
    function dragStop2 (event: MouseEvent): void
    {
    hen2_mc.stopDrag ();
    If (hen2_mc.hitTestObject (holder2_mc) == true)
    {
    hen2_mc.x = holder2_mc.x;
    hen2_mc.y = holder2_mc.y;
    }
    }


    hen3_mc.addEventListener (MouseEvent.MOUSE_UP, dragStop3);
    function dragStop3 (event: MouseEvent): void
    {
    hen3_mc.stopDrag ();
    If (hen3_mc.hitTestObject (holder3_mc) == true)
    {
    hen3_mc.x = holder3_mc.x;
    hen3_mc.y = holder3_mc.y;
    }
    }

    hen4_mc.addEventListener (MouseEvent.MOUSE_UP, dragStop4);
    function dragStop4 (event: MouseEvent): void
    {
    hen4_mc.stopDrag ();
    If (hen4_mc, hitTestObject (holder4_mc) is true)
    {
    hen4_mc.x = holder4_mc.x;
    hen4_mc.y = holder4_mc.y;
    }
    }

    hen5_mc.addEventListener (MouseEvent.MOUSE_UP, dragStop5);
    function dragStop5 (event: MouseEvent): void
    {
    hen5_mc.stopDrag ();
    If (hen5_mc.hitTestObject (holder5_mc) == true)
    {
    hen5_mc.x = holder5_mc.x;
    hen5_mc.y = holder5_mc.y;
    }
    }

    hen6_mc.addEventListener (MouseEvent.MOUSE_UP, dragStop6);
    function dragStop6 (event: MouseEvent): void
    {
    hen6_mc.stopDrag ();
    If (hen6_mc.hitTestObject (holder6_mc) == true)
    {
    hen6_mc.x = holder6_mc.x;
    hen6_mc.y = holder6_mc.y;
    }
    }

    You alreadsy have conditional statements in place as far as I can tell, you just need to add the ActionScript to display the tick...

    function dragStop1 (event: MouseEvent): void

    {

    hen1_mc.stopDrag ();

    If (hen1_mc.hitTestObject (holder1_mc))

    {

    hen1_mc.x = holder1_mc.x;

    hen1_mc.y = holder1_mc.y;

    View the tick code goes here

    }

    }

  • Need help with drag and drop

    IM really new to this program as a

    day new hehe and I need help. im making a game quiz and your supposed

    ED to score in the hoop with a circle.  I have the

    codes for the drag and drop for the circle, but I need help with the collision between the Hoop and the ball, I want to go to the image next or gotoandPlay when the ball touches the ring. HELP PLEASE

    You should not attach code to objects.  and you can be able to happen by using a loop.

    Start by removing all the code the suggested by maqro (i.e. as3) and by removing all the code attached to objects.

    use:

    {yourobject.onPress = function ()}

    this.startDrag ();

    }

    {yourobject.onRelease = yourobject.onReleaseOutside = function ()}

    this.stopDrag ();

    {if (this.) HitTest (whatever))}

    do something

    }

    }

  • With the help of Hewlett Packard Win 7 64 bit with Lightroom 5.7. I have read many explanations of how to drag and drop digital images in Lightroom - but I never got.  I need to know WHERE LTRM drop, HOW to find them and how to get them I

    I need to know EXACTLY how to drag and drop digital pictures into LTRM. WHERE to put them. HOW to find them. How to MOVE in the DEVELOPMENT MODULE.

    When you drag / drop photos, you actually perform a step to import, so it would be wise to figure out how to import your photos and all of the affected options. I agree with Jim Hess and al., drag / drop are an easy way to screw up your organization. Importing is a much more organized way to manage things. There are a lot of tutorial vid3os on import.

  • Help with a Drag and Drop problem

    I design a simple drag and drop the game, ranking but I had several objects and targets, for example square shaped object cannot go to target square shape, but when I have 2 or more place then the square2, carre3 can not go to square target! I used the code as belo

    var objectoriginalX:Number;
    var objectoriginalY:Number;
    var counter: Number = 0;

    triangle_mc.buttonMode = true;
    triangle_mc.addEventListener (MouseEvent.MOUSE_DOWN, pickupObject);
    triangle_mc.addEventListener (MouseEvent.MOUSE_UP, dropObject);

    circle_mc.buttonMode = true;
    circle_mc.addEventListener (MouseEvent.MOUSE_DOWN, pickupObject);
    circle_mc.addEventListener (MouseEvent.MOUSE_UP, dropObject);

    square_mc.buttonMode = true;
    square_mc.addEventListener (MouseEvent.MOUSE_DOWN, pickupObject);
    square_mc.addEventListener (MouseEvent.MOUSE_UP, dropObject);

    square2_mc.buttonMode = true;
    square2_mc.addEventListener (MouseEvent.MOUSE_DOWN, pickupObject);
    square2_mc.addEventListener (MouseEvent.MOUSE_UP, dropObject);

    square3_mc.buttonMode = true;
    square3_mc.addEventListener (MouseEvent.MOUSE_DOWN, pickupObject);
    square3_mc.addEventListener (MouseEvent.MOUSE_UP, dropObject);

    star_mc.buttonMode = true;
    star_mc.addEventListener (MouseEvent.MOUSE_DOWN, pickupObject);
    star_mc.addEventListener (MouseEvent.MOUSE_UP, dropObject);

    poly_mc.buttonMode = true;
    poly_mc.addEventListener (MouseEvent.MOUSE_DOWN, pickupObject);
    poly_mc.addEventListener (MouseEvent.MOUSE_UP, dropObject);

    function pickupObject(event:MouseEvent):void {}
    event.target.startDrag (true);
    event.target.parent.addChild (event.target);
    objectoriginalX = event.target.x;
    objectoriginalY = event.target.y;
    }
    function dropObject(event:MouseEvent):void {}
    event.target.stopDrag ();
    var matchingTargetName:String = "target" + event.target.name;
    var matchingTarget:DisplayObject = getChildByName (matchingTargetName);
    If (event.target.dropTarget! = null & & event.target.dropTarget.parent == matchingTarget) {}
    reply_txt. Text = "Good Job!"
    event.target.removeEventListener (MouseEvent.MOUSE_DOWN, pickupObject);
    event.target.removeEventListener (MouseEvent.MOUSE_UP, dropObject);
    event.target.buttonMode = false;
    Event.Target.x = matchingTarget.x;
    Event.Target.y = matchingTarget.y;
    counter ++;
    score_txt. Text = String (counter);

    } else {}
    reply_txt. Text = "Try Again!";
    Event.Target.x = objectoriginalX;
    Event.Target.y = objectoriginalY;
    -counter;
    score_txt. Text = String (counter);
    }
    }

    Thank you very much for your help!

    An easy way to handle this is to assign a variable for each target that will tell you whether or not it is still a usable lens... Let's say you name "usable", it starts as a true for each target value.  Once a target is used you change the value of this variable to false.  You use this variable as abother test in your conditional.  Something like...

    If (event.target.dropTarget! = null & event.target.dropTarget.parent == matchingTarget & event.target.dropTarget.useable ) {}

    event.target.dropTarget.useable = false;

  • Help with Drag and Drop text

    I am trying to create a series of text objects that I can drag and drop on the screen. I'm trying to text fields in a movieClip container from the Drag and Drop will not work on text fields. When I do that, Flash still sees the objects as fields of text rather than the video clips, and I get the following error.

    ReferenceError: Error #1069: property not found startDrag on flash.text.TextField and there is no default value.
    at chris_fla::MainTimeline/startDragging()

    I'm a newbie to this. What I am doing wrong? Thank you!

    Russ

    Use currentTarget instead of the target.

  • ALT + tab no longer works with drag-and-drop

    I bought a new computer Samsung with Windows 8, two weeks ago. On my old computer, I could choose a file in a folder, then alt - tab to another folder and then drop the selected file. Now, every time I select a file and use alt - tab, the file automatically becomes deselected.

    This never happened to me in my previous versions of Windows.

    To be clear: my keyboard and touch pad working perfectly fine. It is a problem of Windows when you use drag-and - drop jointly with alt - tab.

    Hello Boston,

    This feature is also available in Windows 8. You must select a copy of the file and click alt + tab and select the folder where the file should be moved or pasted.

    If this does not work on your computer, you can try to follow the link below and create a new user account and see if that helps. To create a user account follow this link:

    Create the user account

    I hope this helps. Otherwise, feel free to write us again and we will be happy to help you.

    Thank you

  • I have problems with gmail with firefox. Refreshing page is slow; Drag and drop files in email sometimes do not work.

    My problem is mainly associated with gmail. When I click on return to the Inbox after reading a mail, it takes a good few seconds while in the past, it was always instant.

    My other problem is drag them / move the files as an attachment in gmail. Sometimes it won't work and I have to use the manual icon attaches trombone. However, if I restart firefox and re - connect to gmail, it will work again.

    I also noticed that when you drag an image in the mail window, it will not become an attachment, but it will appear instead. Is there a way where I can choose to have inserted images as attachments rather than displayed in the mail?

    Thanks for any advice you can give me.

    Hi Guigs2,

    Thanks for your advice. I'm not sure what will happen if I change my profile. I'm afraid I'll be somebody else for those who know me.

    So I decided to try the second option on the plugin check. After I clicked on the link the message says that my version of firefox is not the last. I've updated it and so far I don't have drag and drop the problem but we will give it some time and see. This problem does not occur all the time but it happened a few times, so I guess I should try it for a while.

    Thanks a lot for your advice

  • Drag and Drop with XTable

    Hello

    is there a way to allow drag and drop from the data portal in a ChnComboBox-XTable column? Just like in a normal ChnComboBox.

    Kind regards

    Martin

    I found something

    "do something with the channel dropped"
    Void XTable1_EventDrop (ByRef, lines, columns, DropInformation) ' Erzeugter event handler
    Dim oDropElement

    For each oDropElement in DropInformation.DiademElements
    ' place here some code for table updateing
    Call MsgBox (oDropElement.ChannelGroup.Name & "/" & oDropElement.Name)
    Next
    End Sub

    'enable the fall for a single channel in pass 2 '.
    Void XTable1_EventDropAllowed (ByRef this, lines, columns, DropInformation, ByRef DropEffect) 'Erzeugter event handler.
    Dim oDropElement

    If (Col = 2) AND (DropInformation.DiademElements.Count = 1) then
    For each oDropElement in DropInformation.DiademElements
    If oDropElement.IsKindOf (eDataChannel) then
    DropEffect = 1
    End If
    Next
    End If
    End Sub

  • Drag and drop in flash cc 2015 with createjs

    can we know how to do simple drag and drop in Web flash with createjs?

    this.circle.addEventListener("pressmove", fl_MouseClickHandler_2.bind(this));

    function fl_MouseClickHandler_2()

    {

    // Start your custom code // This example code displays the words "Mouse clicked" in the Output panel.

    evt.target.x = evt.stageX;

    evt.target.y = evt.stageY; }

    Thank you

    use:

    this.circle.addEventListener("pressmove", fl_MouseClickHandler_2.bind(this)); 
     function fl_MouseClickHandler_2(evt) 
    { 
    // Start your custom code // This example code displays the words "Mouse clicked" in the Output panel.
     evt.target.x = evt.stageX; 
     evt.target.y = evt.stageY; }
    

    Thank you

  • Drag and drop support with the VM mountain lion

    Hi all

    I recently got a new macbook pro (with retina display and the 16 GB and of course the SSD - very soft). I created a machine virtual windows 7 for my windows applications and I also wanted a separate VM to develop on with Mountain Lion, so I downloaded the Cougar from the app store and created an image of mountain lion. My only problem is that it doesn't seem to be any support for drag and drop between my host mountain lion and my mountain lion guest VM. If I try to drag and drop with my windows 7 VM, it works well, but not mountain Lion mountain lion.

    Does anyone know if there are a few settings that I can turn it on or if it is supposed to work? Furthermore, I am under Fusion 5.0.3 and am on MacOS 10.8.3 (on my host and the guest operating system).

    Thank you

    -Jeff

    Hi Jeff,

    Yes it is a limitation having Mac OS X as a guest operating system. There are some other limitations as well as

    • SVGA only.  No chart 2D or 3D accelerated.
    • No unit.
    • No fullscreen multimon support.
    • No USB 3.0 support.

    You can make a feature request or via this link: http://www.vmware.com/contact/contactus.html?department=prod_request

    Thank you

Maybe you are looking for

  • Satellite A300 - can I work without shared memory?

    * I want to work with my A300 without shared memory! ** I can or not? ** and Toshiba a Notbook product, it has no shared memory? *

  • Vista crashed after installing MS office 2010 beta version

    Hello I have Windows Vista Home premium on my laptop with MS office 2007. Yesterday, I installed the version of MS office 2010 beta (with option to keep 2007 MS office). Afterwards, my PC crashed and I can't start. Each time, he attempts to perform t

  • Strange grey boxes on file icons

    For some reason, on almost all the files in my directory Program Files (x 86) together, there is a little gray box with a slash reverse through it, on the lower left corner of each icon. Just after that, I discovered, I noticed that most of my progra

  • BlackBerry smartphones please help, IMEI has been blocked

    My sister was on my phone and it managed to lock my IMEI is - anyone know what I can do thank you.

  • Where my photos are saved?

    When I look at my lightroom catalog, I have a ton of photos (photos of 27 k), but I don't know where exactly they are registered.   Many of them aren't in the folders that I see in lightroom.  The only way I can see is by selecting "all photos" at th