How to go to prev/nextFrame only when all targets are dragged? - actionscript-3

My question is how to go to go to previous/next frame after 'monkey' and 'dog' are both dragged out of the scrollpane.
The file is placed below:
https://www.sugarsync.com/pf/D9726155_61875891_24948
Thanks for any advise.

2 ways I can think of
1- check x and y position of monkey if they are lower or higher than the x and y of scrollpane then go to next frame
2- set and invisible collision area and check if they collide.
I would help more with the code but i didn't find the objects to drag ^_^

Related

How to set a max/limit on how much a movieclip can be moved by x and y?

I'm making a Create-a-Character.One of the features is being able to adjust a facial feature’s placement.E.g. can move the nose up or down
(Through arrow buttons, example: 1 click on up button, move nose up by a little bit.)
But obviously I don't want the eyes or nose or lips floating outside the face or a nose ending up on a forehead that would be strange lol.
So how do I code so that the user can only move a movieclip a set amount of times in the chosen direction?
If you use just arrow buttons to move objects, it is very easy. Once a button is clicked, check object's position and move it if needed. Basic example:
// if arrow up clicked
if (nose.y > 100)
{nose.y -= 2}
// if down arrow clicked
if (nose.y < 140)
{nose.y += 2}
It's same for x axis and obviously, numbers 100 and 140 can be anything you want. It means, move objects just between these points.
User 987 answer is correct, however if your button moves the object at a faster pace say +-5, setting +-2 to the offset might not put it back in the boundary. It will correct itself by +-2 every frame there after, not accounting for if the user continues to hold down the button to try and exceed the boundary further. The nose will continue to glide further away.
The better way to implement this is to immediately set the nose back to the edge of the boundary.
if (nose.y > 140) {
nose.y = 140;
}

AS3 - Finding an objects x and y position relative to the stage

I'm new to ActionScript 3 and I have a character which you can control, the screen scrolls right along the stage and he can fire missiles.
The problem I'm getting is the missiles are created via these co-ords:
bullet.x = hero.mc.x;
bullet.y = hero.mc.y
These work fine untill the screen has scrolled to the right. I assume it's because the bullets are being spawned as a result of them using the canvas x,y and not the stages x,y
So i'm wondering how to find out the x and y of my hero in relative to the canvas so i can spawn the missiles on top of him!
Thanks, and if you need any more information let me know, I'm new to all this. Thank you.
You can do that with localToGlobal and globalToLocal. Your solution would be something like:
bulletPos = bullet.parent.localToGlobal(new Point(bullet.x, bullet.y));
Beware, though, as those are last resort functions. Normally, you'd have all your elements using the same 'layer', so comparisons are easier and faster.

How to make list scrolling only with mouse (actionscript 3)

You can see this list here http://www.studia-kuhni.ru/exec.swf.
List.change
List.itemRollOut
List.itemRollOver
List.scroll
What I should use? How I can scroll list as like as on that swf? (i know about tweenmax, question about scrolling)
May be somebody know beautiful and well made examples?
Thank you.
Try using List.scroll listener, and update 'selectedIndex' with respect to the scroll direction. For eg., my_list.selectedIndex += 1 to select the next item.

AS3: How to make movieclip appear on middle of a separate mc container?

I've been searching and having trouble doing this the right way.So my player has 2 arms which are joined in one mc. Now I'm trying to make the body(which is doesn't belong on the container mc) go between them, so it's like R arm first then body then L arm. The 2 arms rotate on mouse direction, i don't want the body too. Any ideas what way I should go?
EDIT:
please see my sample image
The checked thing is the result I'm looking for. But since the 2 arms is combined on one MC, I can't make the body appear on the middle between the 2 arms.
You should change your nesting model like this:
And then store your arms in an Array or a Vector, and change every arm's rotation separately.
It's the only way

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 ! :-)