开发者

actionscript3 calling functions in Main from a another class

开发者 https://www.devze.com 2023-02-11 11:49 出处:网络
Even I am programmer I am very, very, new to as3. Problem: I have define a classA in aA.sp file. package{

Even I am programmer I am very, very, new to as3. Problem: I have define a classA in aA.sp file.

package{

     import flash.display.Sprite
     .......
     public class aA extends Sprite{
        function aA{ ....   }      //constructor

        functio playVideo(url){.....}
   }

I have defined Main in the document class in the cs4 .flv file The Main class is defined in the Main.as file. package{ import flash.display.Sprite; ....

  public class Main extends Sprite{
    public function Main(){
         var v:Sprite = new aA();
        v.playVideo("clip.flv");
        addChild(v);
    }
}

}

When test on cs4 (contol>enter) I get following error

1061: Call to a possibly undefined method playVideo through a reference with static type flash开发者_运维技巧.display:Sprite

Please help me. I am stuck! ( may be its a simple error ) Thanks in advance.


Make sure that your Main class is in the same package as the aA class (or otherwise use import to import that package). Set the type for your v to aA ( var v:aA = new aA(); ) .


Make playVideo public or make sure aA is in the same package as Main.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号