关键字
以假乱真的背景色以假乱真的背景色(Flash)

以假乱真的背景色


点击浏览该文件
http://www.Flash8.net/bbs/UploadFile/2004-12/200412421950774.swf

改变框里的数字看看发生了什?
今夜学习的成果,只是一种尝试,没啥难点!感兴趣的就琢磨一下吧!
代码如下,直接粘贴到第一帧就可以了,这可是纯AS版地 :
如果真看不懂也不要问,选中那个单词,然后按下F1,看看发生了什么?!( 切记:这一切要在 Flash MX 2004 下去做。如果在IE下这么做 )

// 函数:setBgColor()
// 功能:模拟设置背景色
// 参数:
// instMcpName:String 影片实例名称,字符串,例如:"instMcpBgColor"
// levelNumber:Number 影片实例所在层级,正整数
// colorRGB:Number 色彩值,十六进制数值,例如:0xFF0000
// originX:Number, originY:Number 原点(左上角)坐标,单位为pixel
// diagonalX:Number, diagonalY:Number 对角点坐标,与原点构成矩形对角线,单位为pixel
// 返回值:_root[instMcpName]:movieclip 影片剪辑实例,movieclip对象
function setBgColor(instMcpName:String, levelNumber:Number, colorRGB:Number, originX:Number, originY:Number, width:Number, height:Number) {
// 创建空的影片剪辑实例
_root.createEmptyMovieClip(instMcpName, levelNumber);
with (_root[instMcpName]) {
// 设置颜色填充
beginFill(colorRGB);
// 设置无边框矩形
lineStyle(undefined);
moveTo(originX, originY);
lineTo(originX+width, originY);
lineTo(originX+width, originY+height);
lineTo(originX, originY+height);
lineTo(originX, originY);
endFill();
}
return _root[instMcpName];
}
// Stage.scaleMode 属性值说明
// "showAll" 长宽比固定最小适应。窗口中可以显示全部影片,影片不产生变形,是默认值。
// "noBorder" 长宽比固定最大适应。根据长宽中最大值显示影片,窗口中有时可能无法显示全部影片。
// "noScale" 无缩放,不随 Flash Player 大小变化而变化,始终保持影片属性中设置的宽、高值。
// "exactFit" 长宽比不固定完全适应。影片充满整个窗口!因此影片可能产生变形。
// 设置缩放模式,"exactFit"可以使背景充满画面。
Stage.scaleMode = "exactFit";
// 隐藏 Flash Player 上下文菜单中的默认项
Stage.showMenu = false;
// 设置模拟设置背景色
bgColor = setBgColor("instMcBgColor", 1, 0x009999, 0, 0, Stage.width, Stage.height);
//trace(typeof (bgColor));
_root.createTextField("instInput", 2, Stage.width/2, Stage.height/2, 200, 100);
with (_root.instInput) {
type = "input";
_height = 18;
_width = 50;
background = true;
restrict = "A-F0-9";
maxChars = 6;
text = "009999";
}
_root.createTextField("instInput2", 3, instInput._x, instInput._y-18, 200, 100);
with (_root.instInput2) {
type = "dynamic";
_height = 18;
_width = 50;
background = true;
backgroundColor = 0x000000;
textColor = 0xFFFFFF;
selectable = false;
text = "RGB设置";
}
// 文字格式设置
my_fmt = new TextFormat();
my_fmt.align = "center";
instInput.setTextFormat(my_fmt);
instInput2.setTextFormat(my_fmt);
// 文本框内容变化时触发
_root.instInput.onChanged = function(txt) {
//trace(txt._name+" changed");
if (txt.length == 6) {
myColor = new Color(bgColor);
myColor.setRGB(Number("0x"+txt.text));
}
instInput.setTextFormat(my_fmt);
};

2006-01-08 15:05:53.0