WEB开发网
开发学院图形图像Flash 实现flash站整个网页且flash总是居中 阅读

实现flash站整个网页且flash总是居中

 2008-01-25 11:19:35 来源:WEB开发网   
核心提示:flash站满整个网页且flash总是居中,站满整个网页 flash居中效果查看地址:http://www.mygamemylove.com/demo/flashatthis/下载地址:http://www.mygamemylove.com/114.html看了闪吧的:“影像“系统,实现flas

flash站满整个网页且flash总是居中。

站满整个网页 flash居中

效果查看地址:http://www.mygamemylove.com/demo/flashatthis/

下载地址:http://www.mygamemylove.com/114.html

看了闪吧的:“影像“系统,发现一个很好的效果就是无论浏览器的大小如何不停的改变,它里面的工具栏,属性栏始终贴在左边或者右边,就是说

始终保持着相对的坐标。这个是如何做到了,对过笔者的研究,其实很容易做到。

我们现在分两步说,flash站满整个网页,然后再来看:让flash中的元件始终处于相对位置。

1.flash站满整个网页(这一部分完全是仿造闪吧影像“系统的首页来作的)s

一个外部的js文件用于显示出要插入的flash,这样的好处是在iE中,flash不会出现虚框。

然后就是html文件了。这样了调用js,显示flash:

<html>
<head>
<meta http-equiv="Content-Type" c />
<title>欢迎您常来自娱自乐,我的经验与您分享.wwww.mygamemylove.com</title>
<style type="text/css">
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
</style>
</head>
<body>
<div class="flash-content-swf">
<script type="text/javascript" src="js/swfobject.js"></script>
<div id="flashcontent">
播放此动画需要
<a href="http://www.adobe.com/go/getflashplayer">FlashPlayre9</a>.
欢迎您常来自娱自乐,我的经验与您分享.wwww.mygamemylove.com
</div>
<script type="text/javascript"> var so = new SWFObject("swftest.swf", "index", "100%", "100%", "9", "#ffffff");so.write
("flashcontent");</script></div>
</body>
</html>
注意几点的就是:

1.用css:body来定义页面的上下左右的边距为0。2.就是要插入的flash地址div的id名称要与:so.write("flashcontent");一致。

其次还要注意一点儿的就是背景色的设置:new SWFObject("swftest.swf", "index", "100%", "100%", "9", "#ffffff")最后一个参数,要与flash

本身的背景色相同,不然后会出现不想要的效果

2.让flash中的元件始终处于相对位置

flash代码为:

//影片的相对位置#####################
//引用影片的相对位置类
importmygamemylove_com.*;
//这个一行很重要,不改变flash的原始尺寸。
Stage.scaleMode="noScale";
//左上对齐
Stage.align="LT";
//
varcasSwfXY:casSwf=newcasSwf();
//不停更改。
_root.onEnterFrame=function(){
////设置左
casSwfXY.setL(Stage.width,Stage.height,mcL);
//设置上
casSwfXY.setT(Stage.width,Stage.height,mcT);
//设置右
casSwfXY.setR(Stage.width,Stage.height,mcR);
//设置中
casSwfXY.setC(Stage.width,Stage.height,mcC);
//设置下
casSwfXY.setD(Stage.width,Stage.height,mcD);
};
获得影片的相对位置的类:
注意:文件要放在mygamemylove_com这个文件夹内,名子为:casSwf.as
classmygamemylove_com.casSwf{
//设置左
functionsetL(numW:Number,numH:Number,_mc:MovieClip){
 _mc._x=0;
 _mc._y=numH/2-_mc._height/2;
}
//设置上
functionsetT(numW:Number,numH:Number,_mc:MovieClip){
 _mc._y=0;
 _mc._x=numW/2-_mc._width/2;
}
//设置右
functionsetR(numW:Number,numH:Number,_mc:MovieClip){
 _mc._x=numW-_mc._width;
 _mc._y=(numH-_mc._height)/2;
}
//设置下
functionsetD(numW:Number,numH:Number,_mc:MovieClip){
 _mc._x=(numW-_mc._width)/2;
 _mc._y=numH-_mc._height;
}
//设置中
functionsetC(numW:Number,numH:Number,_mc:MovieClip){
 _mc._x=(numW-_mc._width)/2;
 _mc._y=(numH-_mc._height)/2;
}
}

Tags:实现 flash 整个

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接