如何获得使用任何影片剪辑的功能?

时间:2015-06-10 13:48:34

标签: function actionscript-3 flash-cs6

我在理解这种功能方面有点迷失,我觉得这已被问过一千次,但无法找到代码正在做什么的解释。

基本上我只想要一个带有实例名称框的影片剪辑来做某事,然后再将该函数用于其他影片剪辑

有点像这样,但正在努力。

非常感谢

//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
    }
}

抱歉,这不是英语,我的沟通技巧很糟糕

1 个答案:

答案 0 :(得分:0)

当然可以这样做。您为函数提供参数,然后引用参数以更改其属性。通过这样一个简单的移动函数,它可以接受DisplayObject - MovieClip的远程超类,因此是Flash可以显示的那些对象的许多其他可能类的超类。

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
    }
}

您可能希望查看有关ActionScript 3语法的this manual以及有关变量,函数和类的以下页面,以了解更多信息。

相关问题