Flash :: DisplayObject.rotation Not Matching Trig Functions

Mar 19, 2010

I'm trying to label an animated pie chart, and I've been having a great deal of trouble getting rotated objects to line up with trigonometrically-positioned objects. So, for example, if I have a pie piece that's middle is angle theta and has been rotated n degrees in a tween, and then I try to position a label with code like this:

label.x = center.x + Math.cos((theta + n)/180 * Math.PI) * radius;
label.y = center.y + Math.sin((theta + n)/180 * Math.PI) * radius;

the label is often not aligned with the center of the pie slice. Since I am also zooming in to the pie chart a great deal, the error becomes significant enough that it occasionally causes the label to miss the pie slice altogether. The error seems relatively unpredictable, and it looks a great deal like a rounding error, but I don't see any obvious rounding going on (the trig functions evaluate to ten or so decimal places, which should be more than enough here).

How can I get these labels to position correctly?

View 1 Replies


Similar Posts:


ActionScript 3.0 :: Flash DisplayObject Container Matching All Elements With AddChild() On Criteria?

Mar 1, 2012

I'm coding this minigame implementation where a sprite traverses tiles on a screen, and when he's done traversing a tile, the tile "disappears" (its alpha decreases and it becomes a "wall" the player can not move onto). Now, simple enough. Make use of a traversing and traversed boolean arrays to store if a tile is currently being traversed, or if it isn't, but it has been traversed. So, if traversing == 0 and traversed == 1, make the tile "disappear". However, and here's the weird part, if I just set the alpha to, say, 0.5 in this if statement, it sets the alpha on just the tile I traversed, whereas if I try to make it part of the wall as well (in the same if), every tile except the one I've traversed to becomes a wall.

Here's part of the code (it happens in the enterFrame game loop):

Code:
const NUM_TILES = 15;
//Add MC for all the tiles
var tiles = new MovieClip();
addChildAt(tiles,5);

[code]....

View 1 Replies

ActionScript 2.0 :: Randomly Generate Trig Functions?

Jul 9, 2006

Does anyone know if there is a way to randomly generate trig functions (sin, cos, tan). I am trying to make poblems using these functions. The examples that I see are automatically assigning values to these functions however I want to randomly generate. Example from flash 8 help feature[code]...

View 2 Replies

Flash :: Move A Displayobject Based On Another Objects Rotation?

Jan 17, 2010

Ive probably ran into some code like this before. just cant remember where. I have 2 display objects on my stage. One is rotating and the other is positioned 90 degrees from the rotating object. As the object rotates, the other object adjusts its x and y positioning from the rotating object..

If this doesnt make sense, then let me explain what I am trying to do. I have a spaceship in my flash game. this ship has 2 torrets siting on the left and right wing. as the ship turns, the torrets need to remain on the wings.

View 2 Replies

IDE :: Set DisplayObject Rotation In IDE?

Oct 13, 2011

I can rotate it, or modify>transform>rotate +/- value

but what is the manual equivilant to simply object.rotation=0;

View 4 Replies

Flash - Trig Equations To Create Ellipse

Feb 13, 2011

I am working with this function that moves an object around a center point in a perfect circle and am trying to modify it to move it in an oval shape that is 1/2 as high as it is wide?

Basically, I have a set speed
var myVelocity:Number = 0.25;
Then I calculate my Sine and Cosine based on the speed
var myCos:Number = Math.cos(myVelocity);
var mySin:Number = Math.sin(myVelocity);

Then I figure the distance of the the object from a fixed center points along each axis and
var x1:Number = myBall.x - centerX;
var y1:Number = myBall.y - centerY;
var x2:Number = myCos * x1 - mySin * y1;
var y2:Number = myCos * y1 + mySin * x1;
myBall.x = centerX + x2;
myBall.y = centerY + y2;

I have another function that figures x and y based upon myBall.x = centerX + cos(angle) * radius; that is easy enough to modify the radius to become an ellipse, but is there an easy way to mod the one above to become an ellipse? I want to do this to be more efficient with the code and reduce the number of math function calls

