ActionScript 2.0 :: MovieClip (Box) To Follow Mouse Click On Screen

Feb 15, 2010

Imagine we have a MovieClip called "box". When I click somewhere on the screen, I want the box MC to move to that position. So I wrote something like this (just for horizontal movement):

PHP Code:
onMouseDown=function(){moveTo(_xmouse);};
function moveTo(newx){box.onEnterFrame=function(){if(box._x<newx){box._x+=5;
}else if(box._x>newx){box._x-=5;}else{delete box.onEnterFrame;}};}

Now this works to a degree, except that when the box MC moves to the right position, it then proceeds to vibrate on the spot. I thought it was probably because it can never move to the exact position of _xmouse because I'm adding 10 to the x property which is why the condition is never met. However even if I just add 1 instead of 10, I still have the same problem..

View 3 Replies


Similar Posts:


ActionScript 3.0 :: Make The Mouse Click Event Recognize When Click Anywhere On The Screen?

Jan 26, 2012

I just started playing around with as3 and I have a function for mouse clicks that draws a shape on each click. However the mouse click event does not appear to work unless I click a movieClip object I placed in the middle of the screen. Is there a way to make the mouse click event recognize when I click anywhere on the screen?

[Code]...

View 2 Replies

ActionScript 3.0 :: Make A Movieclip Follow The Mouse?

Jun 4, 2010

Is there anyway to make a movieclip follow the mouse. I have a menu, as a movieclip and when i roll over the menu i want something to pop up where the mouse is that says 'click & drag to scroll' my main menu is called: container_mc the movieclip i want to appear i have exported it for actionscript and is called mouseovermenu.This is the AS3 i have so far:

Code:

container_mc.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandler);
container_mc.buttonMode = true;
container_mc.useHandCursor = true;

[code]....

At the moment the pop up appears when i roll over but it dosnt follow the mouse. Also, i am getting more than one instance of the rollover movieclip appearing.

View 2 Replies

ActionScript 3.0 :: Make A Movieclip Follow Mouse In Rotation?

Apr 29, 2010

I have this code is AS3

Code:
var xMouse = mouseX;
var yMouse = mouseY;

[Code]...

But unfortunately, the ship does not follow mouse rotation. The ship only rotates with respect to the mouse when you move the ship, not when you move the mouse.

View 1 Replies

Actionscript 2.0 :: Using A MC As A Cursor - Tell MovieClip To Follow The User's Mouse?

Mar 12, 2009

I'm fairly new to using ActionScript to move MovieClips around. I'd like to have a movieclip follow my mouse around the screen (like a mouse cursor). I put one instance of the MC on my stage, with an instance name of 'a', without quotes. (identifier is 'box', class is 'boxClass', without quotes.)

[Code]...

This doesn't work, which should be apparent since I'm posting this. (lol) How can I tell my movieClip to follow the user's mouse?

View 2 Replies

ActionScript 2.0 :: MovieClip To Follow User Mouse Based On X Value

Jul 30, 2007

I'm using the following code to have an MC follow the users mouse based on it's x value. But I'd like to have this inverted...so that if the users mouse goes right, the MC goes left....instead of going right along with the mouse.

