AS3: restoring timeline animation after code alteration - actionscript-3

I have a movie clip that I animate in my timeline.
At a certain point of my code I need to move that mc by actionscript and at another point I need it to do the timeline animation.
Now, I know that if I alter my movieclip through AS the timeline animations will be ignored further on, but I was wondering: is there a way to force the movieclip to follow the timeline tweenings back again?

No. Once you change a property, it is detached from the timeline.
One solution is having another movieclip inside that movieclip. That way, the timeline animates the main movieclip, but you can access the inner movieclip with a reference to it and do whatever additional transformations you want to it. How you do this will depend on what exactly you're doing, and you have to remember the transformations will "stack", but it works.

Related

MovieClip sticks to all frames

I have a MovieClip with 5 frames. On it are some other movieclips, quite a few of them. On every frame of the first MovieClip they are positoned differently and when I change the frame they change location. Everything works great until I change something within the actionscript.
If I try to color the child MovieClip or do anything with it and then change the frame, the MC stays on the same spot, it does not change location like it should (and does if I dont change it).
Why is this happening? Can I do something to fix it?
Thank you :)
Try changing the position of the movieclips dynamically, using actionscript on each frame, instead of directly on the stage.
[movieclip].x = [Number];
[movieclip].y = [Number];
I'm pretty sure objects that have been referenced in actionscript tend to ignore the IDE positioning in later frames, so you need to dynamically move them. I've seen it happen to me heaps of times.

Flash AS3 play movieclip from main timeline on certain frame

I can't seem to find the right script to let my movieclip play when a certain frame reaches on the main timeline. Searched a dozen websites, I'm not quite the coder but hope you guys can tell me the best way.
Thanks!
There are some different solutions for this, the most appropriate would be to not code at all on the timeline. But if you are using the timeline, then write on that specific frame:
myMC.gotoAndPlay(frameNumber);
Where myMC is the INSTANCE NAMEof the movieclip object placed on the stage (you can change it in the properties panel) and frameNumber is the number of the frame where you want to play the movieclip from.

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

AS3 mouseClick ignore a movieclip

Is there a way in AS3 to make a the mouse ignore a certain movieclip? I need it to be on top of the other movieclips (due to transparancy effects), but have it in a way that allows clicking on the movieclips underneath it. I know about ".mouseChildren = false", but that only makes all the stuff inside that movieclip unclickable, but it still functions as a "barrier" on top of all the others buttons.
Is there a way to do this, or do I need to remove it completely ?
You need to set both .mouseChildren and .mouseEnabled to false before you can click on objects behind the MovieClip. This makes the mouse ignore the objects within the MovieClip and the MovieClip itself.
Source: http://pixelfumes.blogspot.com/2008/01/clicking-through-movieclips-to.html
EDIT: Oops, didn't see that comment by Alex, sorry.

erasing a movieclip

I have a fully working flash application, made in as3. Now i dynamicly added a movieclip and i would like to be able to erase that movieclip with a eraser of some sort, my goal is to be able pick up a sponge with the mouse and then start dragging over the movieclip and erasing the parts where i dragged over it.
Anyone who can help?
Looks like this might be what you're looking for:
http://www.piterwilson.com/personal/2008/05/07/bitmapdata-erasing-in-as3-with-custom-brush-shape/
Is the background behind the MovieClip always the same?
If so you can put an image of the background over the MovieClip you want to erase, and mask that image so it becomes invisible, then add a click listener that draws a circle in the mask when clicked. This way it'll look like the MovieClip is being erased.
With getPixel you can loop over the mask and detect the percentage of the MovieClip that has been erased, so you can remove the clip from stage when it's fully erased.