Action Script 3 Drag & Drop

Hello

I've been following a Lynda tutorial to generate a simple drag and drop game in Flash CS5, using ActionScript 3 and met with what I'm sure that someone will be a simple problem to solve. I got to the stadium where I have video clips 10 and 10 on _target areas to drop these clips, they then snap into the right area.

My problem is that I have a meter running in the background that counts the number of correct conversions; what I want is when all 10 points fell in the right zone (_target relative), a line of Action Script will be executed, now for this example, I would like to bring the Alpha of a textfield/clip on 0-1 scene, showing a message of victory.

Here is my code so far, I use external classes for the process of what drag / move.

The grid class:

package
{

import flash.display. *;
import flash.events. *;


Grid/public class extends MovieClip
{
var dragdrops:Array;
var numOfMatches:uint = 0;


public void Grid()
{
the constructor code
dragdrops = [moneya moneyb, moneyc, moneyd, moneye, moneyf, moneyg, moneyh, Anil, moneyj];
var currentObject:DragDrop;
for (var i: uint = 0; i < dragdrops.length; i ++)
{
currentObject = dragdrops [i];
currentObject.target = getChildByName (currentObject.name + "_target");

}
}

public void match (): void

{
numOfMatches ++;
if(numOfMatches == dragdrops.) Length)
{
HERE, it IS WHERE I want TO PUT the ALPHA CODE
}
}

}

}

Class DradDrop:

package
{
import flash.display. *;
import flash.events. *;

SerializableAttribute public class DragDrop extends Sprite
{

var origX:Number;
var origY:Number;
var target: DisplayObject;

public void DragDrop()
{
the constructor code
origX = x;
origY = y;
addEventListener (MouseEvent.MOUSE_DOWN, drag);
buttonMode = true;
}

function drag(evt:MouseEvent):void
{
stage.addEventListener (MouseEvent.MOUSE_UP, drop);
startDrag();
parent.addChild (this);
}

function drop(evt:MouseEvent):void
{
stage.removeEventListener (MouseEvent.MOUSE_UP, drop);

stopDrag();

If (hitTestObject (target))
{
Visible = false;
Target.Alpha = 1;
Object (parent) match ();
}

x = origX;
y = origY;
}

}

}

Any help would be great.

use:

package
{

import flash.display. *;
import flash.events. *;

Grid/public class extends MovieClip
{
var dragdrops:Array;
var numOfMatches:uint = 0;

public void Grid()
{
the constructor code


dragdrops = [moneya, moneyb, moneyc, moneyd, moneye, moneyf, moneyg moneyh, Anil, money j];
var currentObject:DragDrop;
for (var i: uint = 0; i< dragdrops.length;="">
{
currentObject = dragdrops [i];
currentObject.target = getChildByName (currentObject.name + "_target");
   
}
}
 
public void match (): void
 
{
numOfMatches ++;
if(numOfMatches == dragdrops.) Length)
{

Use a dynamic textfield you can assign an instance name (for example, tf) and use:
TF.alpha = 1;
}
}
 
}

}

Class DradDrop:

package
{
import flash.display. *;
import flash.events. *;

SerializableAttribute public class DragDrop extends Sprite
{
 
var origX:Number;
var origY:Number;
var target: DisplayObject;

public void DragDrop()
{
the constructor code
origX = x;
origY = y;
addEventListener (MouseEvent.MOUSE_DOWN, drag);
buttonMode = true;
}
 
function drag(evt:MouseEvent):void
{
stage.addEventListener (MouseEvent.MOUSE_UP, drop);
startDrag();
parent.addChild (this);
}
 
function drop(evt:MouseEvent):void
{
stage.removeEventListener (MouseEvent.MOUSE_UP, drop);
  
stopDrag();
  
If (hitTestObject (target))
{
Visible = false;
Target.Alpha = 1;
Object (parent) match ();
}
  
x = origX;
y = origY;
}

}

}

Tags: Adobe Animate

