我有点迷失在理解这类函数中,我觉得这已经被问了上千次了,但是找不到代码要做什么的解释。
基本上,我只想要一个带有实例名称框的电影剪辑来做一些事情,然后再将该功能重用到其他电影剪辑中。
有点像这样,但很有用。
非常感谢
//my function to be used on "instance name" box
myfunc (box);
function myfunc ();
{
while (this is happening);
{
//in this case box.x = goes where ever i put it
.x = goes here
.y = goes here
}
}
对不起,这不是完全英语,我的沟通能力很差
发布于 2015-06-10 15:36:43
你当然能做到。您可以为函数提供一个参数,然后引用一个参数来更改其属性。有了这样一个简单的运动函数,它就可以接受一个DisplayObject
-- MovieClip
的一个遥远的超类,从而成为许多其他可以由MovieClip
显示的对象类的超类。
function myfunc(param:DisplayObject):void {
// no semicolon after declaring the function!
while (somethingIsHappening(param)) {
// why not call a query on that object?
param.x+=1; // move right by 1 pixel
}
}
您可能需要查看本手册 on ActionScript 3语法,以及下面有关变量、函数和类的页面,以了解更多内容。
https://stackoverflow.com/questions/30758274
复制相似问题