ActionScript 3.0 动态动画中的变量作为值

发布于 2024-12-11 03:27:08 字数 895 浏览 0 评论 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖风昔人 2024-12-18 03:27:08
var baseTween:Tween = new Tween(base, "x", null, 0, xAxis, 1, true);

Tween 属性应该是一个字符串。

var baseTween:Tween = new Tween(base, "x", null, 0, xAxis, 1, true);

Tween property should be a string.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文