How can I used ActionScript to draw on different frames of a movie clip. That is, make it so that movieClip.gotoAndStop(0); will show something different to movieClip.gotoAndStop(1);
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use addFrameScript in your code.
For example, let’s say you have a movieclip associated with the class CustomMovieClip.
In your CustomMovieClip’s constructor, you can write something like the following (untested code):
class CustomMovieClip
{
…
function CustomMovieClip()
{
stop();
// add drawGraphicsForFrame1 code into frame 0
addFrameScript(0, drawGraphicsForFrame1);
// add drawGraphicsForFrame2 code into frame 1
addFrameScript(1, drawGraphicsForFrame2);
…
}
private function drawGraphicsForFrame1():void
{
stop();
var sprite:Sprite = new Sprite();
addChildAt(sprite, 1);
// draw in sprite
sprite.graphics.lineStyle …
}
private function drawGraphicsForFrame2():void
{
}
…