中国设计秀欢迎投稿
联网
平面设计 画册 VI欣赏 包装 CG-插画 搜索 个人网页 Alexa排名 CSS 建站资源 下载专区 JS特效 品牌服装 服装院校 专题欣赏 SEO 图标欣赏 专题
域名注册 虚拟主机 广州网站设计 域名注册 广州网站建设 上海网站建设 虚拟主机 广州网页设计 签名设计 虚拟主机 域名注册 acg王国 ACG玩家
求创科技
上海网麒科技
中国福网
数字引擎
招聘求职
中国互联
时代互联
中资源
当前位置:网络学院首页 >> 设计教程 >> Flash >> 编写Flash AS代码实现按钮触发全屏动画

编写Flash AS代码实现按钮触发全屏动画

来源:中国设计秀    作者:    点击:95     加入收藏    发表评论
0
顶一下
中国品牌设计网
  Flash播放器升级到Flash Player 9,0,28,0后可以使网页中的Flash通过一个简单的按钮实现全屏显示,这和一些视频网站中的效果基本相同,下面我们看看具体怎么实现,不需使用Javascript脚本。

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

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

  首先看一下效果:


  下面我们介绍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-10-23 11:21:00    出处:
网站地图 | 关于我们 | 联系我们 | 网站建设 | 广告服务 | 版权声明 | 免责声明 | 网站公告 | 友情链接 | 留言 | 旧版入口