AS3 spin text around center? - actionscript-3

I am trying to get an effect like this:
http://www.welcomeanimations.com/welcome_animated_gifs_rotating_sign_orange_chrome_k_1.htm
I have tried all sorts of things:
Matrix translation/rotation - spins the text around the 'Z' axis, instead of 'Y'
Adding TextField to a sprite, and Sprite.rotationY++: reg. point is upper left corner
Adding to MovieClip - same as above (an article said MovieClip's reg. point was centered).
This should be trivial?!?! Help me stackoverflow, you're my only hope!

So you have to remember, Display objects scale and rotate around their local coordinate system. so when you put a textfield in a sprite, you need to center it in that sprite's coordinate system. And doing that for textfields is annoying because their width/height isn't always accurate but there is trick for that: get visual bounds, but normally you can take half of somethings width and height
I've created a prototype for you on wonderfl so you can see the solution working in action. Click on the blue square to see how the local coordinate system messes with the rotation
Finally as you use thing you might find things not rotating in 3D space quite right, this should be able to fix that.

Related

AS3: 3D axes rotation

I've built a 3D icosahedron in AS3 that I'm going to use as a 20-sided die. With rotationX, rotationY, and rotationZ all set to 0, it looks like the top left picture. Now I'm trying to find the proper rotations for each number so that the face is perpendicular to the screen, like in the top right picture for #1. The problem is that when I rotate it one way, the axes of rotation are changed as well. For example, in the bottom left picture when I was trying to do #2, I set rotationZ to 108, but now rotationX will not turn it straight downwards as it did before.
I could just eyeball it and get approximate rotations that looked about right, but I would rather have exact rotations. Any ideas?
Nevermind, I needed to use Matrix3D instead for my rotations.

Trying to determine the apparent bounding box of a rotated object using ActionScript 3

Say I have a MovieClip of a non-rectangular shape. For an example I've attached a file called Symbol1.png. In this attached file, I've rotated the symbol instance. Of course, this causes the bounding box to rotate as well.
Now say I place that rotated symbol instance inside another symbol. I've illustrated this in the attached file called Symbol2.png. Note that the bounding box now includes the overhanging corners of the rotated symbol that is inside.
Is there any practical way to determine the apparent bounding box of Symbol2 without including the corners of Symbol1's bounding box? I'm trying to zoom and rotate to an automatically calculated size and angle, but this overhang problem is causing a lot of extra space to be included in my final zoomed perspective.
Thanks.
Every container's bounding region is defined by the space that its children occupy. What you're looking for isn't the "bounding box" per-say (as Flash is accurately representing this), but rather the visible space the children occupy (which is much harder to quantify).
Thankfully, you're not the first to ask this, and (technically) this is a duplicate of Calculate Bounding box coordinates from a rotated rectangle

Repeat background with clip?

I have this background that I'm using for a section, and it starts with a small arrow engraving at the top:
However I'm trying to get it when it repeats to clip out the top arrow part, just leaving the texture in the middle part. I was wondering if it was possible to do it with something like webkit? Thanks
You can't. You need to come up with another method of doing so. There are a number of ways to do this. Personally, I would use only the arrow, but use inner box-shadow for the shadows on everything else. This way you have smaller image being used, and it will always fit the size of the container.
Break up the background image from the pointer and make the two separate sprites. You can get tricky with the pointer and have it point in all 4 directions in the same image. This will allow you to pop up the bubble in all directions from the source.
You can't repeat both x and y on a usable sprite.
I have a maximum of three sprites in my projects.
One for non-repeating elements, another for repeat-x, another for repeat-y.
I find the clip property pretty much useless.

scaling and positioning with tweenlite

I have a movieclip with the mesurements of a rectangle. When the application is launched the movieclip is being scaled before placed on the stage as following.
menu.width = 400;
menu.scaleY = menu.scaleX;
this is a smaller size than the original.
the position of the movieclip at this moment is in the middle on the x and top of the stage on the y.
when i click iti would like to do a tween with tweenlite wich scales it to its original(bigger) width and height and position it in the center of the stage on x and y.
the problem is when i position it with tweenlite, it gets done according to its old scale and not according to its new(bigger) scale so the movieclip isnt placed in the exact center of the stage.
Anyone know how i can resolve this?
I tried to compensate by adding a bigger number on the position so it gets positioned in the right way.
But when i click it again i would like it to rescale to its beginning scale and position so it would be very messy to compensate again. Is there any easier way to do this kind of tween?
I doubt that i'm being clear to what i want but i hope i am after all.
The easy and way of tween position and scale is probably to add the menu to a container.
You would then on one hand tween the position of the container, and on the other apply the scale to the menu it self without having to recalculate the proportional position if the scale changes.
This way you can even control the registration point of the menu within the container. e.g. to always scale from the middle...
This can be done with a matrix as well if you want to avoid to stack objects, but honestly it can get really tricky whereas the container method is bullet-proof.

Falling object in Box2D should rotate due to centre of mass?

I'm trying to simulate a falling balloon in Box2DAS3. What is important is that balloon falls the such that the bottom part were you blow it up rotates towards the bottom if it's knock sideways or is dropped at an angle.
alt text http://lh4.ggpht.com/_gjsCWAV_CZc/Sw7zqHahTJI/AAAAAAAAC3s/YIJka4AsM5s/s144/Untitled.jpg
I've tried offsetting the center of mass of the body and also joining two bodies together with the denser one representing the tie. In both cases the body falls at the same angle without rotating.
An object in free fall (vacuum), without any initial linear or angular velocity, will never start to spin by itself, no matter where its center of gravity lies. You need to simulate fluid drag and buoyancy. A simple way to this is to add a small force on the top of the balloon that points upwards.
Add a drag force to all objects. Something like -velocity / drag_amount