2007/01/30 | 图书摘录四:创建滑动的平衡控件
类别(编程资源) | 评论(0) | 阅读(33) | 发表于 12:41

1. 使用“矩形”工具在舞台上绘制一个小矩形,大约 30 像素高 10 像素宽。
2. 选择“选择”工具并双击舞台上的形状。
3. 按 F8 键启动 “转换为元件”对话框。
4. 选择“按钮”类型,输入元件名称 balance 并单击 “确定”。
5. 在舞台上选中该按钮元件,在“属性”检查器中输入实例名称 handle_btn 。
6. 选择该按钮,然后选择“修改” >“转换为元件”。
选择影片剪辑行为时要小写。这将创建一个在第一帧中带有按钮的影片剪辑。
7. 选择该影片剪辑,然后在属性检查器中输入 balance_mc 作为实例名称。
8. 在“动作”面板中输入下面的代码:
balance_mc.top = balance_mc._y;
balance_mc.bottom = balance_mc._y;
balance_mc.left = balance_mc._x;
balance_mc.right = balance_mc._x + 100;
balance_mc._x += 50;
balance_mc.handle_btn.onPress = function() {
startDrag(this._parent, false, this._parent.left, this._parent.top,
this._parent.right, this._parent.bottom);
};
balance_mc.handle_btn.onRelease = function() {
stopDrag();
var level:Number = Math.ceil((this._parent._x - this._parent.left - 50)
* 2);
this._parent._parent.song_sound.setPan(level);
};
balance_mc.handle_btn.onReleaseOutside = balance_mc.handle_btn.onRelease;
startDrag() 参数 left、top、right 和 bottom 是在影片剪辑动作中设置的变量。
9. 选择“控制” >“测试影片”来使用平衡滑块。

注:简约,我喜欢。

0

评论Comments