新客网WWW.XKER.COM:致力做中国最专业的网络学院!
学院: 操作系统 - 网络应用 - 服务器 - 网络安全 - 工具软件 - 办公软件 - Web开发 - 数据库 - 网页设计 - 图形图像 - 媒体动画 - 硬件学堂 - 存储频道 - QQ专区
您的位置:首页 > 网络学院 > 媒体动画 > Flash教程 > 正文:Flash简单实现网页中的Flash动画全屏

Flash简单实现网页中的Flash动画全屏

新客网 XKER.COM 2007-10-19 来源: 收藏本文

Flash播放器自从升级到Flash Player 9,0,28,0,也可以使网页中的Flash通过一个简单的按钮实现全屏显示,和一些视频网站中的效果基本相同,但是在这个教程里是没有使用Javascript脚本的啊!

需要我们在网页中插入Flash代码时,必须加上下面的代码:

<param name="allowFullScreen" value="true" />

首先看一下效果和源文件

点击这里下载源文件

启动Flash,制作一个按钮元件,然后把按钮放到主场景中,为按钮添加代码:

on(press){
  toggleFullScreen();
}

函数toggleFullScreen()是主要来控制窗口,函数定义如下。

//Don't scale the movie when the stage size changes
Stage.scaleMode="noScale";
//Align the stage to the top left
Stage.align = "TL";
//Function to toggle between fullscreen and normal size
//the toggle fullscreen button calls this function when pressed
function toggleFullScreen(){
  //if normal size, go to fullscreen, else go to normal size
  if(Stage["displayState"]=="normal"){
    Stage["displayState"]="fullScreen";
  }else{
    Stage["displayState"]="normal";
  }
}
//Create a listener for each time the Stage is resized
var resizeListener:Object = new Object();
//Called each time the stage is resized
resizeListener.onResize = function () {
  //Move the button to the center of the screen
  toggleFullScreenButton._x=Stage.width/2;
  toggleFullScreenButton._y=Stage.height/2;
}
//Add the listener to Stage
Stage.addListener(resizeListener);
 
这样就制作好了!

当我们把上面制作的Flash插入到网页中时,具体代码如下:

<object data="/xkerfiles/allimg/071019/20071018224608_fullscreen.swf"
type="application/x-shockwave-flash" width="400" height="200" >
<param name="movie" value="/xkerfiles/allimg/071019/20071018224608_fullscreen.swf" />
<param name="allowFullScreen" value="true" />
</object>

就可以看到前面的全屏和收缩效果了!

收藏】 【评论】 【推荐】 【投稿】 【打印】 【关闭
发表评论
要记得去论坛讨论,点击注册新会员匿名评论
评论内容:不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
阅读排行
随机推荐
实用信息推荐