Removing Object/Movie Clip in AS3 - actionscript-3

Hi I'm fairly new at Actionscript 3. This will just be a quick question.
How can I remove a Movie Clip from the stage if I, for example, click on it? I didn't use addChild() or Sprites. I manually put it on the stage.
*Sorry if my explanation is bad or vague

if you want to remove the "Sprites" aka Movieclips over code, you have to implement, the addChild() functionality in your code. After that, you can remove that with stage.removeChild(Moveclipname). Thats all.

Related

How to add symbols in layers?

I am looking to know how to add an object inside a Layer, as you can see here :
I can't find a way to actually add my Movieclip inside the layer from the code side.
Short answer, no. Long answer, I don't think you can, layers are more like grouped display order. I've been using Flash for years and have never met this need or issue. You add the mc from the code at runtime, a moment where you don't really care which layer it goes into.
However, if your question is actually, how to add a mc at a specific index, then you can either addChildAt( mc, theIndexYouWant) or, simulate the layers by creating movieclips and inserting what you need inside of it.
In this case, you would have, on the stage, in a single layer, the movieclips: floor, toto, layer2 and layer3. You would then add, using the code, the mc you want in the toto movieclip.
If something is unclear, ask away :)

AS3 for moving a movieclip along a path

I am looking for a simple AS3 script to move/follow a movieclip (arrrow) along a manually drawn path in flash. Like.. it moves for the start point if the line to the end point of the line, also should rotate at curves automatically.
Also is it possible to duplicate this movieclip (arrrow) tho specific distance, like a ground of arrows moving along a path continuously with specific distance from eachother?
I am working on few infoGraphs and need this arrows animation to show the workflow.
I desperately needs this, pls help!
Cheers,
bp
There could be libraries that help with this, as George Profenza mentions in his comment, and it is certainly possible to calculate points along a bezier.
However, a much simpler solution is to do what people have done since Flash 4. Draw the curve in Flash, then create a motion tween along the curve using an empty MovieClip. At runtime, you can use addChild() to insert your MovieClip as a child of the empty one. You will have a lot more manual control this way, compared to the bezier library.

hitTestObject() collide somehow not working how it should

Or that's what I think, at least.
I just began with AS3 and I'm trying to do a little game where one ball moves on its own and the other one is handled by the player. So far, so good. That works.
What isn't working is hitTestObject(); it just returns true when it's like 2 cm from the other object. Here's a picture so you can see: http://dl.dropbox.com/u/37057843/coll2.jpg
I've read that hitTestObject just creats a rectangle around the objects and then tests for collisions on those rectangles, is it because of that?
If you need any piece of code I'll deliver. I know there are some other opensource libraries/engines like Box2D to solve this in a better way, but I don't want to jump to engines directly.
Thanks for reading!
Yes, hitTestObject will use the clips bounding box.
Check out this link, it has a lot of great information as well as a class that will do what you're looking for
http://sierakowski.eu/list-of-tips/39-collision-detection-methods-hittest-and-hittestobject-alternatives.html
Direct link to the package
http://code.google.com/p/collisiondetectionkit/

How do i know if keyframe is blank or not with actionscript 3

How do i know if keyframe is blank or not with actionscript 3
Thanks for help.
If you mean a frame in a layer in Flash IDE, the one with white circle, the answer is you can't. Layers in AS3 are not saved. They are merely converted to depth order.
What you can find out is if this particular frame doesn't contain any children (when all layers are combined) as it was already mentioned using numChildren property. If you have any shapes, bitmaps or movieclips on stage they all will be listed as children.
But you also might have something drawn in your sprite's graphics object which makes it non-empty in some way. If you want to check that you have to draw it in a BitmapData and examine its content.
As far as I know there is no real concept of keyframes in AS3, so I think that would be hard. You might be able to play to the frame you want to check, and see if getChildAt(0) throws a RangeError - but that is hackish at best, and probably won't work for content that isn't movieclips.
You can use numChildren getter on target clip to know how many clips is inside at moment .
EDIT:
You can also try use getBounds or getRect functions and when Rectangle width and height are equal 0 , thats mean clip is empty.

Script a button to its rollover state?

Anyone know if it is possible via AS3 to change a button to its rollover state when it is not, in reality, rolled over?
Client decided way late in process to ask for some other elements to affect button states. If I had known I would have used movie clips instead of buttons.
Thanks for any advice.
Have you tried manually calling gotoAndStop(2) ?
If none of the above solutions work, you'll either have to subclass SimpleButton and link it to your symbols or rebuild in MovieClips
Dispatch the rollover event manually? Apart from that, I don't see any other way. I am curious though, what sort of requirement(s) would mandate such an oddity.
You can open the properties of any library display object and change it to a button, graphic, or movieclip type. this should allow you to then change the instance type to button and retain rollover abilities while allowing "gotoAndStop" actions on the instance. I'm not totally sure this works, and this thread is old, but if anyone has this same issue it would be worth a shot. This is assuming you aren't creating SimpleButtons dynamically.