热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

AS3中的设置属性是否会阻止时间轴补间?-DoessettingpropertiesinAS3preventtimelinetweens?

IfIhaveamovieclipthathasaclassassignedtoitandIchangeapropertyofthatmovieclipinc

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.

例如,如果我的类设置this.x = 100,稍后在时间轴上设置对象的位置,则不会发生该时间轴补间。

Changing either scaleX or scaleY property also seems to stop timeline tweens from happening.

更改scaleX或scaleY属性似乎也会阻止时间轴补间发生。

Has anyone else experienced this, and if so, is there a way around it?

有没有其他人经历过这个,如果有的话,有没有办法解决它?

2 个解决方案

#1


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:

你没事。更改舞台上MC的某些属性将导致Flash假定您将使用脚本定位它,并且补间将不再起作用。几个解决方法:

  1. 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.
  2. 重复的事情让你分开脚本和IDE定位。也就是说,如果您正在补间对象的X位置并使用脚本旋转它,请更改它以便补间容器剪辑的X,并旋转内部剪辑。

  3. Do all your positioning with script - i.e. use the Tween class, or a tween library.
  4. 使用脚本完成所有定位 - 即使用Tween类或补间库。

  5. 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.
  6. 如果播放头经过一个剪辑不在舞台上的帧,然后到达它所在的帧,则会“重置”剪辑以使用IDE定位和补间。即使您使用gotoAndPlay跳过空框架也是如此。因此,例如,如果您使用脚本在第10帧上移动剪辑,然后在第20帧上执行gotoAndPlay(30);,那么如果您在第20帧和第30帧之间放置一个空白帧,则第30帧处的补间将正常工作。

#2


I would stick strictly to the as3 code if I were you.

如果我是你,我会严格遵守as3代码。

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);

推荐阅读
author-avatar
zjy135781012
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有