A Flash Developer Resource Site

Results 1 to 2 of 2
  1. #1
    Junior Member
    Join Date
    Mar 2013

    drag&drop sound problem

    How can i add a applause sound when all targets are done?

    function dragSetup(clip, targ) {
    clip.onPress = function() {
    clip.onRelease = clip.onReleaseOutside=function () {
    if (eval(this._droptarget) == targ) {
    this.onTarget = true;
    } else {
    this.onTarget = false;
    //the variables below will store the clips starting position
    clip.myHomeX = clip._x;
    clip.myHomeY = clip._y;
    //the variables below will store the clips end position
    clip.myFinalX = targ._x;
    clip.myFinalY = targ._y;
    clip.onEnterFrame = function() {
    //all these actions basically just say "if the mouse is up (in other words - the clip is not being dragged)
    // then move the MC back to its original starting point (with a smooth motion)"
    if (!this.beingDragged && !this.onTarget) {
    this._x -= (this._x-this.myHomeX)/5;
    this._y -= (this._y-this.myHomeY)/5;
    //if the circle is dropped on any part of the target it slides to the center of the target
    } else if (!this.beingDragged && this.onTarget) {
    this._x -= (this._x-this.myFinalX)/5;
    this._y -= (this._y-this.myFinalY)/5;

  2. #2
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    I'm not sure this will work, as I haven't tested it and I don't understad your script well. But it would be something like this:

    if(Target1.onTarget == true && Target2.onTarget == true && Target3.onTarget == true ){
    applause = new Sound();
    The onEnterFrame will keep running until all the onTarget variables become true in all the target movieclips or buttons, then will load and start the applause sound. You need to import the applause sound into the library, export it for actionscript and assign an Identifier name "applause". Hope that helps.
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.