A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: drag&drop sound problem

Hybrid View

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    1

    drag&drop sound problem

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


    function dragSetup(clip, targ) {
    clip.onPress = function() {
    startDrag(this);
    this.beingDragged=true;
    };
    clip.onRelease = clip.onReleaseOutside=function () {
    stopDrag();
    this.beingDragged=false;
    if (eval(this._droptarget) == targ) {
    this.onTarget = true;
    _root.targ.gotoAndStop(2);
    } else {
    this.onTarget = false;
    _root.targ.gotoAndStop(1);
    }
    };
    //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
    Posts
    971
    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:

    Code:
    onEnterFrame=function(){
    if(Target1.onTarget == true && Target2.onTarget == true && Target3.onTarget == true ){
    applause = new Sound();
    applause.attachSound("applause");
    applause.start(0,1);
    }
    }
    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