A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: Code translation please

Hybrid View

  1. #1
    Patron Saint of Beatings WilloughbyJackson's Avatar
    Join Date
    Nov 2000
    Location
    Ro-cha-cha-cha, New York
    Posts
    1,988
    Well, this is basically a drag and drop routine if you need to check something while dragging.

    To break it down:
    code:

    on(press){
    startDrag(this);
    //This creates a function watch for onMouseMove events. That means whenever the
    //mouse is moved, whatever is inside of this function will occur.
    this.onMouseMove = function(){
    //For now, it is your hittest, however, you add as much code as you like in this statement.
    if(_root.pin.hitTest(_root.balloon)){

    _root.balloon.balloon2.gotoAndPlay("popped");

    }

    }

    }



    on(release){

    stopDrag();
    //Setting this.onMouseMove to undefined is erasing whatever checks were set up in
    //onPress statement.

    this.onMouseMove = undefined

    }




    I've used something like this for mouse based games before.

  2. #2
    Senior Member
    Join Date
    May 2006
    Posts
    119
    Ok, I think I understand that now. But I have one more question. Now I am trying to make a pin pop many balloons. my popped balloons have an animation for when they are popped. I found with this script I could pop a balloon, but if i kept moving the mouse, it would restart the animation. I corrected that by adding a

    delete this.onMouseMove;

    it worked for one MC.
    now I have 4 balloons, when I pooped one, it would delete the onMouseMove so I could not pop any more.
    I figured I would add the this.onMouseMove = function(); to the top of each if statement to see if it would work. now it will only pop the last balloon in my if statement.
    I'm out of ideas......
    here is what I have. (probably no very good)

    Code:
    on(press){
    	Mouse.hide();
    	startDrag(this, true);
    this.onMouseMove = function(){
    	if(_root.pin.hitTest(_root.r_balloon)){
    		_root.r_balloon.gotoAndPlay("popped");
    		delete this.onMouseMove
    	}
    	}
    	this.onMouseMove = function(){
    	if(_root.pin.hitTest(_root.b_balloon)){
    		_root.b_balloon.gotoAndPlay("popped");
    		_root.b_balloon._visible = false;
    		delete this.onMouseMove
    	}
    	}
    	this.onMouseMove = function(){
    	if(_root.pin.hitTest(_root.g_balloon)){
    		_root.g_balloon.gotoAndPlay("popped");
    		delete this.onMouseMove
    	}
    	}
    	this.onMouseMove = function(){
    	if(_root.pin.hitTest(_root.p_balloon)){
    		_root.p_balloon.gotoAndPlay("popped");
    		delete this.onMouseMove
    		}
                }
    }
    on(release){
    	stopDrag();
    this.onMouseMove = undefined
    	}

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