A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Mouse position plays movieclip frame

  1. #1
    Senior Member
    Join Date
    Oct 2007
    Posts
    120

    Mouse position plays movieclip frame

    Does anyone know the actionscript to play a movie clip's frame when the mouse is in a certain position on the stage? Basically, play frame 2 of this movie clip when the mouse goes to the far right side of the stage, otherwise play frame 1. Can't seem to get the script right...any ideas?

  2. #2
    Senior Member Ex-Ess's Avatar
    Join Date
    Nov 2002
    Location
    York (England)
    Posts
    588
    Code:
    this.createEmptyMovieClip("mouseCheck",100);
    this.mouseCheck.onEnterFrame = function(){
    	//this bit sets up your frame boundaries [startPointFromLeft,endPoint,FrameToGoTo (can be a number or frame name)]
    	frames = [[183,366,"one"],[0,182,"two"],[367,550,"three"]];
    	
    	//gets the x position of the mouse
    	xPos = _root._xmouse;
    	
    	//loops round the array of boundaries to see where the mouse is and goes to correct frame
    	for(i=0;i<frames.length;i++){
    		if(xPos >= frames[i][0] && xPos <= frames[i][1]){
    			_root.gotoAndPlay(frames[i][2]);
    		}
    	}
    }

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