///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_flashjq23 target="_blank">///pc/img/message.gif" width="64" height="54" alt="请您留言" border="0">
谈谈您的看法

///pc/img/blank.gif" width="1" height="1" border="0">
23.搜寻关键字数之二

  4、定影帧Actions。总共有两个关键帧,第1个关键帧设定的Actions为:stop,即停止。

///pc/homepage/flashsl/flash23/img/008.gif" width="186" height="118" align="absmiddle" alt="插入两个关键帧" border="0">   ///pc/homepage/flashsl/flash23/img/009.gif" width="251" height="87" align="absmiddle" alt="第1个帧的Actions" border="0">

第2个关键帧设定的Actions为:

///pc/homepage/flashsl/flash23/img/010.gif" width="352" height="176" alt="第2帧的Actions" border="0">

Set Variable: "total" = 0
Set Variable: "n" = Length ( text )
Set Variable: "m" = Length (keyword)
Loop While (n > 0 and m > 0)
 Set Variable: "search" = Substring ( text, n ,m )
 If (search eq keyword)
  Set Variable: "total" = total + 1
 End If
 Set Variable: "n" = n- 1
End Loop
If (total>0)
 Set Variable: "result" = "找到"&total&"个关键字"
Else
 Set Variable: "result" = "抱歉,找不到任何关键字"
End If
解释:此场景始终停留在第1个影帧,并不会播放第2个影帧,第2个影帧中的Actions由按钮来调用(用Call语句)。变量n是实体名为“text”的Text Field的字符数,变量m是实体名为“keyword”的Text Field的字符数,若两者都大于0,则执行Loop 语句。Loop语句的Actions表示为:从实体名称为“text ”的大Text Field的最后一个字符开始取出m个字符来和keyword比较,若相同就将计数值“total”累加1。直到实体名称为“text”的Text Field的第1个字符才跳出Loop。最后判断计数值“total”的大小,如果变量“total”大于0,则在变量名为“result”的Text Field中显示“找到‘total’个关键字”,否则显示“抱歉,找不到任何关键字”。
  5、放置按钮。将按钮元件“search”导入场景中,其Actions为:

///pc/homepage/flashsl/flash23/img/011.gif" width="323" height="109" alt="按钮的Actions" border="0">

On (Press) Call ("2") End On 解释:按下按钮后会调用第2个影帧的Actions来执行。


上一步
  下一实例(鼠标跟踪)


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

 

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