flash下拉列表(comboBox
*/
//画矩形
function createRectangle(x:Number, y:Number, w:Number, h:Number, mc:MovieClip) {
mc.beginFill(0xffffff);
mc.moveTo(x, y);
mc.lineTo(x+w, y);
mc.lineTo(x+w, y+h);
mc.lineTo(x, y+h);
mc.lineTo(x, y);
mc.endFill();
}
//
var mygamemylove_com:Object=new Object()
//_mc 附加的下拉列表模板,模板要注意的几点:1.下拉列表的背景:库:"buton"元件,它有3种状态:鼠标点击,放上面,离开。2.库"下拉菜单组件"元件,里的那个mc的名称必须为:mcXiaLa
//详情最好参看源文件。下载地址:http://www.mygamemylove.com/121.html
//arrList 数据列表
//点击某一个表单要处理的动作
//例子
//var arrTem:Array = [{label:"易做图易做图", data:1}, {label:"生活娱乐", data:2}, {label:"自然风景", data:3}, {label:"科技时代", data:4}];
//mygamemylove_com.iniDropList(mcXiaLa, arrTem, function () {
//trace(mcXiaLa.value);
//});
mygamemylove_com.iniDropList = function(_mc:MovieClip, arrList:Array, funWhenPress:Function) {
//生成文本
_mc.setTxt = function(target_mc:MovieClip, strTalkYor:String, x:Number, y:Number, color1:Number) {
target_mc.createTextField("my_txt", 1, x, y, 100, 30);
target_mc.my_txt.multiline = true;
//
target_mc.my_txt.selectable = false;
//指示文本字段是否为多行文本字段
target_mc.my_txt.wordWrap = true;
//是否自动换行
target_mc.my_txt.my_fmt = new TextFormat();
target_mc.my_txt.my_fmt.color = color1;
//颜色
//target_mc.my_txt.my_fmt.underline = true;
//下划线
target_mc.my_txt.my_fmt.bold = true;
//加粗
target_mc.my_txt.my_fmt.font = "Arial";
//
target_mc.my_txt.text = strTalkYor;
target_mc.my_txt.setTextFormat(target_mc.my_txt.my_fmt);
};
//
_mc.arrList = arrList;
//
_mc.setTxt(_mc, _mc.arrList[0].label, 0, 0, 0);
//
_mc.value = _mc.arrList[0].data;
//
_mc.mcXiaLa.gotoAndStop(1);
_mc.mcXiaLa.onRollOver = function() {
//生成一个背景,目的在于,可以屏蔽掉如果它的下边有一些按键的问题
//flash背景调到灰色你可以看到这个白框。
this._parent.createEmptyMovieClip("mcBak", 2);
createRectangle(0, 23, 100, this._parent.arrList.length*24, this._parent.mcBak);
this._parent.mcBak.onRelease = function() {
};
//
this.gotoAndStop(2);
//
this._parent.createEmptyMovieClip("mcRongQi", 3);
var numStarY:Number = 24;
//显示列表。
for (var i:Number = 0; i<this._parent.arrList.length; i++) {
var mcTem:MovieClip = this._parent.mcRongQi.attachMovie("buton", "buton"+i, this._parent.mcRongQi.getNextHighestDepth(), {_y:numStarY*(i+1), _width:_mc.mcXiaLa._width, value:_mc.arrList.data, numI:i});
//
//
this._parent.setTxt(mcTem, _mc.arrList.label, 0, 0, 0);
//
mcTem.gotoAndStop(1);
mcTem.onRollOver = function() {
this.gotoAndStop(2);
};
mcTem.onRollOut = function() {
this.gotoAndStop(1);
};
mcTem.onPress = function() {
this.gotoAndStop(3);
//
this._parent._parent.my_txt.text = this._parent._parent.arrList[this.numI].label;
this._parent._parent.value = this._parent._parent.arrList[this.numI].data;
//
funWhenPress();
//
this._parent._parent.mcBak.removeMovieClip();
//
this._parent.removeMovieClip();
};
mcTem.onRelease = function() {
this.gotoAndStop(1);
};
}
//
};
_mc.mcXiaLa.onRollOut = function() {
this.gotoAndStop(1);
};
_mc.mcXiaLa.onPress = function() {
this.gotoAndStop(3);
};
_mc.mcXiaLa.onRelease = function() {
this.gotoAndStop(1);
//
};
//
};
//下拉列表,图片分类
var arrTem:Array = [{label:"易做图易做图", data:1}, {label:"生活娱乐", data:2}, {label:"自然风景", data:3}, {label:"科技时代", data:4}];
mygamemylove_com.iniDropList(mcXiaLa, arrTem, function () {
//trace(mcXiaLa.value);
});
补充:flash教程,As3.0