-
flash第八讲——连线题
普通类 -
- 支持
- 批判
- 提问
- 解释
- 补充
- 删除
-
-
flash第八讲————————连线题
点击此处下载本次操作视频Flash第八次视频.rar
连线题源文件连线题.fla
-
连线题1
-
连线题2
-
连线题3
-
本课案例源代码
var line1:Sprite = new Sprite();
//line1.graphics.beginFill(0xFFFFFF);
//line1.graphics.drawRect(0, 0, 500, 400);
//line1.graphics.endFill();
addChildAt(line1, 0);
line1.graphics.lineStyle(3, 0x0000FF);
var left1Answer:int = 0;
var left2Answer:int = 0;
var left3Answer:int = 0;
var left4Answer:int = 0;
var selectItem:int = 0;
left1.addEventListener(MouseEvent.CLICK, function(){
line1.graphics.moveTo(left1.x, left1.y);
selectItem = 1;
});
left2.addEventListener(MouseEvent.CLICK, function(){
line1.graphics.moveTo(left2.x, left2.y);
selectItem = 2;
});
left3.addEventListener(MouseEvent.CLICK, function(){
line1.graphics.moveTo(left3.x, left3.y);
selectItem = 3;
});
left4.addEventListener(MouseEvent.CLICK, function(){
line1.graphics.moveTo(left4.x, left4.y);
selectItem = 4;
});
right1.addEventListener(MouseEvent.CLICK, function(){
line1.graphics.lineTo(right1.x, right1.y);
if(selectItem == 1) {
left1Answer = 1;
} else if(selectItem == 2) {
left2Answer = 1;
} else if(selectItem == 3) {
left3Answer = 1;
} else if(selectItem == 4) {
left4Answer = 1;
}
});
right2.addEventListener(MouseEvent.CLICK, function(){
line1.graphics.lineTo(right2.x, right2.y);
if(selectItem == 1) {
left1Answer = 2;
} else if(selectItem == 2) {
left2Answer = 2;
} else if(selectItem == 3) {
left3Answer = 2;
} else if(selectItem == 4) {
left4Answer = 2;
}
});
right3.addEventListener(MouseEvent.CLICK, function(){
line1.graphics.lineTo(right3.x, right3.y);
if(selectItem == 1) {
left1Answer = 3;
} else if(selectItem == 2) {
left2Answer = 3;
} else if(selectItem == 3) {
left3Answer = 3;
} else if(selectItem == 4) {
left4Answer = 3;
}
});
right4.addEventListener(MouseEvent.CLICK, function(){
line1.graphics.lineTo(right4.x, right4.y);
if(selectItem == 1) {
left1Answer = 4;
} else if(selectItem == 2) {
left2Answer = 4;
} else if(selectItem == 3) {
left3Answer = 4;
} else if(selectItem == 4) {
left4Answer = 4;
}
});
课堂上的源代码(不完整)
var line1:Sprite = new Sprite();
var line2:Sprite = new Sprite();
var line3:Sprite = new Sprite();
var line4:Sprite = new Sprite();
addChildAt(line1, 0);
addChildAt(line2, 0);
addChildAt(line3, 0);
addChildAt(line4, 0);var selectItem:int = 0;
var left1Answer:Array = [];
var left2Answer:int = 0;
var left3Answer:int = 0;
var left4Answer:int = 0;left1Answer[0] = 1;
left1Answer[1] = 2;
left1Answer[left1Answer.length] = 3;line1.graphics.lineStyle(3, 0xFF0000);
line2.graphics.lineStyle(3, 0xFF0000);
line3.graphics.lineStyle(3, 0xFF0000);
line4.graphics.lineStyle(3, 0xFF0000);left1.addEventListener(MouseEvent.CLICK,
function () {
left1.gotoAndStop(2);
selectItem = 1;
line1.graphics.moveTo(left1.x, left1.y);
});
left2.addEventListener(MouseEvent.CLICK,
function () {
left2.gotoAndStop(2);
selectItem = 2;
line2.graphics.moveTo(left2.x, left2.y);
});
left3.addEventListener(MouseEvent.CLICK,
function () {
left3.gotoAndStop(2);
selectItem = 3;
line3.graphics.moveTo(left3.x, left3.y);
});
left4.addEventListener(MouseEvent.CLICK,
function () {
left4.gotoAndStop(2);
selectItem = 4;
line4.graphics.moveTo(left4.x, left4.y);
});
right1.addEventListener(MouseEvent.CLICK,
function () {
if(selectItem == 1) {
left1.gotoAndStop(1);
if(left1Answer != 0) {
line1.graphics.clear();
line1.graphics.lineStyle(3, 0xFF0000);
line1.graphics.moveTo(left1.x, left1.y);
}
line1.graphics.lineTo(right1.x, right1.y);
left1Answer = 1;
} else if(selectItem == 2) {
left2.gotoAndStop(1);
if(left2Answer != 0) {
line2.graphics.clear();
line2.graphics.lineStyle(3, 0xFF0000);
line2.graphics.moveTo(left2.x, left2.y);
}
left2Answer = 1;
line2.graphics.lineTo(right1.x, right1.y);
} else if(selectItem == 3) {
left3.gotoAndStop(1);
if(left3Answer != 0) {
line3.graphics.clear();
line3.graphics.lineStyle(3, 0xFF0000);
line3.graphics.moveTo(left3.x, left3.y);
}
left3Answer = 1;
line3.graphics.lineTo(right1.x, right1.y);
} else if(selectItem == 4) {
left4.gotoAndStop(1);
if(left4Answer != 0) {
line4.graphics.clear();
line4.graphics.lineStyle(3, 0xFF0000);
line4.graphics.moveTo(left4.x, left4.y);
}
left4Answer = 1;
line4.graphics.lineTo(right1.x, right1.y);
}
selectItem = 0;
});
right2.addEventListener(MouseEvent.CLICK,
function () {
if(selectItem == 1) {
left1.gotoAndStop(1);
left1Answer = 2;
line1.graphics.lineTo(right2.x, right2.y);
} else if(selectItem == 2) {
left2.gotoAndStop(1);
left2Answer = 2;
line2.graphics.lineTo(right2.x, right2.y);
} else if(selectItem == 3) {
left3.gotoAndStop(1);
left3Answer = 2;
line3.graphics.lineTo(right2.x, right2.y);
} else if(selectItem == 4) {
left4.gotoAndStop(1);
left4Answer = 2;
line4.graphics.lineTo(right2.x, right2.y);
}
selectItem = 0;
});
right3.addEventListener(MouseEvent.CLICK,
function () {
if(selectItem == 1) {
left1.gotoAndStop(1);
left1Answer = 3;
line1.graphics.lineTo(right3.x, right3.y);
} else if(selectItem == 2) {
left2.gotoAndStop(1);
left2Answer = 3;
line2.graphics.lineTo(right3.x, right3.y);
} else if(selectItem == 3) {
left3.gotoAndStop(1);
left3Answer = 3;
line3.graphics.lineTo(right3.x, right3.y);
} else if(selectItem == 4) {
left4.gotoAndStop(1);
left4Answer = 3;
line4.graphics.lineTo(right3.x, right3.y);
}
selectItem = 0;
});
right4.addEventListener(MouseEvent.CLICK,
function () {
if(selectItem == 1) {
left1.gotoAndStop(1);
left1Answer = 4;
line1.graphics.lineTo(right4.x, right4.y);
} else if(selectItem == 2) {
left2.gotoAndStop(1);
left2Answer = 4;
line2.graphics.lineTo(right4.x, right4.y);
} else if(selectItem == 3) {
left3.gotoAndStop(1);
left3Answer = 4;
line3.graphics.lineTo(right4.x, right4.y);
} else if(selectItem == 4) {
left4.gotoAndStop(1);
left4Answer = 4;
line4.graphics.lineTo(right4.x, right4.y);
}
selectItem = 0;
}); -
-
- 标签:
- 连线
- left3answer
- mouseevent.click
- left4answer
- left1answer
- var
- function
- sprite
- selectitem
- left2answer
- int
- flash
-
学习元评论 (0条)
聪明如你,不妨在这 发表你的看法与心得 ~