ActionScript编程实战项目无忧数学课件Word文档下载推荐.docx
- 文档编号:14554520
- 上传时间:2022-10-23
- 格式:DOCX
- 页数:11
- 大小:168.18KB
ActionScript编程实战项目无忧数学课件Word文档下载推荐.docx
《ActionScript编程实战项目无忧数学课件Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《ActionScript编程实战项目无忧数学课件Word文档下载推荐.docx(11页珍藏版)》请在冰豆网上搜索。
importflash.display.Sprite;
importflash.display.BitmapData;
importflash.display.Bitmap;
importflash.display.MovieClip;
importflash.geom.Point;
importflash.events.MouseEvent;
importfl.controls.Button;
importfl.controls.TextArea;
importfl.controls.Label;
importflash.utils.setInterval;
}
(5)创建名为ControlAxes的自定义类,作为影片的主类,并在主类中实例化影片使用的各种对象,如下所示。
privatevarbanner:
Bitmap=newBitmap(newBanner(550,35));
//实例化影片的标题栏
privatevarbackgroundImage:
Bitmap=newBitmap(newBackgroundImage(550,400));
//实例化影片的背景
privatevarfield:
Bitmap=newBitmap(newField(312,312));
//实例化坐标轴区域
privatevaraxesMC:
MovieClip=newMovieClip();
//实例化坐标轴所在的影片剪辑
privatevaraxesSprite:
Sprite=newSprite();
//实例化坐标轴所在的图像单元
privatevaraxesPoint:
Point=newPoint();
//实例化用户选择的坐标点
privatevardistanceLine:
//实例化坐标点到坐标原点的距离
privatevarpointCircle:
//实例化坐标点的红色标志
privatevaraxesBtn:
Button=newButton();
privatevardistanceBtn:
privatevardrawLineBtn:
privatevarangleBtn:
//实例化用户选择的按钮组件
privatevaroutputBox:
TextArea=newTextArea();
//实例化输出信息的文本域
privatevarcurrentRotation:
Number;
privatevarxAxeLabel:
Label=newLabel();
privatevaryAxeLabel:
privatevartipLine:
//实例化参考线的图像单元
(6)自定义createUserInterface()函数,用于创建影片的标题栏、背景等图像,如下所示。
privatefunctioncreateUserInterface():
void{
with(backgroundImage){
//定义背景图像的属性
x=0;
y=0;
}
with(banner){
//定义标题栏的属性
with(stage){
addChild(backgroundImage);
addChild(banner);
//分别将两个图像添加到舞台中
(7)自定义createAxes()函数,在函数中制作坐标轴区域的影片剪辑,并绘制坐标轴,如下所示。
privatefunctioncreateAxes():
with(field){
//定义坐标轴区域的背景
x=-155;
y=-155;
with(axesMC){
//定义坐标轴区域的影片剪辑
addChild(field);
x=196;
y=216;
addEventListener(MouseEvent.CLICK,createPoint);
addEventListener(MouseEvent.MOUSE_OVER,createToolTips);
addEventListener(MouseEvent.MOUSE_OUT,removeToolTips);
addChild(axesSprite);
addChild(distanceLine);
addChild(xAxeLabel);
addChild(yAxeLabel);
addChild(tipLine);
with(axesSprite.graphics){
//绘制坐标轴
lineStyle(1,0x000000,1);
moveTo(0,-155);
lineTo(0,155);
moveTo(-155,0);
lineTo(155,0);
moveTo(150,-3.5);
lineTo(155,0.5);
moveTo(150,3.5);
moveTo(-3.5,-150);
lineTo(0.5,-155);
moveTo(3.5,-150);
with(xAxeLabel){
//x轴的标签文本
move(125,-1);
text="
x轴"
;
with(yAxeLabel){
//y轴的标签文本
move(-20,-156);
y轴"
setInterval(toolTipsValue,100);
//调用计时函数,绘制辅助线
tipLine.visible=false;
//隐藏辅助线
stage.addChild(axesMC);
//将坐标轴区域的影片剪辑添加到舞台中
(8)自定义createPoint()函数,在用户单击坐标轴区域时,绘制一个半径为2px的红色圆点,标记用户单击的位置,如下所示。
privatefunctioncreatePoint(event:
MouseEvent=null):
with(axesPoint){
//获取用户单击的点坐标
x=mouseX-axesMC.x;
y=mouseY-axesMC.y;
if(Math.abs(mouseX-axesMC.x)<
=150&
&
Math.abs(mouseY-axesMC.y)<
=150){
//判断当用户在坐标轴区域单击时
with(pointCircle.graphics){
//绘制实心圆点
clear();
beginFill(0xff0000);
drawCircle(mouseX-axesMC.x,mouseY-axesMC.y,1);
endFill();
axesMC.addChild(pointCircle);
//将圆点添加到坐标轴区域
if(axesPoint.x>
=0&
axesPoint.y<
0){
//判断当坐标在第4象限
currentRotation=Math.atan(-axesPoint.y/axesPoint.x)*180/Math.PI;
//求点到原点间的直线斜率
}elseif(axesPoint.x<
//判断当点第1、2象限
currentRotation=180+Math.atan(-axesPoint.y/axesPoint.x)*180/Math.PI;
}else{
//判断当点在第3象限
currentRotation=360+Math.atan(-axesPoint.y/axesPoint.x)*180/Math.PI;
(9)自定义createComponents()函数,创建课件所使用的各种组件,设置其属性,如下所示。
privatefunctioncreateComponents():
with(axesBtn){
//定义显示点坐标的按钮属性
move(380,60);
setSize(150,25);
label="
点的坐标"
addEventListener(MouseEvent.CLICK,outputText);
with(distanceBtn){
//定义求点到原点距离的按钮属性
move(380,90);
到原点的距离"
with(drawLineBtn){
//定义绘制点到原点连接线的按钮属性
move(380,120);
绘制连接线"
with(angleBtn){
//定义求连接线与x轴夹角的按钮属性
move(380,150);
与x轴夹角"
with(outputBox){
//定义输出结果的文本域属性
move(380,180);
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- ActionScript编程 实战项目无忧数学课件 ActionScript 编程 实战 项目 无忧 数学 课件