///pc/img/blank.gif" width="12" height="8" border="0">当前位置:///default.htm" class="under">亿度网络 -> ///pc/index.htm" class="under">网页制作教程 -> Flash实例


/pc/bin/msg.pl?file_id=k_flashjq35 target="_blank">///pc/img/message.gif" width="64" height="54" alt="请您留言" border="0">
谈谈您的看法

///pc/img/blank.gif" width="1" height="1" border="0">
35.三角函数之一
预览成品:在Flash 4中,算术计算函数十分有限,很多函数计算都必须手写很多代码得以进行,这对一些不太懂编程的朋友来说是一件很痛苦的事情。此实例我们提供了一些常用的三角函数:正弦,余弦。

///pc/homepage/flashsl/flash35/swf/trig.zip" target="_blank"> 下载源程序


逐步说明:
  1)选择工具栏中的文字工具///pc/homepage/flashsl/flash35/img/001.gif" width="23" height="21" align="absmiddle" border="0">,在工作区中的适当位置点击并输入文字“在此输入角度:”。按下文字参数栏中的///pc/homepage/flashsl/flash35/img/002.gif" width="24" height="21" align="absmiddle" border="0">按钮,并在文字右边拉出一文本框为如图所示。

///pc/homepage/flashsl/flash35/img/003.gif" width="249" height="55" alt="文本框" border="0">

设置其变量为名为“angle”。

///pc/homepage/flashsl/flash35/img/004.gif" width="338" height="300" alt="文本框变量" border="0">

  2)同理,在工作区中的下方输入文字并拉出文本框为如图所示。设置文本框的变量名为“output”。

///pc/homepage/flashsl/flash35/img/005.gif" width="247" height="196" alt="文本框" border="0">

  3)选择菜单Insert->New Symbol,

///pc/homepage/flashsl/flash35/img/007.gif" width="201" height="61" alt="建立图符" border="0">

弹出图符属性对话框,输入图符名称为“trig”,并选择Movie Clip项,

///pc/homepage/flashsl/flash35/img/008.gif" width="213" height="98" alt="图符属性" border="0">

设置完毕,点击OK按钮,进入图符编辑模式。
  4)建立程序为如图所示。

///pc/homepage/flashsl/flash35/img/009.gif" width="427" height="103" alt="trig编辑" border="0">

stop层中只有一个空的关键帧,设置的Actions为:
stop。
  表示执行到该帧时停止。
  set values层中也只有一个空的关键帧,其Actions为:

///pc/homepage/flashsl/flash35/img/010.gif" width="358" height="286" alt="Actions" border="0">

Set Variable: "sin0" = 0
Set Variable: "sin1" = .0175
    ……
Set Variable: "sin90" = 1
Set Variable: "count" = 91
Loop While (count <=180)
 Set Variable: "sin" & count = eval ("sin" & (180 - count))
 Set Variable: "count" = count + 1
End Loop
Set Variable: "count" = 181
Loop While (count <=270)
 Set Variable: "sin" & count = eval ("sin" & (count - 180)) * -1
 Set Variable: "count" = count + 1
End Loop
Set Variable: "count" = 271
Loop While (count <=360)
 Set Variable: "sin" & count = eval ("sin" & (360 - count)) * -1
 Set Variable: "count" = count + 1
End Loop
Set Variable: "count" = 0
Loop While (count <= 90)
 Set Variable: "cos" & count = eval ("sin" & (90 - count))
 Set Variable: "count" = count + 1
End Loop
Set Variable: "count" = 91
Loop While (count <=180)
 Set Variable: "cos" & count = eval ("cos" & (180 - count)) * -1
 Set Variable: "count" = count + 1
End Loop
Set Variable: "count" = 181
Loop While (count <=270)
 Set Variable: "cos" & count = eval ("cos" & (count - 180)) * -1
 Set Variable: "count" = count + 1
End Loop
Set Variable: "count" = 271
Loop While (count <=360)
 Set Variable: "cos" & count = eval ("cos" & (360 - count))
 Set Variable: "count" = count + 1
End Loop
  该程序表示:设置不同范围内“整数角度”的正弦、余弦值。请注意这里是“整数角度”。


上一实例(连续控制Movie Clip)  下一步
/pc/bin/msg.pl?file_id=k_flashjq35 target="_blank">
///pc/img/message.gif" width="64" height="54" alt="请您留言" border="0">

/pc/bin/msg.pl?file_id=k_flashjq35s target="_blank">谈谈您的看法

 

 

网页制作 网页设计 网站建设 网站设计 网站制作 做网站 做网页