本页面由 Flash 保存计划 从 Internet Archive 存档还原 · 快照 2008-09-04 · 原址 http://www2.flash8.net/teach/7294.htm ← Flash 保存计划

获取舞台上实例属性的方法

作者:taoshaw   类型:整理   来源:淘沙网

  获取舞台上实例名称、实例参数,以及获取类中的方法。AS3老手就别看了,呵呵。新人可以交流一下。

Main.as:

package {
  import flash.display.MovieClip;
  import textClass.textCll;
  import flash.text.TextField;
  public class Main extends MovieClip {
    private var my_text:textCll;
    private var my_text2:textCll;
    public function Main():void {
      my_text2=new textCll();
      my_text2.getBall(150,300,1)
      addChild(my_text2)
      my_text=new textCll;
      my_text.rootText=txt_shuru;
      my_text.txt="欢迎光临淘沙网";
      my_text.ifborder=true;
      my_text.bColor=0xcccccc ;
      my_text.getBall(150,100,2);
      addChild(my_text)
    }
  }
}

textClass/textCll.as:
package textClass{
  import flash.display.MovieClip;
  import flash.text.TextField;
  public class textCll extends MovieClip {
    private var _textname:TextField;
    private var my_ball:ball;
    public function textCll():void {

    }
    //获取舞台上TextField实例名称;
    public function set rootText(_txt:TextField):void {
      _textname=_txt;
    }
    //获取Main.as中text值;
    public function set txt(_txt:String):void {
      _textname.text=_txt;
    }
    //设置边框;
    public function set ifborder(_borNum:Boolean):void {
      _textname.border=_borNum;
    }
    //设置边框颜色
    public function set bColor(_borderColor:uint):void {
      _textname.borderColor=_borderColor;
    }
    public function getBall(_X:uint,_Y:uint,_Z:uint):void {
      my_ball=new ball();
      my_ball.x=_X;
      my_ball.y=_Y;
      my_ball.gotoAndStop(_Z);
      addChild(my_ball);
    }
  }
}
源文件下载:as3getshuxing.rar
   责任编辑:silvia    时间:2008年11月20日
  • 最近更新