ActionScript 3.0 动态动画中的变量作为值
我正在使用 AS3.0 和 我正在尝试创建一个函数,该函数将生成 1-550 之间的随机值(Flash 阶段的默认宽度),将动画影片剪辑对象沿 x 轴移动到该点,然后制作另一个影片剪辑对象从该点掉落,现在这就是我到目前为止所得到的(请注意,右侧的数字只是在那里对线进行编号!)(“base”是沿 X 轴移动的实例,并且“球”是从中掉落的实例 观点)。
function dropBall() {
var randomNum:Number = Math.random() * 550;//The variable "random" equals a random value between 1 to 550
var xAxis:int = Math.round(randomNum); // the variable "xAxis" equals the value of "random", just rounded.
var baseTween:Tween = new Tween(base, x, null, 0, xAxis, 1, true);//Thats the problematic line!!! the value "xAxis" is
//not valid.
ball.x = xAxis; //Makes the ball appear at the random point. here the variable "xAxis" works just fine as a value.
var ballTween:Tween = new Tween(ball, "y", null, 0, 500, 1.2, true); // animates the drop of the ball along the Y axis.
}
任何人都知道为什么“xAxis”变量不能作为第 4 行新 Tween() 方法的值??? 感谢您的任何帮助:D
I'm using AS3.0 and
I'm trying to make a function that will generate a random value between 1-550 (the default width of a flash stage), will animate a movie clip object to move to that point along the x axis, and then make another movie clip object drop from that very point, now thats as far as I got so far (notice the numbers on the right hand side are just there to number the line!!) ("base" is the instance that moves along the X axis, and "ball" is the instance that drops from that point).
function dropBall() {
var randomNum:Number = Math.random() * 550;//The variable "random" equals a random value between 1 to 550
var xAxis:int = Math.round(randomNum); // the variable "xAxis" equals the value of "random", just rounded.
var baseTween:Tween = new Tween(base, x, null, 0, xAxis, 1, true);//Thats the problematic line!!! the value "xAxis" is
//not valid.
ball.x = xAxis; //Makes the ball appear at the random point. here the variable "xAxis" works just fine as a value.
var ballTween:Tween = new Tween(ball, "y", null, 0, 500, 1.2, true); // animates the drop of the ball along the Y axis.
}
Anybody knows why doesn't the "xAxis" variable works as a value for the new Tween() method on line 4???
Thanks for ANY help :D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Tween 属性应该是一个字符串。
Tween property should be a string.