Setting movieclip origin with AS3 - actionscript-3

I have a spotlight that moves on a stage.
Now I rotate the spotlight but its not rotating on the correct point/origin.
I am trying to do something like
myOject.setOrigin = {x , y};
//and then rotate it about x,y.
I have manually set the white circle in the correct place and when I rotate the
object with the mouse on the screen it works.
Can somebody help me?

Make sure the registration point is in the middle of your symbol. It's not the white circle that appears when you use the Free Transform Tool:
But the crosshair that appears when you edit your movie clip:
You can easily center the object by selecting everything, then opening the Align panel and aligning its horizontal and vertical axes to the center using the two "center" icons under the Align section. If your MC has multiple items per layer, group each layer before aligning, then ungroup after aligning:

The white circle is not what will be used as the origin, it's the little cross. Adjust your clip to have that in the center (you'll have to move all of it's contents). Another option, if moving is not possible, is to wrap your clip in another clip and move it within that.

Select symbol and click CTRL+E - Then move it to positioning cross.

Related

Cocos Creator Collider do not collide?

I have 2 colliders: arrow and wheel (1 and 2).
wheel2 has a collider box which is a small square in the middle left (see image):
I rotate wheel2 and it collides with the arrow (https://i.imgur.com/kyYMzrE.mp4). Look good.
Now, I want the wheel to have many small colliders inside, so I replace wheel2 with wheel1 containing the children which are box colliders:
However, when I rotate wheel1, its child doesn't collide with the arrow: https://i.imgur.com/4ttU16U.mp4
What should I do?

AS3 spin text around center?

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.

AS3 move image as the mouse moves

This probably will be very easy for some, but I am stuck on this. I have a map in a movieclip(mc_map) on stage and a small square which acts as a mask to the really bigger size of the same map. What I am want to do is that when I move the mouse on the mc_map(eg: say my cursor is on New York), the small sqaure window will unhide the same area, or will move that bigger image such that the same area is shown under the square mask. I also want to add another cursor(or crosshair) to the stage which is live only in the area of the square and replicates the position of mouse on map. Any help on this will be great thanks.
There are a lot of tutorials on this type of "magnify" effect. See if this one helps: http://www.flashuser.net/flash-actionscript-as3/create-a-magnifying-glass-in-actionscript-3-0.html

Swing rotate border

I'm working on a swing program to display several pictures. And one can rotate the picture (implemented each as a JComponent).
Problem is, when a picture gets rotated, the border of the JComponent doesn't change so that the picture gets clipped.
Is there any way to also rotate the border so that the picture can be fully drawn?
(I know one can calculate the new size of the border, but it leaves empty space on the edge. When a rotated picture overlaps with another and one want to move the one underneath, one cannot do that because the event will be passed to the picture above, onto the transparent edge. So it is more ideal if one can just rotate the border).
Execute another pack() on your top-level JFrame after rotating.

Align the coordinate labels of the triangles, so that they never collide with each other. Actionscript 3

Im trying to achieve something similar to the flash movie in the below link.
http://mathopenref.com/coordtrianglearea.html
As we drag the points of the triangle, the coordinates labels, ( A(1,2)) are properly aligned and arrange themselves so that they never collide with each other and never falls inside the triangle.
Please guide me..
Thanks in advance.
in the example you gave, the textfield seems to be aligned outside the triangle on the angle bisection of the corresponding corner.
for the position in one corner, take the two vectors to the other corners. normalize them and then add them and normalize the resulting vector again. this gives you the vector v of the angle bisection in that corner. multiply the vector with a negative constant and add it to the corner, and you'll obtain a position p outside the triangle. finally, if the angle of v is between pi/2 and -pi/2 (pointing right) align the right border of the label to p, and the left border otherwise.
for simple vector calculations, please see flash.geom.Point.