View 1 Replies

Flash :: AS3 GESTURE_SWIPE With N-Trig Powered Touch Screens

Oct 18, 2010

I'm currently developing a prototype using AS3 and trying out some touchscreen gestures. I'm compiling using AIR 2.0 and currently have GESTURE_ZOOM and GESTURE_ROTATE working but for some reason GESTURE_SWIPE is giving me a few headaches. I know It's possible as I've seen it working here, using the same laptop (DELL LATITUDE XT2 & N-TRIG) as I'm testing on.

[Code]....

View 1 Replies

Flash :: Check If DisplayObject A Is A Descendant Of DisplayObject B?

Oct 26, 2010

I would like to be able to quickly check if a given DisplayObject is a descendant (not in the inheritance sense - ie. child, grandchild, great-grandchild, great-great-grandchild, etc.) of another DisplayObject. There doesn't seem to be a native way to do this and I can only think of two ways to achieve it: Create the mother of all nested loops. Seems a bit, I dunno, wrong? Dispatch a bubbling event at the 'child' and check if the potential 'parent' receives it.

[Code]...

View 2 Replies

ActionScript 2.0 :: Drawing An Arrow With A Line - Trig?

Feb 19, 2006

Im using the drawing API to draw lines between movie clips, join the dots style, but is there a way to draw an arrow in the centre of the line indicating which direction its going? I know it will involve trig i think and i guess it will be something like (1 find the mid point of the line (2 find the direction by checking the start point and end point (3 draw a triangle somehow that goes in the right spot. It shouldnt be too hard if u know your trig i bet...

View 12 Replies

ActionScript 2.0 :: Trig - Rotating An Object Based On 90 Degrees

Jul 8, 2007

rotating an object based on 90 degrees. For example, I only want the characters rotation values to be 0, 90, 180, or 270 based on the angle between the mouse and an object. I used to know a formula that worked right into the atan2 method, however sadly I had forgotten it

View 2 Replies

Flash :: Logic For A Matching Game?

Feb 5, 2011

I was given a task to make a match making game in actionscript 2, problem is, i have very little knowledge about the language (well, and how matching works in as2, what are the important codes, code emplacements, and all I am new in AS2, and i really need a lot of help with our project. :)

I plan to match images. But.. I was planning to have a sort of "Compatibility" match-up game, like,..let's say we have two batteries, one has a 50v capacity(how do u measure batteries?) then the other has a 100v capacity, then there's this battery slot that only accepts a 50v battery, then you will have to match this 50v battery to that battery slot, that's my concept for the game, sir. I hope you got what i said, sir. :D

View 1 Replies

ActionScript 3.0 :: Flash Matching Pattern Algorithm

Dec 2, 2010

[Code]...

Is there a way to do this with RegExp maybe? I know that I could just add each variation of each pattern to the array, and just search it, but I want to do it more intelligently.

View 4 Replies

Flash :: Strange Behaviour In A String Matching Algorithmn

Aug 13, 2011

I know my 'algorithm' isn't useful at all, but I think I encountered a very strange behaviour.

[Code]....

View 1 Replies

ActionScript 3.0 :: Rotation Center Is In Left Of The Image - Aren't 3D Rotation From Transform Panel

Jan 7, 2010

I have a movieclip and when I do 3D rotation from Transform panel, It rotates perfect, center is in the middle of image, and when I apply mc.rotationY, rotation center is in left of the image, aren't 3D rotation from Transform panel and mc.rotationY from AS same? what's up?

View 2 Replies

Actionscript 3 :: Augmented Reality Flartoolkit Rotation - Trace The Rotation Of The Marker

Mar 23, 2011

I'm trying to do some augmented reality projects with flartoolkit . I can now put simple 3d objects on my marker and it works fine , but I wanna give my project some events that the user can interact with. I'm trying to trace the rotation of the marker. there's a container:DisplayObject3D which my application uses to add the 3d objects , I traced this :"trace(container.rotationZ)" but it's just returning 0 . I studied another AR application's source code and it was using the rotation of it's container object without problem .and I think I should mention that I'm using the exercise file of seb lee delisle papervision3d course from [URL]. anyone has any experience with flartoolkit? the main functions of my my code is as below:

[Code]...

View 1 Replies

Flash - Add Functions To Playerglobal.swc Or Allow Compiler To Pass Own Functions

Oct 25, 2011

Im adding lot of simple functions to prototypes of top level objects ( Object , Array , String ...) and have 2 questions :

Is possible to add functions to top level's classes in compile-time ?

If not , is there a way to allow this functions to compile ? I dont like to turn off strict mode

ex:

string.removeWhiteSpace();
string.sliceStr("." , "end");
textField.scrollBottom();

this return compile-time error , cause there is no such function , i have to write it in braces :

string["removeWhiteSpace"]();
string["sliceStr"]("." , "end");
textField["scrollBottom"]();

and i like to aviod it )

View 2 Replies

ActionScript 3.0 :: 3D Rotation Of Nested Movieclips, Separate Of Parent Rotation?

Aug 11, 2010

Is it possible to have the child movieclip rotate separate of the  rotation  properties assigned to the parent? so ultimately giving the  child  element it's own axis?I've customized Lee Brimelows (gotoandlearn.com) 3D carousel to spin  on  the x axis to make it a vertical carousel. I've also rotated that by 45 degrees on the y axis to see all the items, and wrote a snippet of   code to hide the left portion of the carousel. The entire  carousel is contained within the 'container' movieclip, and  inside of  that are my carousel items (as seen below), with the larger  item being  the item in focus.

On rollover of the item in focus, I want to rotate it so it faces the   viewer (as seen below),basically removing the 45 degree rotation   applied to the container.The problem i'm running into is when you rotate the container (changing   the rotationX of the container), the axis basically rotates with it, so   when i rollover the next item 'in focus', the following happens..(in  the  example where it appears how it want it to, the carousel is at a   rotationX of 0, so it works fine)

View 2 Replies

Flash :: Create A Accurate Chronometer Matching Real Time?

Sep 23, 2011

I'm working in an educational software, mostly developed using Flash AS3, and we have a chronometer which shows different values through different users. Example: Two users starting the chronometer at same time, but along some minutes of usage, they have different values.

The current implementation uses Timer class, causing this to happen, obviously due the different average speed of each computer.

View 1 Replies

ActionScript 1/2 :: Inconsistent Rotation - 270 Degrees Of Rotation Disappear?

Apr 21, 2009

Program A has a cannon that aims to line up with where-ever the mouse is pointing, in 360 degrees, and fires when the mouse is is clicked. Program B has an eye instead of a cannon that should in theory do similar functions when the capslock key is toggled, but instead only has a 90 degree range of motion from the Right of the eye toward the bottom (quadrant 4 only). Where did the ther 270 degrees of rotation disappear to?

[Code]...

View 4 Replies

ActionScript 2.0 :: Create A 3d Rotation Much Like The Widely Used Carousel Only The Rotation?

Aug 11, 2006

i.m trying to create a 3d rotation much like the widely used carousel only the rotation i desire consist of four upright(90 degrees) movieclips resting on a slanted, 30 degree plane which rotate onEnterFrame or following a tween on a oval like path - then pause for a given number of seconds at the four movieclips positions equal in distance on the plane

function around() {
this._x = Math.cos(this.angle) * radiusX + centerX;
this._y = Math.sin(this.angle) * radiusY + centerY;
var s = this._y /(centerY+radiusY);

[code]....

View 7 Replies

IDE :: Z - Rotation X And Rotation Y Missing In Motion Editor Panel

Feb 23, 2009

Why isn't there the Z, rotation X and rotation Y fields in my motion editor panel?

View 1 Replies

Flash :: Search BitmapData Object For Matching Pixel Values From Another Bitmap?

Jun 16, 2010

Using Actionscript 3 is there a way to search one bitmap for the coordinates matching pixels of another bitmap?

[URL]

Somehow you would have to loop through the bigger bitmap to find and the the pixel range that matches and return those coordinates. For example the Bitmap with the "E" is 250 pixels over and 14 pixels down in the bigger bitmap.

View 2 Replies

Actionscript 3 :: Drag And Drop Matching Type Game With Groupings In Flash

Oct 28, 2011

sorry for the misunderstandings in my program, i'm quite new here and i am also new in using flash. here is the sample output that i used in my code

[Code]....

View 2 Replies

ActionScript 2.0 :: Flash 6 Importing Data Into Array And Matching It To Case Switch?

Feb 3, 2011

A quick review of the project, I am importing information from an xml file into an array. From there I have passed the information from the array to a variable.I find it that when I try to match the variable to a string letter, that it is not running through the case switch properly and going straight to the default bit. I have tried numerous solution to check where the problem lies;I have trace the actual position of the array to check if it is the correct letter I am trying to match.Did a length check on the variable that it is only 1, and not containing any spacesWhen I hardcode the letter into the variable, the case works perfectly.Any idea on why this is happening would greatly be apreciated. I have pasted a sample of the code below;

var switchTest = initialSlide_array[1];
switch (switchTest) { //switch case used to check template type
case "A":

[code].....

View 2 Replies

ActionScript 3.0 :: Flash Matching Items In An Array To Movie Clip Labels?

Feb 6, 2012

I have an array that holds a list of items. In a movie clip, I have that same list as the frame labels. I'm using a for loop to iterate through the array and then assigning event listeners so that when you roll over an icon, it sends the movie clip to the right frame label (matching the item in the array).

However, the code I have now only returns the first match and not any of the others. Here's my code:

Code:
for (var j:uint = 0; j<interiorCallouts.length; j++) {
featureTextArray[j].text = interiorCallouts[j];
featureArray.length = interiorCallouts.length;

[Code]....

See the showCallout function. I'm using the interiorCallouts array to match the frame label in the callouts_mc, but I'm only getting the first match. None of the others.

View 4 Replies

Actionscript 3.0 :: Rotation X Rotation Y Don't Show?

Oct 8, 2009

I am watching the tutorial on the motion editor and when he opens the motion editor to edit the Rotation X and Rotation Y values I'm in trouble.My motion editor now only shows Rotation Z but, no Rotation X or Rotation Y. What am I doing wrong?

View 1 Replies

Flash :: Can't Add Module As DisplayObject

Jun 5, 2011

I'm trying to load a module and add it to a mx:box object called "mod". [code]...

View 1 Replies

AS3 :: Flash - Add A Border To A Displayobject?

Jun 29, 2011

I know how to draw a rectangle and add it to a DisplayObjectContainer,but do you see a simpler method to directly add a border to a DisplayObject? DisplayObject don't seem to have addChild(), so I would have to add it on the parent, which is not perfect in my opinion...

View 3 Replies

ActionScript 3.0 :: 3D - Rotation Via MatrixTransformer - Do A "pseudo 3D" Rotation Of A Movie Clip

Dec 2, 2008

I am trying to do a simple "pseudo 3D" rotation of a movie clip. The clip would "flip" on to the screen. I have created the effect using PaperVision3D, however, the final SWF is about 64k and my project requires a smaller file size. I tried to create the flip effect manually by creating skewed versions of the clip and tweening between them, except this doesn't work because the shape is not tweaked along the vanishing point as it should be. It looks like perhaps I could accomplish what I want to do using the MatrixTransformer but I've not had much luck so far.

View 3 Replies

ActionScript 2.0 :: Pause Rotation On Rollover Of A Movieclip And Restart Rotation On Rollout Of The Movieclip

Oct 3, 2006

I'm trying to pause my rotation on rollover of a movieclip and restart rotation on rollout of the movieclip. Here is my current code,

[Code]...

View 1 Replies







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