功夫之王游戏的教程动画
功夫之王Flash游戏,好好玩啊
用网页控制flash播放和暂停
具体步骤
代码示例:
<object id="movie" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="150" height="100" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="demo.swf" />
<param name="menu" value="false" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffcc33" />
<embed src="demo.swf" menu="false" quality="high" bgcolor="#ffcc33" width="150" height="100" name="movie" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object><br>
<button onClick="movie.IsPlaying()?movie.StopPlay():movie.Play()">Pause</button>
提示:本例中的核心语句
movie.IsPlaying()?movie.StopPlay():movie.Play()
用了三目运算符,相当于
if(movie.IsPlaying()){
movie.StopPlay()
} else{
movie.Play()
}
特别提示
本例代码运行后的效果如图5.3.2所示,单击【Pause】按钮时如果Flash动画正在播放,则停止播放动画,否则播放动画。
图5.3.2 暂停Flash动画的按钮的实现
特别说明
本例主要用到Flash对象的IsPlaying()方法来测试Flash动画的当前播放状态,然后分别调用Play()方法和StopPlay()方法来实现暂停的功能。
IsPlaying() 如果动画当前正在播放,返回为 true,反之返回 false 。
FLASH AS3 画扇形函数
*Create by Geordi 14th Feb 2008
*function DrawSector is drawing a sector in the flash by actionscript 3
*/
import flash.display.MovieClip;
import flash.display.Sprite;
var stag:Sprite=new Sprite();
addChild(stag);
var moviec:MovieClip=new MovieClip;
stag.addChild(moviec);
var S_angle:int=60;
* degree sector in this example, but you could change it to what ever you want
DrawSector(moviec,200,200,100,S_angle,270,0xffcc00);
* mc the movieclip: the container of the sector.
* x,y the center position of the sector
* r the radius of the sector
* angle the angle of the sector
* startFrom the start degree counting point : 270 top, 180 left, 0 right, 90 bottom ,
* color the fil lin color of the sector
*/
{
/* start to fill the sector with the variable "color" if you want a sector without filling color ,
mc.graphics.beginFill(color,50); //remove this line to unfill the sector
*/
angle=(Math.abs(angle)>360)?360:angle;
var n:Number=Math.ceil(Math.abs(angle)/45);
var angleA:Number=angle/n;
angleA=angleA*Math.PI/180;
startFrom=startFrom*Math.PI/180;
mc.graphics.lineTo(x+r*Math.cos(startFrom),y+r*Math.sin(startFrom));
for(var i=1;i<=n;i++)
{
startFrom+=angleA;
var angleMid=startFrom-angleA/2;
var bx=x+r/Math.cos(angleA/2)*Math.cos(angleMid);
var by=y+r/Math.cos(angleA/2)*Math.sin(angleMid);
var cx=x+r*Math.cos(startFrom);
var cy=y+r*Math.sin(startFrom);
mc.graphics.curveTo(bx,by,cx,cy);
}
if(angle!=360)
mc.graphics.lineTo(x,y);
mc.graphics.endFill(); // if you want a sector without filling color , please remove this line.
}
php对多维数组按某值排序的例子
<?php
$arr = array(
"0" => array(line_num => "10", occur_time => "2007-11-19 10:25:04+08"),
"1" => array(line_num => "9", occur_time => "2007-11-19 10:25:04+08"),
"2" => array(line_num => "25", occur_time => "2007-11-19 10:25:04+08")
);
print_r($arr);
echo "<br />";
echo "<br />";
echo "<br />";
uasort( $arr,create_function('$a, $b', 'return $a[\'line_num\'] < $b[\'line_num\'];') );
print_r($arr);
echo "<br />";
echo "<br />";
echo "<br />";
foreach($arr as $key => $value) {
$ar[] = $value;
}
print_r($ar);
?>
输出结果:
Array
(
[0] => Array
(
[line_num] => 10
[occur_time] => 2007-11-19 10:25:04+08
)
[1] => Array
(
[line_num] => 9
[occur_time] => 2007-11-19 10:25:04+08
)
[2] => Array
(
[line_num] => 25
[occur_time] => 2007-11-19 10:25:04+08
)
)
<br /><br /><br />Array
(
[2] => Array
(
[line_num] => 25
[occur_time] => 2007-11-19 10:25:04+08
)
[0] => Array
(
[line_num] => 10
[occur_time] => 2007-11-19 10:25:04+08
)
[1] => Array
(
[line_num] => 9
[occur_time] => 2007-11-19 10:25:04+08
)
)
<br /><br /><br />Array
(
[0] => Array
(
[line_num] => 25
[occur_time] => 2007-11-19 10:25:04+08
)
[1] => Array
(
[line_num] => 10
[occur_time] => 2007-11-19 10:25:04+08
)
[2] => Array
(
[line_num] => 9
[occur_time] => 2007-11-19 10:25:04+08
)
)