ActionScript 3.0 :: Point Cannon Barrel Towards Mouse?

Feb 20, 2012

EDIT: Rotation issue is solved with this:
ActionScript Code:
Math.atan2(ydif, xdif)/(Math.PI/180)-90;

I made a cannon consisting of 3 movie clips: The barrel, base and projectile. I want the barrel to point toward the mouse and the projectile to follow the barrel on the "inside" (behind the movie clip). Also i don't want the barrel to instantly go to different angels, a smooth animation that make the barrel feel like it has some weight would be nice.

Here is an image of the project: [URL]..

View 2 Replies


Similar Posts:


ActionScript 2.0 :: Smake The Barrel Of Gun Follow Mouse

Mar 16, 2005

I havent used flash in years and I wanted to make a game. Ive made a few before but i didnt ever finish them and now i dont have them anymore.I wanna make this game where you are this man that can move around. (i can remember how to do that) and you shoot these huge exploding cats.

-How do i make the person shoot when you press the spacebar?
-How do i make the barrel of the gun follow the mouse and the bullets shoot that way?

View 10 Replies

ActionScript 2.0 :: Drawing Api - The Curve Point Be The Same Point As The Mouse?

Nov 3, 2003

From the Robert Penner code given in this tutorial: [URL] i was wondering why controlx and controly has to be so complicated. I've tried changing it to just _root._xmouse but it messes up. I don't get this, shouldn't the curve point be the same point as the mouse?

View 13 Replies

ActionScript 3.0 :: Making A Cannon Fire?

May 8, 2011

Me and my friend are making a sidescrolling shooter to learn ActionScript 3. But we can't make our cannon shoot the cannonball. Here is the cannon.as


