Actionscript:在第二帧中从动作面板调用函数

时间:2014-12-04 21:58:50

标签: actionscript-3 flash

我开始学习Adobe Flash。我使用的是Flash CS6。

我有一个名为test.fla的文件,另一个名为bikertest.as

Bikertest有这段代码:

package as3.grey{
    import com.grey.utils.Console;
    //import com.grey.utils.ClickTag;
    import flash.display.MovieClip;
    import com.greensock.TweenNano;
    import com.greensock.easing.*;
    import flash.events.*;

public class bikertest extends MovieClip {

private var mc:MC;
        private var console:Console;

public function ray():void{
    init();
    trace("hi from here");
    mc=new MC  ;
    addChild(mc);
}

....................

我试过了:

import as3.grey.bikertest.as;

var t = new bikertest();

t.ray();

我希望能够在ray()的第二帧中的操作面板中调用test.fla。我希望这很清楚。我怎样才能做到这一点? /谢谢!

1 个答案:

答案 0 :(得分:1)

既然你没有描述实际问题是什么(是抛出编译器还是运行时错误?它只是没有跟踪“hi from here”等),我只能评论明显的代码错误:

更改此内容:import as3.grey.bikertest.as; 对此:

import as3.grey.bikertest;  //(loose the `.as`)

并改变这一点:mc=new MC ; 对此:

mc = new MC(); //(use brackets when instantiating - though the FlashPro compiler should allow it without)

并改变这一点:var t = new bikertest(); 对此:

var t:bikertest = new bikertest();  //so the compiler knows what kind of object t is

如果这不能解决您的问题,请更新您的问题以更具体地说明哪些内容无效。

另外,请确保您的bikertest.as文件是正确的文件夹:project root (where the .fla is) -> as3 -> grey