ActionScript 3.0 :: Follow Cursor And Change Direction?
Mar 30, 2010How could I get an object to follow the cursor and rotate to change direction as the cursor changes direction?
View 5 RepliesHow could I get an object to follow the cursor and rotate to change direction as the cursor changes direction?
View 5 Replieswhat i want to happen is have images in a movie clip scroll up and down but i don't want to have to move the mouse to the top of the page to see the top image
here is my code so far
frame 1:
if (_root._ymouse > _root.circle._y) {
_root.circle._y = (_root.circle._y + 10);
} else {
[Code].....
what i want to happen is have images in a movie clip scroll up and down but i don't want to have to move the mouse to the top of the page to see the top image here is my code so far
[CODE]...
I have some info boxes that show up upon MOUSE_OVER of an MC. I set their position to mouseX and mouseY once I want them to appear. The problem is that when I mouse over something near the edge of my stage, the info box appears beyond the stage's bounds. Is there a way I can contrain the infobox X,Y so that it does not go off the state?
Right now, this is how I define the X,Y of the text box (pretty simple).
trlinfotxt.x = mouseX;trlinfotxt.y = mouseY;
I'm trying to make a movie clip follow my mouse. I have that working. But I want to designate a specific area where this the following of the cursor happens. Outside of this area the house would be visible and functional normally. startDrag("myMovieclip", true);
Mouse.hide();
I have a ball with the name of mc which can be moved using the keyboard .. when you press the left mouse button shoots the ball, this ball and the other flies in the face where the cursor was in the shot .. but if you move the cursor to another location and shoot a second time then the second ball is also flying in the direction of the cursor and the first ball change direction toward a second shot ..
ActionScript Code:
import flash.display.MovieClip;
import flash.display.DisplayObject;
import flash.events.MouseEvent;
import flash.ui.Keyboard;
var dist:Number = 0;
[Code] .....
How to make that first ball did not change its direction and continued to fly in the direction of the shot?
I am trying to get an object to follow the mouse cursor only when the cursor is within a certain range of the object.
I would also like the object to stop when the cursor is directly over it, so that it becomes a selectable button.
Lastly, I would like to apply this to many objects, that don't overlap, but rather, "bounce off" of one another. An example of this is at
[URL]
The code I have so far is:
ball_mc.onEnterFrame = function() {
var xMouse = _root._xmouse;
var yMouse = _root._ymouse;
[Code]....
"ball_mc" of course, is the instance name of the object that I have created.
So far I have this code for an object to follow the cursor on stage and change direction. Is it possible for the amount of objects to increase over time to follow the cursor?
stage.addEventListener (Event.ENTER_FRAME, onFrame);
function onFrame (evt:Event):void {
/*code here*/
myObj.rotation = Math.atan2 (myObj.y - mouseY, myObj.x - mouseX) * (180 / Math.PI) + 180;
[code]...
In my file, I've replaced the cursor with a custom cursor of a pencil.It roams around the screen and on mouse over, triggers various actions. While it moves, I'd really like it to draw, so the user has more of an active role in the narrative. Is there a way to do this?
View 9 RepliesI want to make a mc stick to a cursor from the start and then drop the mc.So far I know how to make a mc follow the cursor and drag and drop a mc.I need an AS3 code for "dropping" a mc at a position (cursor must transform into regular arrow again)The position the cursor needs to snap to is another mc - it should be the nearest, so the distance needs to be measured. So the position is not a grid, but the mc's is can be dropped onto are always on the same positions.
View 0 RepliesI know how to make something follow the cursor (e.g. a ball that moves where your cursor does). However, I'm having a lot of trouble figuring out how to do what I need to for an animation, namely make eyes follow a cursor.Here's the situation: I need to make a graphic (the eye in the middle of the eyeball) follow the cursor (i.e. look up, look left, look in any number of diagonal directions) depending on where the user moves the cursor. But the eyes, obviously, need to stay put in one static spot and move in a very limited region (the entire white part of the eye, but not beyond it).
Furthermore, the eyes start out staring at the user. How do I additionally make them dart to the edges where they'll be looking around once the cursor is moved?
so i have a project where i will be making a website. I will be using flash to make it interactive and visually appealing. I found a website with a really cool entrance page,please view it he mouse moves, the background looks like its moving.
View 3 RepliesI'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?
I have a menu for a website in flash where, an mc moves up and down and shoots...so that when the projectile MC hits a button, it clicks it.
1.) How do I make it so that the MC follows the mouse (like a custom cursor)..but is restricted to only going vertically
2.) how would you make it so that the mc can shoot anywhere....but when the fired MC hits a button, it acts as if it was clicked? My AS knowledge...is..very basic...so if you have any free time could you explain the codes?...so that I can learn from this...rather then just stealing your codes... but..if you want to just let me copy and paste...thats cool too
In as3, how do you change the cursor to the systems default busy/wait cursor (e.g. the spinning wheel on a mac)?
View 2 Replieshow to change the cursor when move over a chart in flex i have tried useHandCursor="true" but it's not working in charts.....and it should show values also....
View 2 Repliesis there AS code that changes the cursor to an alternate cursor? i'm thinking like director, where the alt cursors are built-in--i would do a mouse.hide and then have a MC follow the cursor around, but this always seems choppy/slow to me-
View 1 Repliestrying to make a movie clip follow a custom drawn vertical line, the movie clip follows the cursor but only the y axis
I have added an example of what i mean and the file i need it to happen to
ps the vertical line needs to be hidden.
I want to use and old AS1/AS2 script to AS3. It makes the eyes follow cursor effect, but with the particularity that is not based on a round eye that rotates, but in a pupil MovieClip that actually follows the cursor, but is constrained to the shape of another MovieClip.
View 0 Repliesi want to make one circle follow the mouse cursor, inside another circle. Similar to an eye looking at the cursor. Ive attached an example.
View 4 RepliesWith mx:Box I can set the direction to be either "horizontal" or "vertical". I'd like to reverse the order of the components in the box though. For example:
Before:
|button1| |button2| |button3|
After:
|button3| |button2| |button1|
I've created a custom component that lives in a mx:Box and would like to do this in as simplest a way as possible.
I create a TLFTextField object at design time and need to change its direction at runtime, how this could be possible? the following code did not work and simply ignored: var myText:TLFTextField = MyText;myText.textFlow.direction = "rtl";
View 12 RepliesI want to change the dropdown driection of the calender of datefield.since my width of the application is small.and also i want to reduce the size of the datefield's calender control.
View 1 RepliesIs it possible to conditionally change the direction of a for loop in ActionScript?
Example:
for(if(condition){var x = 0; x<number; x++}else{var x=number; x>0; x--}){
//do something
}
how I change the direction of a movie clip. And how to make it change in the same it's moving.
I have random movement code on the clip, I just want it to rotate, in the direction it goes.
function moveStuff(){
if(Key.isDown(Key.DOWN)){
this._y += 5;
}
if(Key.isDown(Key.UP)){
[code]...
thats my basic Arrow key functions to move a movie clip lp_mc is my character in the left position so when left key is pressed it moves forwards but when right is presssed it moves backwards... i have a movieclip called rp_mc which is the same thing but facing the other way when right is pressed how do i swap the lp_mc for rp_mc so it changes direction?
i'm trying to animate a movie clip by subtracting from its y value and then when it reaches a negative value change direction and animate by adding to its y value until it's back to 0 and loop back and forth. what i have isn't working.
Code:
function Bodyloop(e:Event):void{
var direction:Boolean;
if(body.y > 0){
[Code].....
when it reaches -500 is jumps back and forth.
Code:
animator = createEmptyMovieClip('animator',1);
bg_1 = animator.attachMovie('bg_mc','bg_1',1);
bg_2 = animator.attachMovie('bg_mc','bg_2',2);
[Code]....
how to get it to go from left to right, rather than right to left as it does now. Been messing with it for a while and have no idea what to do.
what i have is a circle image (for this purpose lets say it looks like a clock). For example: when you click 3 o'clock, the whole clock needs to rotate around with the 3 o'clock btn at the 6 o'clock position (with the pivot point in the centre). each of the 'time' positions (2 o'clock, 3 o'clock, 4 o'clock ...etc) needs to be a button and thus be able to rotate around to the 6 o'clock position.This would seem simple enough by just using a.rotate value or using tween movieclips...however the tricky part is:the actionscript needs to determine which way the clock turns (anti/clockwise), dependant on where the clicked time-btn's position is. it needs to be some sort of if statement that says:if (3'oclock-btn) is positioned between 0 degrees (being original 12'oclock position) and 180 degrees (original 6 o'clock position), then rotate clockwise to the 6 o'clock position. If the (3o'clock btn) is positioned between 180degrees and 259 degrees (12 o'clock position), rotate anti-clockwise to the 6'oclock position.
View 5 RepliesI'm building a simple 360 degree image rotation effect using single frames and forward and back buttons. I'm new to AS3 and have managed to create functioning buttons... (so my code may be a bit odd!)But now I also want to advance frames by clicking and dragging on the image itself (or on an invisible button sat on top of the image).Although there are some threads here which have asked the same thing, I don't understand how they were answered. My code is below, and the file I am practising with is on:URL...At the moment if you click on the image area it will advance but as there is no code detecting mouse direction, it just goes forward. Can anyone help me understand how to implement a simple direction detection and then use this to decided whether to advance or go backwards.[code]
View 16 Replies