ActionScript 3.0 :: Shoot An Moving Object Exactly In The Center?
Dec 5, 2011
I have a TargetCirlce_mc which moves on "y" axis from top to bottom. And I have an arrow_mc which is on x:100 & y:200. How can I shoot an arrow exactly on the registration point of the TargetCircle_mc (automatically) while it is exactly opposite to the arrow_mc?
View 1 Replies
Similar Posts:
Oct 30, 2009
I made a pact that I'll use only AS3 from now on but.. The tweening class is confusing me. Take a look at this: [URL]. Finding code that will make the earth move down into center of canvas and simultaneously grow larger?
View 21 Replies
Feb 25, 2010
I am developing a game like this. [URL]. I just start this game And stuck in a problem. Moving arrow of game according mouse moveing like Given URL just check out. I know it is just a mathematical calculation. I have done according X position of mouse moving. But confuse something With Y position also. So I am not getting proper solution of X & Y position Both Togather.
View 2 Replies
Sep 21, 2009
I found a basic example of how to create something that'll shoot an object and create an arc based on an angle. I added a power Bar to it, but I noticed something bad about it.
The way it works the higher the speed is the further it goes and the faster it moves across the screen. This doesn't give me enough control. Because essentially I want fast moving projectiles but I want to also be able to shoot both near and far.
With this current system that's an impossibility.. Can anyone shed some light on how I can do this better? Here's the current way it's being done (important parts):
Code:
bullet = new Bullet;
this.stage.addChild(bullet);
bullet.speed = 1 + powerBar.scaleX * 20;
[Code].....
View 2 Replies
Sep 28, 2002
i've posted many times and got loads of responses but i dont understand how to make a bullet hole appear when you shoot an object. MSN me a [URL] to have a chat about doin the actionscript.
View 1 Replies
Apr 7, 2011
I'm trying to get a triangle to spin in place,
View 7 Replies
Oct 25, 2011
This tutorial si about moving star out of the stage center, this is the script:
import flash.display.MovieClip;
import flash.events.Event;
var container:MovieClip = new MovieClip();
addChild(container);
addEventListener(Event.ENTER_FRAME, addstarred);
[Code]...
View 2 Replies
Feb 21, 2011
I am in the midst of finishing up a design application where you can upload images and colors. I use the greensock transform manager. I am taking anything a user does and recording it so I can recreate what they made on larger scale behind the scenes (to be exported for printing purposes)
The problem I am running into is with rotation and moving x and y values. The transform manager does everything relative to a center point, but when i recreate the image object the registration point is at the top left. I have found how to rotate around the center of the object using the transform matrix, but I can't seem to move the x and y correctly because these values change when you rotate. I want to just move the image to the left or right relative to the center. How could I go about doing this.
Here is how I rotate.
private function rotateAroundCenter (ob:*, angleDegrees:Number, ptRotationPoint:Point) {
var m:Matrix=ob.transform.matrix;
m.tx -= ptRotationPoint.x;
[Code]....
View 1 Replies
Oct 27, 2011
I'm working on my first game engine with AS3 and I'm hitting my first real setback. The idea is that the player controls a centered "turret" on the screen and can't move. Enemies come from all 4 sides and move towards the player. I have all the enemies spawning, randomly, on the edges of the screen. However their movement is silly, because I've coded it like this:
Code:
if (x > 300)
{
[code]........
View 2 Replies
Feb 23, 2012
I am trying to do a apply a tween for the width property on a MovieClip Object but every time it changes the width and the position too, and I don't want that. I want to change the width going to one side without changing the x and y of the object.
I tried both of thes and they gave the same result.
var c:Tween = new Tween(left, "scaleX", Strong.easeOut, 1, 1.5,20,true);
var c:Tween = new Tween(left, "width", Strong.easeOut, 20, 200,20,true);
I think it is applying the transformation according to a center of the movie clip. but I don't know how it can be changed.
View 2 Replies
Apr 13, 2011
Im working on a small project and it involves a guy which you move with the arrow keys. The arrow keys add to his x, y velocities and his position is updated accordingly. How can i get this man to grab onto an object and spin around it (like when you grab pole and letting your momentum swing you around) . I can make him grab the object but I dont know how to modify his x,y speeds to simulate the arc.
View 4 Replies
Oct 13, 2010
my title explains what im need but im using flash cs4 and heres what i have so far:
var centerX:Number;
var centerY:Number;
var centerZ:Number;
[Code].....
ok so RBall is my first moving object and my orbiting object will be called orbit
View 9 Replies
Sep 17, 2009
I want to make a fluid layout for the website I'm working on right now. I know the basic concepts of how to center an object and keep it there, or how to stick a shape to the top or bottom... etc. But if there's a movieclip that I would like it to conserve its position proportionally as the visitor resizes the stage, how can I do that?
View 3 Replies
Oct 4, 2010
I'm using CS3 with ActionScript 3.0. What I want is simple, and I've done some searching but nothing that can get me the right results.I'm going to post a link that does exactly what I want: http:[url]......This rotates the circular object around a center point in a way that you can distort the object yet is still remains turning in a circular motion. A simple motion tween rotating the image will only work if the object is perfectly round, so distorting the object to make it more straight or curved won't work with a simple tween. I want to do exactly what is happening here (with my own object), is there some AS3 behind the scenes here making this turn on a center point?
View 3 Replies
Jun 9, 2009
I have problem to center my movie clip by tween class, check my file. I need the object to center and it goes to left..
Code:
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
[Code]...
View 3 Replies
Feb 9, 2011
I have a situation where i have a horizontal scrolling container that has a video object inside it. the video object has to stay inside the scrolling content for another reason i don't want to get into here. Now the client wants me to keep the video in the center of the stage even when the clip its inside of is scrolling. Normally I would just take it out of the scrolling clip and place it above the scrolling content but i cant do that here. I tried this math but it didn't work exactly. on an enter frame when the video is open I have this code;
Actionscript Code:
if( vid ) vid = ( stage.stageWidth/2 - vid.width/2) - scrollingContainer.x;
View 4 Replies
Oct 4, 2010
I'm using CS3 with ActionScript 3.0. What I want is simple, and I've done some searching but nothing that can get me the right results. I'm going to post a link that does exactly what I want:This rotates the circular object around a center point in a way that you can distort the object yet is still remains turning in a circular motion A simple motion tween rotating the image will only work if the object is perfectly round, so distorting the object to make it more straight or curved won't work with a simple tween. I want to do exactly what is happening here (with my own object), is there some AS3 behind the scenes here making this turn on a center point??
View 5 Replies
Dec 8, 2010
I am just getting back into using Flash after not using it for about 5 years. I'm having an issue with the simplest thing! I want to be able to type pixel values into the Properties panel to transform/resize an object from the OBJECT CENTER as reference point. If I use the transform tool, it uses the center of the object as the reference. However, if I do as above and type values into the Properties width/height, the object transforms with the top left corner as reference. If I need two or more objects sized exactly the same, or if I want to do a "zoom in" effect, using the transform tool is very ineffecient!
My object seems to be showing that the center is set as the reference point (white circle in center of object). Also, the objects I am working with are jpg's and psd's imported to the library, and made into movie clip symbols.
View 9 Replies
May 10, 2010
I have two MC's on the stage. One of them is standing still in one position, the second one is moving towards it. I want the moving mc stop right at the very centre of the first mc. I've tried using hitTestPoint, but I don't know how to set the proper parameters. If I put there just: mc1.hitTestPoint(mc2.width / 2, mc2.height / 2, true), the trace function I use doesn't seem to have even noticed the collision...
View 1 Replies
Jul 29, 2011
I have an object i want to drag, how do I center it under the mouse?
View 4 Replies
Mar 5, 2005
i was wondering if there was a way to center a loaded movie to the object it was loaded in to..using this
loadee.loadMovie("load1.swf");
to load the movie into clip loadee , the clip is located the the center of the main movie, now i want the clip that was loaded into the placeholder clip to be in the center of the movie, instead of the upper left corner of the movie being were the placeholder clip was
// VoS
View 2 Replies
Mar 19, 2009
how to lock the mouse to the center of the drag object but instead of the center of the object moves towards the mouse its the mouse who's going to move towards the center of the object? This
PHP Code:
startDrag(this, true);
locks the mouse to the center but its kind of annoying to see the object jumping specially if the object is big.
View 3 Replies
May 24, 2010
I have had some help but still not understanding this.
How can I scale an object from center after it is dragged by the user?
Currently I have this:
function onSliderChange(e:SliderEvent):void
{
scaleClip(slider.value);
}
[Code]...
With this code the movieclip jumps back to the center of the stage each time I call the scaleClip() (move the slider). I would like the object to scale from it's own center regardless of where it is on the stage.
View 2 Replies
Aug 9, 2010
I am making a small tool for making simple T-Shirts designs. Everything is perfect except that I don't manage to rotate an item the way I want. I am makeing everything from ActionScript. When I load an image on the design it is added to the stage. I have an object called "ImageView" that extends MovieClip. It has some properties and some methods (ex kill() that removes the object and all associated listeners). In this object I also add the image that is loaded from a location. When I click on the item another object "Transformer" is added on the stage. It surrounds the ImageView and adds some controls for rotating and scaling the image.
My problem is when I rotate the ImageView. It rotate according to (0,0) (obviously). What I want is to be able to rotate it according to the center of the ImageView. A solution is to set the picture inside the ImageView in such a way that (0,0) is the center of the picture. But I try to avoid this since it will cause some problems (that will requiere more coding) at "TextView" (a class that has text instead of an image).
View 3 Replies
Oct 4, 2010
using CS3 with ActionScript 3.0. What I want is simple, and I've done some searching but nothing that can get me the right results. I'm going to post a link that does exactly what I want:This rotates the circular object around a center point in a way that you can distort the object yet is still remains turning in a circular motion. A simple motion tween rotating the image will only work if the object is perfectly round, so distorting the object to make it more straight or curved won't work with a simple tween. I want to do exactly what is happening here (with my own object), is there some AS3 behind the scenes here making this turn on a center point?
View 3 Replies
Apr 30, 2004
this is sort of a cross post (yes AND sorry), but I realized that it makes more sense to post it here than in FlashMX - so the moderators are welcome the first post. What I'm trying to do is gradually minimize an object, when dragged into a certain area. Let's say I have a box and when it is dragged away from the center it becomes gradually smaller.
View 11 Replies
Mar 5, 2005
i was wondering if there was a way to center a loaded movie to the object it was loaded in to..
using this
loadee.loadMovie("load1.swf");
to load the movie into clip loadee , the clip is located the the center of the main movie, now i want the clip that was loaded into the placeholder clip to be in the center of the movie, instead of the upper left corner of the movie being were the placeholder clip was
View 2 Replies
Aug 31, 2010
When I insert my object into my scroll pane it does not center.
View 3 Replies
Oct 27, 2011
I've created an mc which functions as my map and controls to go with that which allow the map to be moved around and key points navigated to and zoomed in on at varying zoom levels.I'm using scaleX and scaleY to scale the map mc and a list of x and y positions to correctly position the map for each key point.When I want to go to a certain area I perform this calculation (offsetX and offsetY are the center of the screen):
newX = posX * scale + offsetX;
newY = posY * scale + offsetY;
Then I tween the position and scale of the map to smoothly scale and move the map to the correct position:
var tween = new TweenLite(_background, EASING_SPEED, {x:newX, y:newY,scaleX:scale.getScale(),scaleY:scale,ease:EASING_TYPE,onComplete:moveToComplete,onCompleteParams:[room]});
I now need to implement a zoom in / out function and this is what I'm struggling with. The zoom should use the center of the screen as the reg point for the scale, so I've been trying something along the lines of the following to get the correct positioning:
var newX = offsetX - (offsetX - _background.x) * scale;
var newY = offsetY - (offsetY - _background.y) * scale;
So in my mind this gets the distance from the current position of the map relative to the center point of the screen (offsetX, offsetY) then scales that distance by the new scale. However, this is clearly wrong because it's not working and the positioning of the map is wrong.I've also tried using a transform matrix to get the correct values but I know even less about them and not got the right results.
function scale(target:MovieClip, center:Point, scale:Number):Point {
var m:Matrix = new Matrix();
m.translate(-center.x, -center.y);//move the center into (0,0)
[code]....
View 3 Replies
Jan 15, 2010
I'm building a class at the moment for transforming and scaling content with align, constrain and scaling options.
This is just just fine if the transform center is LEFT or TOP_RIGHT, or what have you, and always within the object bounds, but I haven't yet tackled situations where objects are NOT nicely aligned, or the transform point is outside of the object bounds.
View 3 Replies