I have many SWF file those I have included in my web page using the HTML Object tag. Its working fine but, I am not able to maintain the size of my SWF files. I have following code for SWF files.

我有许多SWF文件,我使用HTML Object标签包含在我的网页中。它的工作正常但是,我无法维护我的SWF文件的大小。我有以下SWF文件的代码。

<object id="example_flashGame" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="600" height="400">
        <param name="movie" value="/video/swf/fun/funny-baby.swf" />
        <param name="allowScriptAccess" value="always" />
        <param name="loop" value="false" />
        <param name="menu" value="false" />
        <param name="quality" value="high" />
        <param name="wmode" value="window" />

        <embed name="example_flashGame" src="/video/swf/fun/funny-baby.swf" width="600" height="400" allowScriptAccess="always" loop="false" menu="false" quality="high"  wmode="window" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
 </object>

Currently the size (width and height) of the SWF file is fixed in the object tag in above code. I want when size exceeds from a certain range then constant size will be applied to the file else, file will be displayed in its original size.

目前,SWF文件的大小(宽度和高度)在上面的代码中的object标签中是固定的。我希望当大小超过某个范围,然后将恒定大小应用于其他文件,文件将以其原始大小显示。

If there is a file whose size is less than what I have given in object tag then, the SWF file graphics are distorted and its not looking well.

如果有一个文件的大小小于我在object标签中给出的大小,则SWF文件图形会失真并且看起来不太好。

Can anyone please tell me how can I make the size of SWF files auto if the file size is less than 600x400 if the size exceeds 600x400 then this size will apply, else file should display in its original size.

任何人都可以告诉我,如果文件大小小于600x400,如果文件大小小于600x400,我怎么能自动调整SWF文件的大小,然后这个大小将适用,否则文件应该以其原始大小显示。

I have seen some gaming sites (such as miniclip.com) do exactly the same thing, they display the original size of there games (small or large) on play page, do they maintain there files hight and width in DB tables or something else?

我看过一些游戏网站(比如miniclip.com)做同样的事情,他们在播放页面上显示游戏(小或大)的原始大小,他们是否在数据库表或其他东西中维护文件的高度和宽度?

Is there any way to do this in HTML or using JQuery or javascript??

有没有办法在HTML中或使用JQuery或javascript?

1 个解决方案

#1


There's no way to simply detect the size of Flash stage from JS. You'd better call a JS function from inside Flash to set the stage size.

没有办法简单地从JS中检测Flash阶段的大小。你最好从Flash里面调用JS函数来设置舞台大小。

So, you'll have to put this code in the Flash movie (AS2):

所以,你必须把这段代码放在Flash电影(AS2)中:

import flash.external.ExternalInterface;
ExternalInterface.call("resizeFlash", Stage.width, Stage.height);

Then in the HTML page you'd have the JS function that resizes the Flash element:

然后在HTML页面中,您将拥有调整Flash元素大小的JS函数:

var max_flash_width = 800;
var max_flash_height = 600;

function resizeFlash(w, h)
{
    // force the w and h to be within limits set above
    w = Math.min(w, max_flash_width);
    h = Math.min(h, max_flash_height);
    // then resize the flash element using w and h
    var flash_elem = document.getElementById("example_flashGame");
    flash_elem.width = w;
    flash_elem.height = h;
    if (navigator.userAgent.toLowerCase().indexOf("safari") !=- 1) {
        var flash_elem = document.getElementById("example_flashGame");
        flash_elem.width = w;
        flash_elem.height = h;
    }
}

更多相关文章

  1. 如何使用jquery或JavaScript在一次浏览中上传多个文件
  2. python (9)统计文件夹下的所有文件夹数目、统计文件夹下所有文件数
  3. struts2结合swfupload控件实现视频等大文件上传
  4. 当函数在单独的PHP文件中定义时,调用JavaScript函数onclick按钮事
  5. 使用Python写HTML 文件使用jinja2中的模板
  6. Python读取修改ini配置文件[ConfigParser]
  7. 用户输入从.csv文件生成新列表?
  8. Python文件操作大全,随机删除文件夹内的任意文件
  9. 当使用一个传送到另一个的python文件时,我可以将stdin与argv结合

随机推荐

  1. MSM7627的内存分布图
  2. Android如何缩放应用中的字体大小
  3. 【Android】intent-filter里data匹配分析
  4. [置顶] android MultiDex multide
  5. 通过ViewPager实现类似微信的页面切换(Fra
  6. android获取本地视频路径
  7. Android-SDK-Manager 不能更新最有效的解
  8. eclipse中修改工程的Android版本
  9. public static final int a;static和final
  10. 昨天花了两个小时做了一个天气预报的Demo