一、输入题目
点击文本工具(静态文本),在舞台上单击,输入以下题目:将下面的作家与作品用线条连接起来。
余光中 《乡愁》
徐志摩 《再别康桥》
二、制作作家作品上方影片剪辑
(1)点击【插入】|【新建元件】|【影片剪辑】,进入编辑区,用矩形工具画一个无边框的矩形,返回场景,按【ctrl+l】打开库面板,将此影片剪辑拖入场景中,放于作家名字上方(有几个作家就拖几个影片剪辑,都放于作家名字上方),并取实名称为【zhuojia1】【zhuojia2】。
(2)用同样的方法制作作品上方的影片剪辑,将其放于作品上方,取实例名称为【zhuopin1】【zhuopin2】。
(3)分别选中作家与作品上方的影片剪辑,在属性面板中【颜色】处将影片剪辑的【Alpha】设为0,使其为透明。
三、制作对错影片剪辑
(1)点击【插入】|【新建元件】,选择【影片剪辑】进入编辑区。点击图层1第二帧鼠标右键单击,插入【空白关键帧】,然后选择【线条工具】,笔触颜色为红色,在舞台中间绘制一个红色的对勾。
(2)点击图层1第二帧鼠标右键单击,插入【空白关键帧】,然后选择【线条工具】,笔触颜色为红色,在舞台中间绘制一个红色的差。(与上一步画红色对勾方法相同,需要注意的是绘制的图形尽量按排在中间,即十字架处)
(3)选中图层1第1帧,打开动作面板,在代码编辑区输入代码:stop().
(4)返回场景,将对错影片剪辑拖到作品的后边,第一个取实例名称为【duicuo1】,第二个取实例名称为【duicuo2】。
四、制作提交、重做按钮
依次点击【窗口】|【公用库】|【按钮】,选择一个按钮拖到舞台中,放好位置。双击此按钮,选中【text】层的弹起帧,将文字改为【提交】,然后返回场景.
五、编写代码
(1)选中【zhuojia1】影片剪辑,打开动作面板,输入代码:
onClipEvent (mouseMove) {
x1 = _x;
y1 = _y;
}
on (press) {
this.startDrag();
}
on (release) {
if (this.hitTest(_root.zhuopin1)) {
this._x = x1;
this._y = y1;
this.stopDrag();
}elseif(this.hitTest(_root.zhuopin2)) {
this._x = x1;
this._y = y1;
this.stopDrag();
}
}
(2)选中【zhuojia2】影片剪辑,打开动作面板,输入代码:
onClipEvent (mouseMove) {
x1 = _x;
y1 = _y;
}
on (press) {
this.startDrag();
}
on (release) {
if (this.hitTest(_root.zhuopin2)) {
this._x = x1;
this._y = y1;
this.stopDrag();
}elseif(this.hitTest(_root.zhuopin1)) {
this._x = x1;
this._y = y1;
this.stopDrag();
}
}
(3)选中提交按钮,打开动作面板,输入代码:
on (release) {
if(_root.zhuojia1.hitTest(_root.zhuopin1)) {
duicuo1.gotoAndStop(2);
}elseif(_root.zhuojia1.hitTest(_root.zhuopin2)) {
duicuo2.gotoAndStop(3);
}
}
on (release) {
if(_root.zhuojia2.hitTest(_root.zhuopin2)) {
duicuo2.gotoAndStop(2);
}elseif(_root.zhuojia2.hitTest(_root.zhuopin1)) {
duicuo1.gotoAndStop(3);
}
}
(4)新建一层,在第一帧输入画线代码:
_root.onMouseDown = function() {
_root.lineStyle(2, 0xff0000, 100);
_root.moveTo(_xmouse, _ymouse);
};
_root.onMouseMove = function() {
updateAfterEvent();
};
_root.onMouseUp = function() {
_root.lineTo(_xmouse, _ymouse);
};
如果不想要提交按钮来判断正确,而是直接连线后就出现判断,则可不要提交按钮代码,将【zhuojia1】改为:
onClipEvent (mouseMove) {
x1 = _x;
y1 = _y;
}
on (press) {
this.startDrag();
}
on (release) {
if (this.hitTest(_root.zhuopin1)) {
this._x = x1;
this._y = y1;
this.stopDrag();
duicuo1.gotoAndStop(2);
}elseif (this.hitTest(_root.zhuopin2)) {
this._x = x1;
this._y = y1;
this.stopDrag();
duicuo2.gotoAndStop(3);
}
}
【zhuojia2】代码改为:
onClipEvent (mouseMove) {
x1 = _x;
y1 = _y;
}
on (press) {
this.startDrag();
}
on (release) {
if (this.hitTest(_root.zhuopin2)) {
this._x = x1;
this._y = y1;
this.stopDrag();
duicuo2.gotoAndStop(2);
}elseif (this.hitTest(_root.zhuopin1)) {
this._x = x1;
this._y = y1;
this.stopDrag();
duicuo1.gotoAndStop(3);
}
}