flash拖动图片 代码

来源:百度知道 编辑:UC知道 时间:2024/05/16 09:52:28
在FLASH 里拖动图片代码如下
map_mc.onMouseDown = function () {
startDrag(map_mc);
}
map_mc.onMouseUp = function () {
stopDrag(); //
}

但是他能拖到画面外
怎么才能控制图片被拖到边是就在也拖不动了?

默认是以元件中心点为中心,中心点不可以拖拽出舞台外。
你可以加参数设置拖动范围的坐标具体的,你看帮助吧,里面都有。

你可以在flash里面新建一个空白的影片剪辑在剪辑里面随意画一点东西.然后将这个影片元件拖到场景之中,你场景中要几个这样的元件你就拖几个,我这里拖了四个同样的影片剪辑.并在场景中给这个影片剪辑各命一个实例名称.选中一个空白影片剪辑.然后点属性面板就可以命名了.我们可以随意合.我把它们分别命名为mc1 mc2 mc3 mc4吧.
现在就在时间轴上的第一帧写上下边的语句就行了.
mc1.onPress=function () {
startDrag(this);
}
mc1.onRelease=function () {
stopDrag();
}
mc2.onPress=function () {
startDrag(this);
}
mc2.onRelease=function () {
stopDrag();
}
mc3.onPress=function () {
startDrag(this);
}
mc3.onRelease=function () {
stopDrag();
}
mc4.onPress=function () {
startDrag(this);
}
mc4.onRelease=function () {
stopDrag();
}