ActionScript Code:
package com.edwardothesheep
{
 import flash.display.*;[code]....

And this is the error it gives:

TypeError:::Stage@1fc34b51 to flash.display.MovieClip.
at com.edwardothesheep::cannon/shoot()[C:UsersIanDownloadscannontestcannontestcome dwardothesheepcannon.as:33]

View 1 Replies

ActionScript 3.0 :: Double Barrel Rotating Turret?

Aug 20, 2009

i am trying to make a "double-barrel" firing cannon in AS3..below is a crappy drawing of what im trying to acheive...im having trouble making the two bullets come out where they should (1 on the left barrel, 1 on the right barrel). prior to this, i already successfully created a standard "one-barrel" turret that rotates depending on the mouse location and fires 1 bullet per shot.. what i'm trying to do now is (like i said above) to create a double-barrel turret that would fire 2 bullets per shot (1 on the gun1 and 1 on gun2)..below is the code i used for the single-barrel turret: on the timeline:

ActionScript Code:
stage.addEventListener(Event.ENTER_FRAME, followMouse);
stage.addEventListener(KeyboardEvent.KEY_DOWN, fireBullet);
var radians:Number;

[code]....

View 0 Replies

ActionScript 2.0 :: Parabol - Firing Shell / Cannon On Certain Angle

Oct 26, 2004

How would you script a parabol? i want to be able to "fire" a shell/cannon on a certain angle and have it do a parabol/curve in the air and land/hit.

View 3 Replies

ActionScript 3.0 :: Arrow Point To The Mouse?

Apr 6, 2009

This is a fairly simple problem, yet I can't make it work. I have an arrow-shaped mc, and I want it to rotate, constantly, so it points at the mouse.

this is what i do every frame:vectorArrow.rotation = Math2.radsToDegs(Math.atan(-(root.mouseY - y)/ (root.mouseX - x) ) );

what happens is that it rotates strangely. It doesnt rotate fully, let alone point to the mouse. I've also tried someone elses code:

[Code]...

View 2 Replies

Follow Mouse From A Pivot Point?

Jun 8, 2009

I am trying to have a flashlight follow the mouse from it's pivot point. Rotating from its registration point, 180 degree rotation. Also have it move back to place if the mouse is off stage.

View 1 Replies

ActionScript 2.0 :: Move The Point Where The Mouse Is Placed?

Nov 10, 2009

Can You with a code move the point where the mouse is placed?

Example. If you have a row of buttons on a frame and when you click one of the buttons you don want the mouse to be on that very same spot because on the next frame are the buttons on the same place. You want the mousearrow to be placed on the top of the frame.

View 1 Replies

Actionscript 2.0 :: Mouse Over Point Scroll Left Or Right?

Jun 17, 2009

I seem to be having difficulty figuring out the code required for mouse over and scroll left to right. Basically, I have arrows either side of the window and I would my timeline to smoothly go to the left or the right when the cursor is over the arrow.

View 5 Replies

ActionScript 2.0 :: Movie Clips That Point Towards The Mouse?

Apr 23, 2006

i am looking to be able to have a movie clip that always faces the direction of the mouse and don't have the first clue how to do it. all i can guess is that it uses radians in some way.

View 3 Replies

ActionScript 3.0 :: Rotating MovieClip To Point At Mouse

Jul 4, 2007

I am trying to make a line point to wherever the cursor is when I stumbled upon the Math.atan2(); function. It appeared that i would put
line.rotation = Math.atan2(1,1);
to get 45 degrees or pi/4, but I was wrong. It barely moved the movieclip at all. So what I'm trying to do is to get this movie clip to rotate along with the mouse so the line is always pointing at the cursor. Also, how would you get movieclip to move along the line created by the line of these two points?

View 9 Replies

ActionScript 3.0 :: Calculate Mouse's Distance To A Certain Point?

Dec 4, 2009

What I am trying to do with AS3 in Flash cs4 is calculate the cursor's distance to given point (let say 400,300) and use that distance to constantly (20 fps) change my curtain's alpha value. (which is basically a box turned into a movie clip) [code]...

View 5 Replies

Actionscript 3 :: Find Closest Point To Mouse Position?

May 29, 2011

I've got a grid of sprites.Now I would like to drag an image on a grid-element.Therefore I need to know which x/y of the grid-element is the closest point to the mouse-position.

View 2 Replies

ActionScript 2.0 :: Object Follow Mouse ... Registration Point

Sep 5, 2009

im trying to make my plane movieclip follow the mouse... which i have achieved although i want to give it a regestration point so that when the mouse turns or goes left, right, back etc, the front of the plane goes with it so it looks realistic aposed to a plane image moving left and right.

View 1 Replies

ActionScript 2.0 :: Point To A Specific Scene When Mouse Is Inactive?

Oct 17, 2006

I'm working on a presentation to be presented on a Trade Show. It have an inicial movie, running in loop, but with a Menu bar, so people could stop the movie and go to a product catalogue. I want that when people stop looking the catalogue and go away, the presentation go (after a few minutes) to the initial movie loop again.

View 4 Replies

ActionScript 2.0 :: Scale A Beam To Mouse Co-ordinates/point?

Oct 23, 2008

I have attempted to make a movieclip scale in the y axis using _yscale but I can't seem to make it scale to the exact mouse co-ordinates.

Its within a rotating movie clip (controlled by the position of the mouse) and that works fine.

Here's the code I'm using at the moment.

Code:
onClipEvent(enterFrame){
var disty = this._y - this._ymouse
var dist = Math.sqrt(disty*disty)
this._xscale = 100 + dist;
}

View 6 Replies

ActionScript 3.0 :: Control A MC Position Based On Mouse Point?

Jan 20, 2011

I am trying to make an animation where the user can mouse over a small MC at the top of the stage, which controls the movement of another larger MC at the bottom of the stage.I am thinking that 'points' (which I know nothing about) might be the way to go. The other thing is that it needs to be fluid motion. Am I at least on the right track with points and mouse_move or is there a better approach for this?

View 2 Replies

ActionScript 2.0 :: If The Y Value Of The Mouse Cursor Reaches A Certain Point, The Scrolling Stops

Oct 13, 2009

Basically I have a scrolling bar with thumbs of images that you can click and view. The bar scrolls depending on where the mouse is located along the X plane. Basically, the greater the value of X, the faster the bar scrolls to a certain extent. I am trying to figure out a way that if the Y value of the mouse cursor reaches a certain point, the scrolling stops. Like if the mouse is scrolling off the bar of images itself, the scrolling stops. As it stands the scrolling is only controlled based on where the mouse is located along the X plane and it has nothing to do with the Y value. I would like to be able to stop the bar with a certain Y value. Make sense? I Hope So :P

[Code]...

View 1 Replies

ActionScript 3.0 :: ScrollWheel Zoom With Point Of Focus At Mouse Cursor Tip?

Jun 18, 2010

Looking for code to enable zooming in/out on a graphic or movie clip using mouse scrollwheel with origin of scale change being at the mouse cursor position. I have one where it is at top left. I also require it to stay proportional, when applied to a rectangular graphic my code makes it go letterbox on zoom out!

View 3 Replies

Flex :: Scale To Point (Zoom Into Image Where Mouse Clicked)

Jun 14, 2010

There is an Image control that when I click on it I need to zoom in (using the center/transform point where the mouse is clicked). I have the zoom transition working great, but when I set transformX & tranformY (with autoCenterTransform false) it doesn't zoom into that point.

Here is my code that only zooms in (not to a specific point)
<fx:Script>
<![CDATA[
protected function imgLogo_clickHandler(event:MouseEvent):void {
transformer.play();
} ]]>
[Code] .....

View 1 Replies

Actionscript 3 :: Flex - Display A Panel At The Point Where Mouse Is Clicked?

Nov 1, 2010

I would like to create a component(extending from spark Panel), which upon a buttonclick should show up next to the button(something like a bubble popping up or like the small box opening up when hovering up on profile links in facebook/twitter). I tried to create a component that implements mx.core.IToolTip and provided the methods required by the interface. And on the toolTipCreate event, set this component as the tooltip.

This works to an extent. When I bring the mouse over the button, the panel appears as the tooltip and goes away when i move the mouse away. What I need is, the panel should appear next to the button when click on it and should go away only when I click outside the panel or click the close button present inside the panel.

View 1 Replies

ActionScript 2.0 :: Make A MC Point (rotate) To Where The Mouse Was Clicked On Stage?

Apr 25, 2006

how to make a MC point (rotate) to where the mouse was clicked on stage ?

View 1 Replies

ActionScript 2.0 :: Function That Return Mouse Direction As Cardinal Point?

Dec 5, 2006

i'm searching for a function that return the mouse movement as Cardinal Point.In other words i would like to have as returned value, if mouse is going from down to top, North, if mouse move from left to right, should return East ... and so on

View 3 Replies

ActionScript 3.0 :: Make Simple Line With Mouse And Also Able To Reproduce It With The Save Point?

Aug 25, 2009

i want to make a line with mouse movement and with bnlur effect i also want to save those point to reproduce that, i know how to make simple line with mouse and also able to reproduce it with the save point but not able to do blur effect with it

View 1 Replies

ActionScript 3.0 :: Make A Bullet Launch At Different Degrees (anywhere From 1-360) From A Specific Point Towards The Mouse

Jul 30, 2009

I need to make a bullet launch at different degrees (anywhere from 1-360) from a specific point towards the mouse.

View 3 Replies

ActionScript 2.0 :: Objects Of Attraction - Towards The Mouse Cursor Within 100px And Return To It's Point Of Origin

Oct 29, 2006

How do I take Object_MC and have it attract towards the mouse cursor within 100px and return to it's point of origin when the mouse is 101px + away from the cursor, all while doing an "elastic" like recoil effect, and going from 50% alpha to 100% over that distance to the mouse?

View 1 Replies

ActionScript 3.0 :: Draw A Rectangle Or Circle Shape With Mouse And Scale By Setting The Point?

May 11, 2009

I want to make an editor like this site. [URL] If you browse this link you will find "Button. If you press this button you will navigate to a editor to design your layout. After draw a rectangle or circle or line you can resize that or can rotate that. When you finish if press the "you will back to the previous page where your desinged layout display. If you press the "" again then you will navigate the editor with the previously designed layout. I want to make a site like this. I want to use the flash cs4 to make the editor. Anybody knows how to draw a rectangle or circle shape with mouse and how to scale by setting the point and how to rotate by setting the rotation point also by using flash cs4 and as3?.

View 3 Replies

Professional :: Make A Circular Dial, Point At The Mouse Position While Staying Locked To It's Location?

Jul 23, 2010

I trained on flashMX back in the day and haven't done anything since so now I've got CS5 it's a bit like being at school again! I have a circular dial sat in the middle of the screen with an arrow placed on it's edge. How do I get the dial to rotate so it always faces the mouse pointer?

View 7 Replies

ActionScript 2.0 :: Make A Movieclip In Flash That Makes Buttons Spin Around A Point Depending On The Mouse Position?

Oct 9, 2007

I have recently followed a tutorial to make a movieclip in flash that makes buttons spin around a point depending on the mouse position. I have made my own version off this and would like to use it in a full flash website that i am making at the moment.

The only problem that i am having is with aligning this clip and as it is made up of script i cant physicly drag it to were i want it. I understand how to alighn this with x/y positioning but when i preview the flash in a web browser it is positioned correctly but then when i 'full screen' the browser this clip jumps about 4 inches down the page.

View 1 Replies







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