如何使用 .js 将 .swf 调整为全屏
我的应用程序是在 Flash Builder 中构建的。我想在 HTML 页面中嵌入一个小型 Flash 登录表单。登录表单处于代码的“登录”状态,宽/高为几百像素。 “默认”状态设置为 100% 的高度和宽度。我有一个调整大小函数,一旦登录收到适当的凭据就会执行该函数。
private function resizeApplication():void {
if(ExternalInterface.available) {
ExternalInterface.call("resizeApplication");
}
调整大小的 JavaScript 是这样的:
function resizeApplication() {
var app = document.getElementById('app');
app.style.height = '100%';
app.style.width = '100%';
app.style.left = '0';
app.style.top = '0';}
#app
是 div,溢出在正文中设置为 auto。这工作得很好,除了我在底部附近留下了网页的一些可见部分。我希望能够调整网页大小以匹配 swf 或隐藏除 swf 之外的所有内容。我尝试了一些不同的 js 操作,包括将 Bottom 属性设置为 0 并使用 document.body.clientHeight
的变体。
My application is built in Flash Builder. I want to embed a small Flash login form inside an HTML page. The login form is in the 'login' state of code and is a few hundred pizxels wide/ tall. The 'default' state is set to height and width of 100%. I have a resize function that is executed once the login receives the appropriate credentials.
private function resizeApplication():void {
if(ExternalInterface.available) {
ExternalInterface.call("resizeApplication");
}
The javascript that does the resizing is this:
function resizeApplication() {
var app = document.getElementById('app');
app.style.height = '100%';
app.style.width = '100%';
app.style.left = '0';
app.style.top = '0';}
#app
is the div and overflow is set to auto in the body. This works just fine except that I am left with some visable portion of the webpage near the bottom. I want to be able to either resize the webpage to match the swf or hide everything except the swf. I have tried a few different things with the js including setting the bottom attribute to 0 and using variations of the document.body.clientHeight
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您不能将其设为“全屏”,但可以使其填满浏览器。
首先,应用程序元素应该将位置样式预设为固定或绝对(取决于您的页面),因为从脚本中设置它会重新加载 Flash 对象。
如果位置固定,则使用此方法:
这可以绝对找出视口的位置及其大小,然后移动应用程序元素并调整其大小。
http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html
无论哪种方式都不会'如果您只是通过 ActipnScript 将 Flash 全屏显示,对您来说不是更容易吗?
You can't make it "Full Screen" but you can make it fill the browser.
First the app element should have the position style pre-set to either fixed or absolute(depending on your page) since setting it from the script will reload the flash object.
And then use this one if the position is fixed:
And this for absolute find out the position of the viewport and it's size and just move and resize your app element.
http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html
Either way wouldn't it be a lot easier for you if you just made the flash fullscreen from ActipnScript?
您必须手动设置 div 的高度才能始终获得您想要的效果。这与使背景图像始终填满屏幕的技巧相同。
像这样的东西:
You have to set the height of the div manually to consistently get the effect you are looking for. This is the same trick used to make a background image always fill the screen.
Something like this:
为什么不直接使用进入真正的全屏模式
Why not simply enter real full screen mode using