ActionScript 3.0 :: Finding A Point Relative To A Center Point?
Nov 9, 2010
I'm trying to figure out how to find a point relative to the center of an object, modified by its rotation. For example, in the attached swf, I've been messing around trying to draw trails to a bitmap, coming out of the thrusters. I didn't have a problem at first, but as the ship rotated, the lines that were being drawn wouldn't remain relative.
http:[url]....
I'm sure this is because I have no idea what I'm doing, and I've just been sort of idioting my way through it. That aside, is there an easy way to find the point I'm looking for? For instance, say I want a point at Y -14 of my ship, but I want that to remain relative to the ship as it rotates.
View 14 Replies
Similar Posts:
Jan 8, 2012
All though I can scale down the size of my objects and can shift them to their correct positions when scaling. I cannot shift them to the correct relative positions, relative to the screen centre.
Code:
level=1; //starting scale level
public function scaleOut(level:int) // scale to a level 1-4{
for (var r = 0; r < Main.ballArray.length; ++r){
// scale radius
Main.ballArray[r].bRadius *= (oldLevel / level);
[Code] .....
View 8 Replies
Sep 16, 2011
So let's begin. I want to build a wheel which you can spin, similar to a roulette wheel. You can do this both ways (CW and CCW, this issue causing the bug, actually). The wheel has some acceleration to it too, and I achieve this by measuring the start and final angle of the drag movement, using Math.atan2(dy, dx). The problem is the following: atan2 outputs the following angle scheme, assuming the point relative to which the math is done is in the center of the circle.
atan2 returns a value measured in radians, so I'm using the classic angle*180/Math.PI formula. I've changed this original scheme into the following, using some simple math to shift the angles a bit, to resemble more accurate circle angles (going up to 360 degrees) The problem that I'm facing at the moment is should the user decide he wants to swipe clockwise, and moves through the right point, where 0 turns into 360 or 180 turns into -180, the whole angle difference thing is capsized. It registers a CCW movement (as if the user swiped his mouse all around the circle). So, I'm looking for some ideas as to how I can work around this small issue.
View 1 Replies
Dec 31, 2010
i was wondering if there was something that allowed you to grab any 2d point that exists inside a movieclip and grab the 3d position of that exact point...
for example i have a rectangle movieclip on the stage .. and its rotate on the x axis 75 degrees.. registration of the clip is at bottom middle.. so when it rotates the bottom stays in the same spot and everything rotates around it..
now what if i wanted to know the exact x,y,z of the top edge of the clip..
is there a function similar to localToGlobal that would take the x,y coordinate inside the clip and spit back a global 3d point .. (i guess its called a Vector3D)
View 0 Replies
Aug 30, 2009
I got a working broad phase and collision detection is fast enough.Now my collision response is working, but slow. I have trace(using getTimer()) through the whole resolving method, and I found the slow spot is where I get the collision point and normal vector.
Right now, I test each point on each shape against each line on the other shape. This works nice on triangles, but other shapes, it much to slow.I would think that using SAT(seperating axis therom) would have a way to get this when checking collisions, but I cant seem to get it.I need a fast way to get the collision point and normal vector.(Right now, it takes about 3 milliseconds per collison on a rectangle with 4 points and 4 lines)
View 0 Replies
Aug 8, 2011
[Code]....
two balls are stationary on stage and I am dragging ball 1 between them. I want my program to deny the ability to do this (technical terms) and move the ball automatically to the closest point available that does not overlap either of the other two balls i.e. the left side of the dragged ball may touch but not over lap ball 3. I have a feeling the circular equation: (x-a)^2 + (Y-b)^2 = c comes into it but it may need pythagoras instead as the balls are all circular but not all the same size. The best way I can see for this is to write a multi-part equation for the bounds of boths balls and then finding the nearest point, but not sure how to do this in as3, perhaps using the 'for each' tag.
View 3 Replies
Oct 20, 2009
I have a dynamic image loading into a movie clip and i dynamically created a transform box around it. However the anchor point of that transform box is coming on the left top instead of in the center, which is not letting the image transform properly. how to dynamically put the anchor point to center through AS2?
View 1 Replies
Jul 9, 2010
I am new in action script 3... i am not able to rotate movie clip from center point(movile clip is a containear holding many clips).
View 9 Replies
Aug 26, 2010
i am trying to find center point of my pie.
var myTween:Tween = new Tween(piechart,"............", Strong.easeOut,1200, 510, 1, true);
i want to animate from the center and it has a xml driven data file.
View 2 Replies
Feb 20, 2009
I have a sprite and a tween created using actionscript.
the sprite resizes correctly but the center of resizing is the upper left corner.
How can I set the resizing point to the center using actionscript ?
View 3 Replies
Dec 10, 2009
how to do an effect like the one seen on this page?: http:[url]....
View 1 Replies
Dec 1, 2010
I´d like to know if it´s possible to find a minimum y point (where the shape ends) of a shape, in a given x coordinate.
Example: I have a complex shape like a big "S". Suppose the "S" minimum x coordinate is 0. How can I find the minimum y point of the "S" (again, where the shape ends) in the x coordinate of 14?
Here is the image: I need to find the y coordinate (or point) of the blue point in the image.
View 11 Replies
Jun 5, 2011
I have a Movieclip (MC1) with and moving object (OBJ1) inside it and using AS3. I want to do a hit test on it with another object (OBJ2) that is on the stage. Normally I would just do MC1.x + OBJ1.x to get my coords for the hit test. But how do I do it if MC1 has been rotated?
View 2 Replies
Apr 7, 2011
I'm trying to get a triangle to spin in place,
View 7 Replies
Mar 28, 2010
Can I set the registration point of a MovieClip (or other Display Object) to its center upon creation in AS3? the following
[Code]...
sets the registration point of myClip to its top left corner by default. Using Flash CS4 to set it to its center is just a couple of clicks, so I am wondering how I can perform the same action only with code.
View 3 Replies
Aug 9, 2011
I searched online and found this script that is supposed to rotate and image but I'm not sure how to use, where to put in the degree angle that I want my sprites to rotate by. Also, I get an error. 1084: Syntax error: expecting identifier before leftparen. 1084: Syntax error: expecting rightparen before leftbrace.
var point:Point=new Point(spr_box.x+spr_box.width/2, spr_box.y+spr_box.height/2);
rotateAroundCenter(spr_box,45);
function rotateAroundCenter (ob:*, angleDegrees) {
[Cde].....
View 1 Replies
Jan 30, 2012
I'm trying to rotate a point in my Canvas from a given point (center). In my MouseDown handler, I save the point where user click (oldPos), and in my MouseMove handler, I'm doing this:
private function onMouseMove(event:MouseEvent):void
{
// Where the user pointer right now
[code]......
View 1 Replies
Dec 28, 2010
How Can i Set registration point to to the loader at the center by using as3 ?
View 5 Replies
Sep 8, 2011
basically just wondering if its possible to scale an MC about the center of the stage as opposed to the top left of the MC? I thought about setting the X & Y as stage width / 2 + MC width / 2 but cant as the user needs to be able to move the MC which is much bigger than the stage and zoom in on a point in the center rather than just the center of the MC.
View 2 Replies
Dec 1, 2007
I'm trying to use Zoom transition for my photo Gallery which I'm using loadMovie "jpg" from Xml file.Now the problem is here. The Registration Point is set to the top upper left corner and I would like it to be in the center of my loadMovie.The Zoom transition only zoom from left corner and need to be center equal sides. How do I do this. My image size is "width 400px height 240px
View 4 Replies
Mar 9, 2009
I am trying to rotate some points around the center of the circle(0,0), however I'm getting weird values from the output. I've commented the problem code..
Code:
var r:Number = 10;//radius
var y:Number;
var x:Number;
var a:Number = 90;//angle of which the semi-circle is facing.. could be a random angle.
var ax:Number;//rotated points
[Code] .....
I am using the semicircle in BitmapData collision checking with getPixel(), with a moving circle...
View 1 Replies
Nov 16, 2010
I'm making a 3D room builder. The user places Sprites around the 2D stage and my script converts those Sprites to Papervision3D DisplayObject3D objects. I'm having problems with the 3D object positioning because Sprites have registration points at their top-left corner and 3D objects have registration points at their center. How can I make that conversion?ere's a scheme of how the 2 different coordinate systems work:
I've tried this code:
child3D.x = child2D.x;
child3D.z = child2D.y - child2D.y - child2D.y; // just to make it negative
[code]....
View 5 Replies
Feb 1, 2010
Using the new 3D features in CS4. I know you can change the 3d center point manually via the Transform panel, but does anyone know how to do this dynamically at runtime? (ie via code)
View 1 Replies
Jul 11, 2011
I'm trying to Resize a panel using a Resize Effect using its center as the anchor point. I've been googling for some information and the only thing I have found is to set the horizontalCenter and verticalCenter to 0, but this is not working for me. The panel keeps resizing from top/left corner.
View 1 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
Dec 6, 2009
How to find out different circle's center point of a bitmap?
just like photo above, how can i locate the 2 center points of circles?
i only know using .getColorBoundsRect to get a point, but this only apply to one circle, in fact i wanna get different points according to the bitmap.
View 1 Replies
Dec 1, 2010
I'm trying to add some zooming functionality. The problem is that when you zoom in and out, it scales the MC up and down from where the registration point is. This means That when I'm far from the position of the registration point instead of zooming the in straight it also makes it appear as if you are travelling towards the registration point.
To offset this effect I want to calculate the amount of pixels I need to offset the Map by so that it appears as if you are zooming in directly.
So just as a test I've put a little ball inside the map(called "center") which I'm trying to keep in the center of the map.[code]...
View 1 Replies
Dec 9, 2010
Is there a way to use the scaleX and scaleY property in conjunction with the Tween class to scale from the center?ActionScript Code:[code]above unfortunately only scales from top left. This is not a class I can go in and move all the content by hand (so that the registration point is in middle) as it's all dynamic. I've looked al over but none seem to make use of the Tween class.
View 8 Replies
Jun 14, 2011
I draw a shape,like follows:
var shape1:Shape;
shape1=draw();
addChild(shape1);
shape1.rotation=50;
[Code]....
Then I want to rotate the shape at it's center point(200,202) by using shape1.rotation=50,but I find the shape don't rotate at the the center of it's shape. How to realize the function which make shape rotate at its center point?
View 4 Replies
Jul 11, 2003
I start with a question: how could I change the registration point of a movie clip created or loaded at runtime? I want to move the registration point from top/left to center.
View 2 Replies