Code:
import mx.utils.Delegate;
class Mover {
private var target:MovieClip;
private var limits:MovieClip;
private var ease:Number;
[Code] ......

View 3 Replies

ActionScript 2.0 :: Make Movieclip Follow Mouse Tween Movement?

Jun 13, 2011

I'm not sure what to call this particular way of making the movieclip follow the mouse.When the mouse moves up, the movieclip plays through the frame. If the mouse moves down, the movieclip plays in reverse? I think that's how it works.

View 2 Replies

IDE :: Follow Mouse - Limit The Area Where The Clip Can Follow?

Oct 26, 2009

I found this tutorial [URL] and is wondering if I could limit the area where the clip can follow? I'm planning to have my cartoon's EYEBALLS follow the mouse move.

View 1 Replies

ActionScript 2.0 :: Force A Mouse Follow Movieclip To Snap To A X Y Position If It Reaches X Y Boundaries?

Mar 30, 2009

How would you force a mouse follow movieclip to snap to a x y position if it reaches x y boundaries or perhaps if a button is released the movie clip snaps to a x y position? Of course if the mouse returns to x y boundaries I'd like for the movie clip to follow again.

Right now this is the code I'm using to make the movieclip follow the mouse within x y boundaries:

Code:
onClipEvent (load) {
_x = 0;
_y = 0;

[code]....

View 4 Replies

ActionScript 2.0 :: Skip Intro With Mouse Click On Screen

Jan 19, 2009

I have an issue with an intro I'm doing. I have made animation which is around 200 frames and in the main timeline, so that it starts when you load the page. I want the user to be able to click anywhere on the screen to skip this intro as it takes a while to load on slow connections. At the moment I have made a large button on a layer under the animation which only works as a button when you have loaded the page into the cache and not the first time you load it.

View 6 Replies

ActionScript 2.0 :: Straight Line Will Follow Their Mouse Until They Click Again And This Releases The Straight Line?

Jan 30, 2009

I've managed to follow some drawing tutorias which work fine (mouse down draws a line everywhere you move mouse like MS paint).I would like to adapt this now if I can so that when a user clicks down, a straight line will follow their mouse until they click again and this releases the straight line. This should leave one line on the screen, then they are free to move their mouse and repeat the action again.

View 6 Replies

ActionScript 3.0 :: Follow Mouse With Easing, Until Mouse Is Reached

Jun 23, 2010

I am looking for a quick and simple way of having a movieclip follow the mouse with easing, until it reaches the mouse, at which point I want it to stop. It needs to ease out, so the standard cursorMC.x = mouseX will not do (also because it doesn't update the position of the mouse.

View 1 Replies

ActionScript 3.0 :: Unloads External Swf Inside Movieclip / When Click A Button On Main Screen

Jul 22, 2011

i found a script that unloads my external swf inside a movieclip when i click a button on my main screen. this script causes the external flash inside my moviclip to close and unload when i click the close button, which is what i want!. the only pain in the butt is it preloads the external flash when you go the flash site and i dont want that. i only want the script to close the external swf. if anyone is curious book.swf is the swf in the movieclip i am trying to close.[code]

View 1 Replies

Dd Eventlisenter For Mouse Click To A Movieclip?

Oct 7, 2009

from various books, I know that to add eventlisenter for mouse click to a movieclip:
 
movieClipName.addEventListener (MouseEvent.CLICK, clickFunction);
 
then I define the function
 
function clickFunction(event:MouseEvent)
{ bla bla bla }

My questions are (as silly as they might sound!),

a) why do we need a parameter (i.e. event:MouseEvent) for clickFunction??

b) since we have a parameter for clickFunction, when we feed this function into addEventListener, why didn't we write  movieClipName.addEventListener (MouseEvent.CLICK, clickFunction() );

View 3 Replies

ActionScript 2.0 :: How To Get MovieClip To Move On Mouse Click

Apr 20, 2004

How do I get a movieclip to move to the mouse when it is clicked and released and have it rotate in the direction that it moves?

View 5 Replies

ActionScript 3.0 :: Zoom A Movieclip On A Click Mouse Place?

Aug 2, 2009

I wish make a zoom with tweenlite library on a movieclip.But I wish zoom on a focus where the user click.The user step are like this:step1: the user go on a place over the picturesstep2: clickstep3: zoom to the click placeHow I can do it in AS 3.0?

View 1 Replies

ActionScript 3.0 :: Retrieving A MovieClip's Name From A Mouse Click Into A Function?

May 20, 2009

I'm not proud of my subject line, but it was the best I could do.I'm using this while loop to activate the function buttonpressed from one of five buttons named thumb0, thumb1, etc.:i = -1; while (i++ < 4){this["thumb"+(i)].addEventListener(MouseEvent.MOUSE_UP,buttonpresse d);}I want the main timeline to jump to the labeled frame corresponding with the targeted button's numberfunction buttonpressed(evt:MouseEvent):void{MovieClip(root) .gotoAndStop("clip"+[i]);}

View 2 Replies

ActionScript 3.0 :: Mouse Click Event On Invisible Part Of MovieClip?

Feb 20, 2009

I have a MovieClip of an bicycle, and I've attached and event listener for mouse clicks on that movieclip. The mouse clicks events are raised when I click on the bike, but I really want to be able to click somewhere in the entire region of the movieclip's rect (to make it easier for the audience this is for to be able to click).

View 1 Replies

ActionScript 3.0 :: Square MovieClip - Tracking Coordination Of Mouse Click

Oct 20, 2010

I have a square movieclip named squarepad. What I want is when I click on it to do [some stuff] according to where the square is clicked. It should be something like this:
if ([mouseclickedx] > 1) and ([mmouseclickedx] < 10) then
[do this]
end if

View 1 Replies

ActionScript 2.0 :: MovieClip - Control Resize With Mouse Or Single Click / Drag

Jan 20, 2010

I'm pretty new to Flash and seem to be struggling with variable scope, events and where to put code within movieclips/main area etc. What I'm trying to do is produce a Flash movie that will allow the user to click on a tool from a selection, i.e. a circle, then click on another part of the screen to place the centre of the circle, with a second click to set the radius of the circle (an alternative would be a single click and drag to place the circle and drag it out to the desired radius.) Once the mouse if clicked a 2nd time, or the drag operation is completed, the circle will stay at the selected radius.

The code I'm using so far to test out the idea is below:
_root.onEnterFrame=function(){
_root["item1"].onMouseMove=function(){
d = Math.sqrt(Math.abs(_xmouse-this._x)*Math.abs(_xmouse-this._x)+Math.abs(_ymouse-this._y)*Math.abs(_ymouse-this._y));
if(d<370){
this._width = d*2;
this._height = d*2;
}else{
this._width = 87;
this._height = 87;
}}}

This uses a simple circle movieclip, and the above code is placed in Frame 1 of the background as opposed to the movieclip itself. It resizes the circle movieclip ok, but I want to be able to control the resize with the mouse or with a single click/drag.

View 10 Replies

ActionScript 3.0 :: Switch A Boolean Variable To True After A Mouse Click On A Movieclip?

Sep 2, 2011

I am trying to switch a boolean variable to true after a mouse click on a movieclip.

I want an animation to continue after the user has clicked both btn1 and btn2.

After researching this topic it appears that changing a variable inside a function will only effect code within that function and not the code outside of it - therefore my main Btn1Var and Btn2Var do not update to flase.

ActionScript Code:
stop()
var btn1Var:Boolean = false;
var btn2Var:Boolean = false;

[Code].....

Is there an easy way to change the original variable for each button to true after being clicked?

View 5 Replies

IDE :: Attach Movieclip To Datagrid Cell (and Detect Mouse Click On CellRenderer)?

Aug 28, 2008

Not to certain how many people may need this script, but lo and behold I had need of it for my project. So, here's my script on how to add a movie clip to a Datagrid Cell via CellRenderer1) Create an Actionscript file (*.as) and call it IconCellRenderer2) Put the following code inside that file:

Code:
package
{

[code].......

View 4 Replies

ActionScript 3.0 :: Make The Screen To Follow The Character When Falling?

Sep 26, 2011

im making a platformer with this code...

import flash.events.*;
import flash.utils.*;
import flash.display.MovieClip;
import flash.ui.Multitouch;

[Code]....
 
And i want to make the screen to follow the character when falling.. for the side horozontally i made the Boundries go the opposite way and keep the character in the center but how can i do that with falling and jumping up off screen?

View 3 Replies

ActionScript 3.0 :: Rectangle Follow Curssor Splash Screen?

Dec 14, 2011

how i can make script like this:splash screen in fullwindow rectangle follow cursor to choose language

View 0 Replies

Eyes Follow Mouse Cursor - Increase "mouse Sensitive" Area?

Aug 27, 2009

I have created a small flash movie where the eyes of the character follow the cursor. Its based on this one here Only problem is, it only works while the mouse is actually over the movie. Is there any way to increase the sensitive area to the whole screen without increasing the actual size of the movie?

View 1 Replies

ActionScript 3.0 :: Create A Single Movieclip That Responds To The Same Input (mouse Click) In Two Different Ways?

Apr 4, 2010

i'd like to create a single movieclip that responds to the same input (mouse click) in two different ways: if playhead is on frame labeled "one" go to frame labeled "two", otherwise if playhead is on frame labeled "two" go to frame labeled "one". i've tried if/else and switch statements with no success - what's a good approach to doing this?

View 1 Replies

ActionScript 3.0 :: Scrub That Manipulates A MovieClip, But Tracks A Change In Mouse Position From Click To Release?

Oct 25, 2010

The other is a scrub that manipulates a MovieClip, but tracks a change in mouse position from click to release, instead of tracking the changes in position of a slider playhead. But here is the download for that one:(sorry not a link due to not having over 50 posts yet, you will need to copy and paste)I have found plenty of AS1+2 ways of doing this idea, yet just haven't found any solid AS3 versions.I am currently in a class to learn Actionscript and have tried to figure out this problem yet I am just not yet to that level.

View 0 Replies

Get An Object To Follow The Mouse?

Dec 26, 2009

I am using CS3 and trying to get an object to follow the mouse and having a hard time finding a tutorial on this, because all of the ones i have found want me to add the actionscript to the MC, and my version of flash won't let me do that. Flash expects me to attach it to the frame and so the code doesn't work.

View 11 Replies

IDE :: Get An Object To Follow The Mouse?

Feb 24, 2010

...without using the startDrag method. I know I can use code like this inside of a mouse event listener/function:

Code:
objectMC.x=mouseX;
objectMC.y=mouseY;

This code makes the object move with the mouse, but only if I move the mouse very slowly. When I move the mouse quickly, the mouse leaves the area of the object and thus the MOUSE_OVER listener stops listening, causing the object to stop.

View 1 Replies

IDE :: Mc Follow Mouse With Boundaries?

Jun 1, 2010

I can't find any info on this so I guess I'll just ask. I'm trying to make moveclips that will follow the mouse pointer on MOUSE_OVER but only up to a certain distance then tween back to its original coordinates (preferably with a bounce or elastic ease).I tried startDrag(); on mouse over and that works quit cool but the problem is stopping the drag...

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved