Actionscript 3 :: Get Visual Corner (eg. TopLeft) Of Rotated DisplayObject?
Feb 6, 2010
When rotating a display object (around its center) the visual corner of the element moves (the actual x and y of the "box" remains the same). For example with 45 degrees of rotation the x coordinate will have increased and the y coordinate will have decreased as the top left corner is now at the top center of the "box".
I've tried to use displayObject.getBounds(coordinateSpace).topLeft however this method is simply returning the x and y of the box and thus doesn't change after an object has been rotated.
So, how do you get the x and y of a visual corner of a rotated display object?
Update: this is what I mean with the position of a visual corner after rotation -->
The button is rotated on the Y axis and the rotate pivot is in the middle of the button.
This will create a button that looks something like this[code]...
I put together a sample to show off the various approaches for calculating this that people are suggesting. The source code is also available. Nothing is quite working like I'd expect. For example, turn the rotationSlider to 85. The button is effectively invisible, yet all approaches are still giving it height and width.
I ran into an issue with an app that I have been working on.The application lets a user draw a rectangle, which base class is UIComponent, on an SVG Canvas. The user can rotate, skew, scale,flip horizontal and flip vertical the rectangle. Then they can drop an image into the rectangle.We just cloned the rectangles matrix and applied it to the image and the image would transform the same as the rectangle. Well now we have changed the way the app works.
Now we don't want the image rotated or flipped on the initial drop, and this is where I'm having trouble.I was wondering if there is a way to always find the true top left of any rectangle no matter what kind of matrix is placed on it. I can find the center of the rectangle but when a user flips the rectangle the center point is outside the rectangle.Instead of finding the center I would like to find the topLeft.I have tried several things. Like transform.pixelBounds, but this gives me big numbers like 2200 instead of 400. I have also looked at senocular.com but not sure that I understand it.I just need a dynamic way to always find the top left.
I create their basic Flash app with their Flash IDE for Visual Studio 2010 http:[url]....When launching the run button, it launch flash but with this error within Flash CS4: The following JavaScript error(s) occurred:
t line 6 of file "FlashApplication1.jsfl": Cannot find file file:///C:/temp/FlashApplication1/FlashApplication1/FlashApplication1.as.
Here is the flash file I am referring to: [URL] You can view it online here: [URL] Notice how when the navigation loads in on the left, the WhipSmart logo Goes to the topleft? Well I don't want it to do that. I want that to happen ONLY when a user clicks on a navigation link.
So how it should looks is: The whipsmart logo appears big (as it does), the mid text loads and WhipSmart logo gets a bit smaller (as it does) and THEN it needs to stay like that until a user clicks on a menu item (it doesn't do that now, right now it automatically goes up to the topleft without the user making an action).
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.
I am making something flash flip like: [URL] but i want to do it in my banner 1000 width and 299 height problem is that i have few banner images i think 5 to 8 and i want to start my flip from "bottom-left" corner till "top-right"
I am facing a curious issue. Generally when we draw lines in Flash either vertically or horizontally or through exact 45 degrees on either of the sides, they come out as straight and anti-aliased. While if they are drawn deviated from either 0 or 45 degrees, they come out as jagged. I want that to be anti-aliased too
When I select the text tool in Flash and click on screen to type, my text box is default rotated 90Ė clockwise. In addition, the text is default bottom aligned so when you hit return, the next line is above the first line. So, simply rotating it back doesn't
Even my properties box align buttons are rotated: I should add that the little rotation button you see for "orientation" is not the fix- it rotates individual letters.I can't find anything in the menus, toolbars or preferences to change this...
this math isn't working well. I'm using it for a rotated drag and drop (of a tone arm on a vinyl, a kind of abstract turntable simulation). Right now it just moves a bit in the middle of the vinyl (values between 21 and 36, is this degree or what unit is this?), but it should move between the two edges. The problem is that I don't know enough about trigonometry functions. Therefore I can't optimize the math for envisaged behaviour. Does anybody have an idea/tip how I can get a bit more control on the math and its effect? (maybe with more trace functions)
I am currently making a game based on slicing other objects, basiclly when you hold down and drag your mouse and then release it an object that shows the cut will be created.
I have made an application where you can design your own greeting cards. I use matrices to scale and rotate images, and I always need to know what scale the image has.
It works when the image isn't rotated, by taking the value from matrix.a or .d which are the scaleX and scaleY values. But when I rotate the image, using the matrix.rotate() function, the a and d values no longer corresponds to the scale of the image.
How can I get/calculate the scale value of an object that is rotated? And I don't want to scale the image by using the scaleX and scaleY methods.
I need to rotate the imageClip,then zoom in,then i need to scroll the imageClip fully.ve the tutorial for thisboth horizontal and vertical scroll for Rotated imageClip..
Suppose I have a Sprite (A) that is constanly being rotated (as often as the mouse moves).
I have another Sprite (B) that is a child of (A). It makes sense that B is a Child of A because I want B's position to be relative to A's position, and I want B to become invisible when A goes invisible, etc.
However, I would like B NOT to rotate when A rotates. Is there a way to omit B from rotating when A rotates, even though B is A's child?
I know I could do something like B.rotation = - A.rotation everytime A gets rotated, but that feels like a clunky hack to me... there must be a better way?
Currently I'm considering making B a separate object, and not a child of A. But thats not much better because then I have to keep B updated with A's position and visibility, etc...
Is there not an event that occurs only when there has been some sort of visual change to an object. So for example if it were a video or animated object it would be firing as often as EnterFrame. However, if it were some sort of input control just sitting there doing nothing visually, then the event wouldn't fire until the visual state changed as a result of some sort of user input for example.
Can I use Tofino (Visual Studio plugin for Flex development) to build IOS apps? Also do I need to download the Flex 4.5 SDK if I already have Flash Builder 4.5?
In my attempt to create a simple Pong-like game, I've encountered a very strange and at times severe visual bug.When I set the ball (A Flash CS 5.5 library MovieClip) in motion moving around the screen at a rather fast speed, I've noticed that sometimes the edges of the ball would be cut-off for a short moment in the direction it is moving.
When it happens, it almost seems like the position of the ball MovieClip is slightly ahead of its own border and thus the part that is outside the border fails to get drawn.
Here's a picture that illustrates how this looks - at least for me:
You can also view the .swf file online here: [URL]
Some technical data:
I've been unsuccessful in capturing the with a screenshot no matter how much I tried. Sometimes I would open the .swf and the bug would be almost non-existent while at other times it was very blatant. I'm using an EnterFrame event function to increment / decrement the x and y position of the MovieClip. I have never encountered any such problem in any Flash app, in this machine or others. Truncating / rounding the x and y values of the MovieClip didn't help. Neither did setting cacheAsBitmap to true.
Can I build up visual communication just based on two flash client points? I mean a live video connection from a client side to another client side, without FMS.
it's been a long time since I opened VB and I just needed to make a real simple program.Someone enters their income, then based on their salary, their taxes are displayed.One input TextBox, one ouput TextBox, and a button to calculate.I'm almost there, I'm just missing something, I have a TextBox for income:
txt_income
I have a TextBox for income + taxes:
txt_taxtotal
And a Calculate button:
btn_calculate
Here is the code: (I didn't want to use a class like you did)[code].....
i know how to program in vb.net, and have little problems switching to action script. the only problem im having is that i dont know where to type my code. in visual basic there were events that you would type into. does any one who knows Vb know what im talking about? i get the whole convert to symbol stuff just not where im supposed to type
creating a button within a movie clip that will pause both the images (bmps) on the screen and the sound, which is being loaded by AS3.Here's the code for my sound.
Code: //This assigns an abreviated name to the StorySongBook class which is inside the StorySongBook.mp3 properties. var sbs:StorybookSong = new StorybookSong();[code].....
How do I assign this to a button on the stage though (event listener?) and get the button to stop both audio and visual?
I am using Senocular transform tool and I have an object on the stage which I can rotate freely using the mouse. What I want to do is "capture" the total degrees I am rotating the object and write in a a text box. For example, if I will rotate the object clockwise 3 times, the text box will show 1080 (360 * 3), if I will rotate the object counter clockwise 1.5 times the text box will show -540 (360 * -1.5).
Say I've got a box that is 218 by 86. If I rotate it to 50 degrees then the width and height are reported as 206 by 222.3. I'm trying to take those rotated values back to the original values and I'm having a bad math day and can't figure it out.