如何使用 .js 将 .swf 调整为全屏

发布于 2024-12-05 13:27:34 字数 768 浏览 1 评论 0原文

我的应用程序是在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

北城挽邺 2024-12-12 13:27:34

您不能将其设为“全屏”,但可以使其填满浏览器。
首先,应用程序元素应该将位置样式预设为固定或绝对(取决于您的页面),因为从脚本中设置它会重新加载 Flash 对象。

如果位置固定,则使用此方法:

app.style.top = '0';
app.style.left = '0px';
app.style.top = '0px';
app.style.right = '0px';
app.style.bottom = '0px';

这可以绝对找出视口的位置及其大小,然后移动应用程序元素并调整其大小。

http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html

无论哪种方式都不会'如果您只是通过 ActipnScript 将 Flash 全屏显示,对您来说不是更容易吗?

fscommand("fullscreen", "true"); // ActionScript 2
stage.displayState = StageDisplayState.FULL_SCREEN; // ActionScript 3

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:

app.style.top = '0';
app.style.left = '0px';
app.style.top = '0px';
app.style.right = '0px';
app.style.bottom = '0px';

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?

fscommand("fullscreen", "true"); // ActionScript 2
stage.displayState = StageDisplayState.FULL_SCREEN; // ActionScript 3
全部不再 2024-12-12 13:27:34

您必须手动设置 div 的高度才能始终获得您想要的效果。这与使背景图像始终填满屏幕的技巧相同。

像这样的东西:

function resizeMain(){
$("#wrapper").height(window.innerHeight);
$("#background").height(window.innerHeight);
$("#background").width(window.innerWidth);
}
window.onresize = resizeMain;
$(document).ready(function(){resizeMain();});

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:

function resizeMain(){
$("#wrapper").height(window.innerHeight);
$("#background").height(window.innerHeight);
$("#background").width(window.innerWidth);
}
window.onresize = resizeMain;
$(document).ready(function(){resizeMain();});
执妄 2024-12-12 13:27:34

为什么不直接使用进入真正的全屏模式

StageDisplayState.FULL_SCREEN 

Why not simply enter real full screen mode using

StageDisplayState.FULL_SCREEN 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文