rotate movieclip by pressing and rotating another movieclip - actionscript-3

I have placed two movieclips one parent name "container" and a child inside container named holder. I want container to rotate by pressing/dragging the holder placed at the top right corner with mouse movement. The container should rotate from the center point.

Here on Stack Overflow, we do not work for you and code for you. We just answer productive questions that will help future users.
So what you would do is make a MouseEvent function and add the event to holder by container.holder.addEventListener(MouseEvent.MOUSE_CLICK...) and in the function you would put: addEventListener(Event.ENTER_FRAME...) and in that enter frame event, you would put: event.currentTarget.rotation += NUMBER or container.rotation += NUMBER - Same Thing because the event's current target is container. Replace NUMBER with a number.
Not much is being done here, as you can see:

Related

parent-child depth will change in actionscript

Please have a look at this project, in this project I have two symbol, one of them create and add another symbol as child.
Child symbol is drawn over parent as I expected. Parent symbol has two frames. When parent goes to second frame, child symbol drawn under parent. I mean depth order will change.
Can somebody help me!!?? Sorry for poor language.
Download link:
https://drive.google.com/file/d/0B-KCX3wxRH-cOUk5YU1OUzNFN3M/view?usp=sharing
Yellow shape from the frame 1 move to the new layer.
Hide Layer 3 and go to the second frame.
Select and remove the yellow bitmap image.
Show Layer 3.
Another solution:
Add next code after gotoAndStop(2);
swapChildren(btselect,getChildAt(numChildren - 1));
You misunderstand completely how the Flash rendering works so here's a couple of pointers:
"Child symbol is drawn over parent as I expected", nope, that doesn't happen. A parent has content which can be pictures, other symbols ect ... and they are all inside the parent so no child are drawn over the parent, they have a display hierarchy that's all.
"child symbol drawn under parent." well once again nope, a child is not drawn under it's parent, it is inside the parent and under other objects.
When a MovieClip with multiple frame displays the content of a frame it adds those content to it's display list (inside itself). After that if you add another child in it it will be on top. Then you move to another frame let's say frame 2. Once again the MovieClip adds the content of frame 2 inside itself, but since the child you added in the previous frame is already there all the new content is added on top of it.

setText jolts TextButton at inital position for a microsecond or two while movement is happening

I have an actor and I'm moving it by using moveTo(destinationx, destinationy, time).
The problem is that the actor is a TextButton and I need to change the text while the movement is happening and this poses a serious problem. It seems setText calls invalidate and invalidateHierarchy so when the method is called the position of the TextButton is reset to the initial position for a while so that the movement proceeds with a jolt (jump) of the text button position (position set at initialization - .center()).
All the dynamics of my actor movements are running as planned as long as I don't modify the text while Actions.moveTo is still running. If I do modify it then I see a jolt of the text at the moment I call setText.
How can I solve this pb?
I was able to reproduce your problem by placing a Button in a Table and using moveTo actions on the Button. The problem is that when a widget belongs to a Table, the Table is responsible for controlling the widget's position and size, so actions that affect the position will not work correctly.
If you are moving a widget around the screen to arbitrary positions, it doesn't make sense for you to keep it in a static Table anyway. If you add the Button directly to the stage, the problem goes away.
However, I discovered another problem. If the Button doesn't have a Table parent, it doesn't update its own size correctly when its text changes.
I found a solution. Place the Button in a Container and add the Container to the Stage. Use your MoveToActions on the Container that wraps the Button, not the Button itself.

Getting graphic/movie clip x,y position from within another movieclip?

This should be fairly simple I'd think, I'm just not that familiar with actionscript haha.
I have a game where I have the background moving behind a character that stays in one position on screen. I'm relatively new to actionscript 3 but I'm wanting to have text boxes pop up whenever the player presses a key over certain objects passing in the background.
So, basically the background itself is a movie clip, and I have other graphics and movie clips within the background mc.
I was thinking of getting the player.x and y position and then "comparing" that position (>= and <=, etc.) with the graphic/movie clip in the background. But I just don't know how to obtain the x and y coordinate of the graphics/movie clips in the background mc.
You could try to target your movie clips in the background by getting their coordinates, then removing their parent's position (the background container).
Something like :
var finalXPosition:int = targetMovieClip.x - backgroundContainer.x;
var finalYPosition:int = targetMovieClip.y - backgroundContainer.y;
By substracting the target movieclip parent's position to its position, you gain the final position in the parent's scope coordinates.
It should work for you as soon as your character and your background container are situated at the same level of the display list.
Here is a quick diagram of what I try to explain (please forgive my inaptitude to draw nice and explicit drawings ^^)
Usually, when I stumble upon such a case, I try to make a quick and even dirty drawing, starting with what I want, then breaking down every useful data I have to achieve that result, you should keep that method in mind and try it the next time ! :-)

how to control masked scrollpane by clicking

I have a bit of a problem. I want to create something like this but vertical instead of horizontal.
I also want to control the slider by clicking on up/down buttons instead of scrolling.
Reference: http://active.tutsplus.com/tutorials/effects/create-a-responsive-xml-image-scroller-in-actionscript-3-0/
Now i have a container mc that holds all my thumbs and a mask that masks that container. I also have my buttons that gonna
trigger this scroll up/scroll down function.
I have sort of no idea at all of how to write the function for that. I have made the container tween up and down but i need a limit
for that so it want tween to far and go out of bounds.
Any suggestions?
First, to prevent the mask from moving with the content, make sure it's sitting on the same level as your content.
For example:
myContainer ¬
- contentBox
- maskShape
And contentBox.mask = maskShape.
For the scrolling, it's just a matter of increasing or decreasing the position of your contentBox with every click of your navigation buttons.
In the case of the down button, on your event listener you'd do something like...
contentBox.y = contentBox.y + 25;
Of course we want this to smoothly slide over, so in the case of TweenLite...
TweenLite.to(contentBox, 0.5, {y:contentBox.y + 25});
The "up" button is simply the reverse of this.

Dynamically adding tween to n MC's

Here's what I'm aiming for. I'm querying the Rotten Tomatoes API for Upcoming Movies. For each movie returned, I'm creating an instance of MovieIcon (MC). I'm then adding this MC as a child of a Container MovieClip that's already on the scene. Each time, I'm incrementing the xPosition of each MovieIcon MC such that, they're positioned next to each other.
My container MC has a mask applied to it, therefore any child objects that are positioned beyond the size of the mask, they're are hidden from view.
How can I dynamically add a tween/easing animation between all these MovieIcon MC's so that when I hover over the Container MC, it 'scrolls' left or right, depending on the mouse motion?
Thanks in advance.
First I would recommend using a tweening library.
TweenLite and Tweener are good options
http://www.greensock.com/tweenlite/
http://code.google.com/p/tweener/
Both of these include docs that will help you get everything set up in your project.
Then you should be able to add a ROLL_OVER event to each of your MovieIcon MC's
MovieIcon.addEventListener(MouseEvent.ROLL_OVER, handleRollOver);
Inside your handler you can use the event.target property to get a handle on the over MovieIcon.
Assuming your using TweenLite you can go and add your tween to that target
private function handleRollOver(e:MouseEvent):void{
TweenLite.to(e.target, duration, {x: new x value, any other prop: any other val})
}