ActionScript 3.0 get BoundingBox of MovieClip - actionscript-3

How do I get the BoundingBox of a MovieClip? if the contents of the movieclip have they're lowest coordinate at the movieclips origin then it's easy (just take width and height of the movieclip and add them to the coordinates of the mc). but how to do it for an arbitrary movieclip?

See the ActionScript reference for getBounds() or getRect().

Related

Looping a Movieclip in Flash AS3

I have a simple question but can't seem to find a simple response. I have created a movieclip inside a movieclip that contains several movieclip symbols with motion tweens. I currently have a stop() command layer located at the end of all movieclips (frame 175) but wish to have one specific movieclip loop. What is the easiest way to do this?

ActionScript 3 - Possible to access MovieClips which are an instance of another MovieClip?

I drew an image on the stage and converted it to a movieclip whose name is
originalMovieClip
. The movieclip is now in my library. I dragged the movieclip in my library onto the stage. I did this twice, so now I have two movieclips which are both an instance of
originalMovieClip
which was the original movieclip which I created.
Through actionscript 3, is there a way for me to target all movieclips which are an instance of
originalMovieClip
? I want to basically do
all Movieclips Which Are An Instance Of originalMovieClip.gotoAndStop(2);
In such a basic manner, the short answer is - NO.
Short story long - you need to put them into array and loop through it, and stop every movie clip inside.
Other technique (not appropriate) is to loop through all children of stage, and check if the MovieClip is specific type (again you should at least set linkage class to originalMovieClip).
I suggest using the first one :)

How to manipulate a movieclip inside another movieclip independently

So, I am trying to make a flash game with a bomber plane with a rear-gunner. I have made the plane a movieclip and, inside that, have the gunner movieclip. I am trying to use key controls to move the plane and have the gunner follow the mouse cursor. I am not certain if there is a way to make the gunner movieclip stay attached to the plane and move independently. Right now the only thing that works is instantiating a gunner and adding it to the frame, but I am having problems keeping it in the right location while the plane moves.
you can refer to a movieclip in another movieclip by naming it
Picture example:
http://i.stack.imgur.com/weNeF.png
then you can refer to it in your actionscipt by writingyourPlane_mc.gun Example: yourPlane_mc.gun.rotation = mouseAngleToPlane

How to capture current frame from a MovieClip into a BitmapData object?

The movieclip is in a seperate swf file that has been imported into the library. The movieclip itself plays fine (the movieclip is vector based) but when I try and capture the current frame from it into a bitmapdata object nothing seems to happen. I'm wondering if it's some type of security issue?
mc is the movieclip
bitmap=new BitmapData(mc.width,mc.height,false);
trace("Creating bitmap for frame grab width=",mc.width,"height=",mc.height);
bitmap.floodFill(0,0,0xff0000); //for debugging only
bitmap.draw(mc);
After using the code above to capture the current frame of the movie the texture is solid red so it seems that it is not being changed after the floodfill command I put above for debugging.
Figured it out, the image is being drawn but is off the right of the screen since it seems to be using some sort of centerpoint or offset position to draw the movie. If I allocate the bitmap to be 4x taller and 4x wider then I see the bitmap.

Does setting properties in AS3 prevent timeline tweens?

If I have a movieclip that has a class assigned to it and I change a property of that movieclip in code, it seems that the property can no longer be tweened on the timeline.
For example, if my class sets this.x = 100, and later on the timeline I tween the position of the object, that timeline tween will not occur.
Changing either scaleX or scaleY property also seems to stop timeline tweens from happening.
Has anyone else experienced this, and if so, is there a way around it?
You have it right. Changing certain properties of an MC on the stage will cause Flash to assume that you are going to position it with script, and tweens will no longer work. A couple of workarounds:
Reparent things so that you separate scripted and IDE positioning. That is, if you were tweening an object's X position and also rotating it with script, change it so that you tween the X of a container clip, and rotate an inner clip inside.
Do all your positioning with script - i.e. use the Tween class, or a tween library.
If the playhead goes past a frame where the clip is not on the stage, and then to a frame where it is, this will "reset" the clip to work with IDE positioning and tweens. This is true even if you jump past the empty frame with gotoAndPlay. So for example, if you use script to move the clip on frame 10, and then on frame 20 you do gotoAndPlay(30);, then a tween at frame 30 will work correctly if you put a blank frame somewhere between frames 20 and 30.
I would stick strictly to the as3 code if I were you.
import these at the top of your actionscript
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
and then set your tween like this:
var myTween:Tween = new Tween(object, "property", EasingType, begin, end, duration, useSeconds);