Loading...
  所在位置:论坛首页 -> ┈┋电脑网络技术区┋┈ -> 图象媒体技术应用 -> 编写Flash AS代码实现按钮触发全屏动画
标题:编写Flash AS代码实现按钮触发全屏动画收藏 编辑 删除 楼主 | 上一篇 下一篇
点点头
等级:社区游民
权限:普通用户
积分:5
金钱:3247
声望:11
经验:11
发帖数:734
注册:2007年1月16日
资料 短消息2007-12-3 14:19:04
Flash播放器升级到Flash Player 9,0,28,0后可以使网页中的Flash通过一个简单的按钮实现全屏显示,这和一些视频网站中的效果基本相同,下面我们看看具体怎么实现,不需使用Javascript脚本。

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

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

  首先看一下效果:

/imagelist/2007/295/k02fla0kznk7.swf

  下面我们介绍Flash中的做法。

  启动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="你的swf文件地址"
type="application/x-shockwave-flash" width="400" height="200" >
<param name="movie" value="你的swf文件地址" />
<param name="allowFullScreen" value="true" />
</object>

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

2007-12-3 14:19:04 顶部
第1页 共页 共0个回复     <<    >>    
 快速回复
  • 支持UBB,HTML标签

  • 高级回复

  • 操作选项:评分 加精 解精 奖惩 设专题 设公告 解公告 固顶 总固顶 解固顶 结帖 解结帖 锁帖 解锁 移帖 删帖
      首页 | 购买指南 | 商业版本 | 虚拟主机 | 特色介绍 | 下载中心 | 支付方式
    Copyright 2004-2008 BBSGood.com Powered By: BBSGood.Speed Version 5.0
      咨询电话:0575-85513832、0575-85513825(传真)、7*24小时咨询服务:13606552007 不良信息举报中心 浙ICP备05029817号
      业务QQ:38958768、客服QQ1:415896239、客服QQ2:343896043、MSN:jccsxx@hotmail.com