说起来真是惭愧,学习flash都三四年了,flash在网页中全屏的问题一直都没有得到比较好的解决。今天在看js方面的书籍,flash始终是镶嵌于网页中的插件,与浏览器有着相依为命的关系。所以有些效果是需要与浏览器配合实现的。比如全屏。
as:
import flash.text.TextField;
import flash.events.Event;
import flash.display.StageScaleMode;
import flash.display.StageAlign;
stage.scaleMode=StageScaleMode.EXACT_FIT;//如果不想舞台元素有所改变可以设置为showall
//stage.align=StageAlign.LEFT;
var text:TextField=new TextField();
text.autoSize="left";
addChild(text);
text.text="mengtianwxs";
text.appendText("\n"+this.root.loaderInfo.parameters._width+"\n");
text.appendText(""+this.root.loaderInfo.parameters._height);
var w:int=(int)(this.root.loaderInfo.parameters._width);
var h:int=(int)(this.root.loaderInfo.parameters._height);
this.loaderInfo.addEventListener(Event.COMPLETE,onComplete);
function onComplete(e:Event=null):void
{
this.loaderInfo.removeEventListener(Event.COMPLETE,onComplete);
text.appendText("\nrun here");
}
html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
body{
margin:auto 0;
padding:0;}
</style>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
function getData(){
var sw=window.innerWidth;
var sh=window.innerHeight;
var flashvars = {_width:sw,_height:sh};
swfobject.embedSWF("test.swf", "content", "550", "400", "10.0.0", "expressInstall.swf", flashvars);
function getFlash(){
return document.getElementById("content");
}
var fl=getFlash();
fl.style.width=sw+'px';
fl.style.height=sh+'px';
}
function onl oads(){
getData();
}
function onresize(){
getData();
}
</script>
</head>
<body οnlοad="onloads();" οnresize="onresize();">
<div id="content"></div>
</body>
</html>