flash加载输入文字

作者:袖梨 2022-07-02

思路:as2中载入图片可以用 MovieClipLoader类,as3中载入图片可以用Loader类;边框的实现可以用Drawing API来实现如lineStyle,lineTo等等...

先看As2的做法:(老外的代码)

//创建一个空剪辑,以便载入图片1111.jpg,1111.jpg是跟源文件同一目录下的。
this.createEmptyMovieClip("image_mc", 1);
//创建一个监听器监听MovieClipLoader类的onLoadInit事件
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
 //空剪辑位置舞台居中
 target_mc._x = Stage.width/2-target_mc._width/2;
 target_mc._y = Stage.height/2-target_mc._height/2;
 var w:Number = target_mc._width;
 var h:Number = target_mc._height;
 //画边框
 target_mc.lineStyle(10, 0x00FFFF, 100, true, "normal", "square", "miter", 10);
 target_mc.moveTo(0, 0);
 target_mc.lineTo(w, 0);
 target_mc.lineTo(w, h);
 target_mc.lineTo(0, h);
 target_mc.lineTo(0, 0);
 //旋转角度
 //target_mc._rotation = -2;
};
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
image_mcl.loadClip("1111.jpg", image_mc);

相关文章

精彩推荐