Similar Questions

  • How to make a reset button and add the action script to reset all my drag drop video clips

    It's HOT need help quickly by the close of business Thursday

    Hello kglad and all, I have a problem with adding a reset button for my drag and drop video clips.

    The problem is, if a student dragging a movie clip to a wrong address on the SWF, I want them to be able to hit a reset button that would lead the SWF even they opened and what would showup a page clear to restart drag them and drop exercise.

    I know how to make a button for this want just the appropriate action script to be able for the user to start over with no symbol of clip from movie on the page.

    Seal55

    You must either code to reset everything or you can reload your current page:

    loadMoveNum(this._url,0);

  • createjs Flash cs6 export do not action script

    Hello

    I had installed cs6 in my laptop (trail version). Basically, I am programmer Action Script 3.0. I'm trying to develop an application and create the js file. I have programming using simple drag and drop functionality. his work in the swf file. Once I publish js his does not work. And I faced questions of the text. You guys can let me know that I was wrong.

    Find attached test files.

    Thank you
    Virginia chatelain

    CreateJS will not translate your actionscript code to javascript.

    Search for tutorials on the subject that will show you how you can replicate the features of AS3 with Javascript

  • Cannot find the combination of rollover image/button/drag / drop

    Hi all

    I use 9 Captivate and work of the interaction that left me speechless. I'm trying to put up with images that will be used for drag-and-drop interaction, and I want the images to have a rollover State to indicate that they are clickable. When you click on it, a display window that provides more information to the user to determine the correct items to drag and drop.

    I tried at first to use a regular image and then add a "Rollover" State, but then I couldn't understand how to assign an action to indicate when this State will come into force. (Is there a way to associate a hotspot of mouse with a picture?) Then I tried to use an image button, which worked very well in the measure where using the rollover State and I used some conditional formatting and the variables for my more info boxes to show when the item has been clicked. However, I didn't until I had finished this part that the buttons can be used as drag objects, OH.

    I thought to use an invisible on an image button so that I could get the most information to display and the image can still be used as a drag-and-drop object, but then brings me back to not knowing how to get the rollover State to work. :/

    Suggestions as to how I can achieve the Trifecta of turning State/button/drag / drop?

    You can not interactive objects as sources of drag or drop targets. Only interactive objects have the integrated rollover state that appears automatically when the cursor is on the object.

    Drag sources and drop targets also have InBuitl States, but turnover is not one of them. Take a look at this article to see all the Inbuilt says in & slipped:

    & Slipped in 2016 with Captivate 9 - Captivate blog

    States customized like the one you created for the object can only be triggered by an event. Rolling a normal object is not an event, which explains why you can not modify a report on working capital. Except, maybe (did not check) using the CpExtra of InfoSemantics widget (only for HTML output), which can be used as EventHandler (another widget to them for the SWF output).

    You can trigger an action when a drag source is dragged to a drop target, using stocks of the object (more: advice & slides - blog of Captivate ) but not before dragging you requested.

    At the moment I don't see a way to do what you ask (and this is the first time I see such a question in this forum). Must be D & D?

  • synchronization of actions scripts

    Hi, I created an action in photoshop on one computer and want to use another--both are on the same account of creative cloud - ideas?

    Save the Action defined for your disk in a folder that you create to save your Photoshop add on.  As \My Photoshop Stuff\Actions\. Highlight all of the Action in the Actions Palette. Use drop-down menu of the Plaette Actions save point Action.  Copy them saved *. ANT file to your other machine and drop it on Photoshop to load this action set in your Photoshop Actions palette.  You must always save what you create. If you do not have to reset your preferences in Photoshop you will lose what you have not saved.

    Package of shares of crafts UPDATE August 10, 2014 added conditional measures Action Palette tips.
    Contains

    Example of
    Download

  • Drag drop files always in temp\VMwareDND which is a symptom of the problem?

    I realized for the first time as the files that are Drag'n dropped from OS X to Windows VM apparently first go to ~ \Appdata\Local\Temp\VMwareDND.

    I noticed this only because:

    I dropped a WORD DOC file on the WINDOWS desktop.  I then opened it in MS WORD.  When I tried to make a BACKUP-from Word, the target folder that appeared in the Save dialogue was... \VMwareDND, no office!

    This DOC file is still in VMwareDND.

    Out of curiosity, I tried to drag / drop files more. These files later are NOT now in VMwareDND. But the first file I have slipped and fallen still exists in VMwareDND.

    Why does the first file in VMwareDND like the rest of the files?

    Was there a problem that the file has been copied from OS X to WINDOWS?

    Should I be worried that maybe the file was not copied correctly? This file was only a 5 page doc, but I am concerned about large binary files.

    Fusion 3.0.0 OS X 10.5.6 Windows Server 2008.

    Hello

    As the files that are drag ' n dropped go via the folder %TEMP% windows is by design.

    It also means that if you try to DND a file that is larger than the space available on the unit that contains only your temporary folder will fail to copy.

    If I remember correctly you can get around this by changing the file folder in your installation of windows to use another drive.

    In regard to the original not getting file not deleted, it is difficult to say. Don't have youby accident registered there in MS Word?

    It could be a bug that animates its not deleted in the temporary folder after copy successful using DND, but it is not a great problem because the temp folder is deleted when you select 'Disk cleanup' in the context menu properties under.

    There are also opportunities under profiles to delete the contents of the temp folder when you restart your guest.

    Hope this helps,

    --
    Wil
    _____________________________________________________
    VI Toolkit & scripts wiki at http://www.vi-toolkit.com

    Writer to the blog www.planetvm.net

    Twitter: @wilva

  • Office file to the browser, drag drop / entry download

    Hello world

    I'm working on a project with drag and drop and im using jqeuryui for this.

    but I want the user to be able to drag a photo to the page and what it apears on the page in the browser (no upload fancy but just customer data)

    and also a button 'Download' but also using data (I won't use of node.js or any database for this project).

    can someone help me with a simple script for that? found a lot of scripts but all the required databases, I just want to keep things simple.

    then just a picture of snow from desktop to the browser and let that attend a div,.

    and an entry button to upload a photo and let that attend a div.

    local all simple.

    I'd like to hear a response.

    -Rob

    I made a model for drag drop download.

    Drag a picture on the box and it will appear in the browser.

    Demo: http://boermancrossmedia.nl/edgedragupload/dragdrop_file_upload.html

    Download a file and model: https://app.box.com/s/sl49v3fs0r0drqm2ix23

    Free to use.

    Maby preran, you can use it for the help page & tutorial?

  • I have version 9.0.1 on 2 pc, both xp sp3. 1 the button "open new tab" is visible, on the other hand, the "Open new tab" button is not yet available in the menu "Customize toolbar" drag / drop. Why?

    I used the same setup file, but on 1 pc, the "Open new tab" button is available in the menu 'Customize toolbar' and can be dragged and drop on the navigation bar. On the other pc, the "Open new tab" button/icon is not yet available for drag / drop. I uninstalled firefox completely, including the settings and preferences, then reinstalled, but that has not fixed the missing button.

    Hello

    Please try to restore the default value in the Customize... window. If it is still not visible, one of the reasons could be that the button is already placed on the toolbar, but can be hidden behind a different icon or toolbar.

    ...............................................................................................................................

    Useful links:

    Everything on tools > Options

    Beyond the tools > Options - about: config

    Subject: config entries

    Information page (Alt + T) tools > Page Info, right-click > view Page information

    Keyboard shortcuts

    View without Plugins

    Files & Firefox profile folder

    Firefox commands

    Basic troubleshooting

    After the upgrade

    Safe mode

    Extensions of the issues

    Troubleshooting Extensions and themes

    Troubleshooting Plugins

    Test Plugins

  • Drag-drop Subvi on selected secondary

    Hi all

    I have an application where the user creates a 'follow-up' layout by dragging the desired data from the tree. In the front panel, I have several sub-panels allowing users to drag & drop data to any as they wish. Attached VI indicates similar stuff.

    However, deleting data, I can't filter what school must be used (in the vi attached, I try to move the data to the two sub-panels but even couldn't handle success that is) should be used to determine what school should show the Subvi (in this case, it is a waveform graph)? Filter mouse events? If I use the mouse enter, I can't use the event filter to drop at the same time.

    How can I feed the data, that are generated inside the second loop, while in these sub - VI that I loaded to the sub-panels? I have to do in case of timeout I suppose, but how can I join the Subvi from there then?

    Ask if you need more questions. Sorry for any possible incomprehensible sentence above

    BR, Palazzo

    Well Yes, there are many different options to pass data to the slot - loaded VI. At some point, you need to store the reference to the loaded VI and use this reference to manipulate the VI. Here's a quick and easy way to make using a local variable of the table:

    It is not very scalable and it certainly has a disadvantage right off the bat. This table will always grow and never get more small, so you'll get overlap VI references. It should still work, but if you kept Drag and drop you would possibly have a memory problem. With a few adjustments, you can solve this problem (specific table indices may be designated for each school, so clear you always the current reference to this specific location of table before loading the secondary).

    FYI, your 1ms waiting is too small. Isn't that nobody have CPU for this.

  • Do drag &amp; drop using Booleans - question!

    Hello to all 2!

    Here's what I'm trying to do:

    I have 2 Boolean commands that has one independent of the other on the front panel.

    I want to be able to change the State of the control 'Slave' drag-and - drop 'Master' on it.

    Example:

    'Master' - WRONG initially.

    'Slave' - initially set to TRUE.

    After drag & drop operation:

    'The master' - always FALSE.

    'Slave' - becomes FALSE.

    Here's a vi in which I tried to address this problem.

    This behavior is possible?

    Thank you!

    Andrew.

    you want to do something similar to this? This isn't a perfect example, but I hope this will help you

  • How to drag - drop in the windows photo gallery?

    All I get ts a red circle with a red line in it.

    Hi GeorgeDuncan,

    Are you aware of any hardware or software changes, prior to the beginning of the question?

    You cannot drag, drop or move the pictures in windows photo gallery, but you can do a right click in the empty space of the image window and use options such as group by, sort by, etc. to organize photos. You can even mark photos for storing photos

    You can also check out the link for more information on tags - below

    http://Windows.Microsoft.com/en-us/Windows-Vista/tips-for-organizing-pictures

    For reference:
  • I try to install an air 320u sierra wireless card and I get an error message "could not access vb run time for custom action script. Cannot install the Manager of mobile broadband services.

    could not access vb run time for custom action script

    I try to install an air 320u sierra wireless card and I get an error message "could not access vb run time for custom action script.  Cannot install the Manager of mobile broadband services.  Any ideas?

    Hello

    I suggest you run the fixit and see if it helps:

    http://support.Microsoft.com/mats/Program_Install_and_Uninstall

    Also check out this link:

    http://answers.Microsoft.com/en-us/Windows/Forum/Windows_7-windows_programs/error-2738-could-not-access-VBScript-run-time-for/1a4499ae-8bc1-4534-9c6f-4d399ac70d9a

    It will be useful.

  • can I drag & drop in records of drive c to d to data disc

    I have a lot of free space on the data drive D. can I go to c and d drives properties and drag & drop of files/folders from one disk to the other?

    Hello

    read this:

    Move your folders and files of the user to a different partition

    http://www.vista4beginners.com/move-user-files-folders-to-another-partition

    ________________________________________________________________

    or save data on D: - remove D: - extend C: into the now unallocated space where D: is

    How to remove and extend a Partition with Vista disk management

    http://www.Vistax64.com/tutorials/95418-disk-management-delete-extend.html

  • using the FC command with the GUI drag & drop

    In Windows 95 and 98, it was possible to make a shortcut to the "CF" MS-DOS command on the desktop, and then compare two files by drag & dropping them on the shortcut.

    However, starting from Windows XP, while this still TECHNICALLY works, the MS-DOS window (I do not remember what to call other than "command prompt window", so bear with me) will close immediately upon expiration of the program, making it impossible to read the results, especially if it is "no differences encountered".

    I remember that there was no decent way to solve this problem in XP, but is there a solution to Vista or 7? Typing long file names can be heavy, and even by using copy and paste is tedious compared to the ease, I remember not on Windows 9 X.

    Oh, I just had a thought when you think of batch files. I tried to add a pause at the end command. That seemed to work. It has been long since I made a batch file that needed the pause command. I don't know why I thought using a batch file with a command to break a decade ago.

    Oh and thanks for the link explaining the differences in the manufacture of the batch files. I learned how to 3.30 in 1990 for MS-DOS batch files and never really learned anything new other than the fact that I could use drag-n - drop in Windows 95.

    Is there something else that I could learn a few new tricks that have been introduced since MS-DOS 3.30? I _might_ have read books for MS-DOS 4 or 5 at the time, because there weren't really that many differences. The only different things I knew were the dosshell in MS-DOS 4, Edit & QBASIC in MS-DOS 5 and extended external help of 6.2.2 MS-DOS command which was similar (although I didn't know it until the end of the 1990s) for Unix man pages. Oh, and in one of these versions, they also did better? parameter help messages.

  • Drag & drop doesn't work only in Internet Explorer

    I am no longer able to drag & drop something in Internet Explorer.  I often drag text to a search box or a box on a form.  This feature has stopped working.  As soon as I try to drag text highlighted my cursor becomes a circle with a line through it.
    Thank you.
    DC

    Hello

    What antivirus/antispyware/security products do you have on the machine? Be one you ALREADY had on this
    machine, including those you have uninstalled (they leave leftovers behind which can cause strange problems).

    If no joy there's something blocking perhaps.

    Start - All Programs - Accessories - System Tools - IE with no Addons - what works best?

    IE - Tools - Internet Options - Advanced - tab click on restore, and then click Reset - apply / OK

    IE - Tools - Internet Options - Security tab - click on reset all default areas - apply / OK

    Close and restart IE or IE with no addons

    not better?

    IE - tools - manage Addons (for sure disable SSV2 if it is there, it is no longer necessary but Java always install
    "(and it causes problems - you never update Java to go back in and turn it off again)." Search for other possible problems.

    Windows Defender - tools - software explore - look for problems with programs that do not look right. Permit
    are usually OK and "unauthorized" are not always bad. If in doubt about a program to ask about it here.

    Could be that a BHO - BHOremover - free - standalone program, needs no installation, download and run - not all
    are bad, but some can cause your question (toolbars are BHO).
    http://securityxploded.com/bhoremover.php

    Startup programs
    http://www.Vistax64.com/tutorials/79612-startup-programs-enable-disable.html

    Also get Malwarebytes - free - use as scanner only.

    http://www.Malwarebytes.org/

    --------------------------------

    Try these to erase corruption and missing/damaged file system repair or replacement.

    Run DiskCleanup - start - all programs - Accessories - System Tools - Disk Cleanup

    Start - type in the search box - find command top - RIGHT CLICK – RUN AS ADMIN

    sfc/scannow

    How to analyze the log file entries that the Microsoft Windows Resource Checker (SFC.exe) program
    generates in Windows Vista cbs.log
    http://support.Microsoft.com/kb/928228

    Then, run checkdisk - schedule it to run at next boot, then apply OK your way out, then restart.

    How to run the check disk at startup in Vista
    http://www.Vistax64.com/tutorials/67612-check-disk-Chkdsk.html

    I hope this helps.

    Rob - bicycle - Mark Twain said it is good.

Maybe you are looking for