Flex:在 MovieClip 的不同帧上绘制
如何使用 ActionScript 在影片剪辑的不同帧上进行绘制。 也就是说,使其成为 movieClip.gotoAndStop(0); 将显示与 movieClip.gotoAndStop(1) 不同的内容;
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在代码中使用 addFrameScript。
例如,假设您有一个与 CustomMovieClip 类关联的影片剪辑。
在 CustomMovieClip 的构造函数中,您可以编写如下内容(未经测试的代码):
class CustomMovieClip
{
...
函数 CustomMovieClip()
{
停止();
// 将drawGraphicsForFrame1代码添加到第0帧
addFrameScript(0, drawGraphicsForFrame1);
// 将drawGraphicsForFrame2代码添加到第1帧中
addFrameScript(1, drawGraphicsForFrame2);
...
}
私有函数drawGraphicsForFrame1():void
{
停止();
var sprite:Sprite = new Sprite();
addChildAt(精灵, 1);
// 在精灵中绘制
sprite.graphics.lineStyle ...
}
private function drawGraphicsForFrame2():void
{
}
...
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
{
}
...