swfobject 奇怪的行为 [英] swfobject weird behavior

查看:24
本文介绍了swfobject 奇怪的行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 swfobject 嵌入我的 Flash.它在做奇怪的事情.

I'm using swfobject to embed my flash. It's doing weird things.

我使用 FlexBuilder 创建了一个简单的文本字段.这是一个 AS3 项目,它扩展了 Sprite.我将其宽度设置为 640,高度设置为 450.然后,在页面的 swfobject 参数中,我还设置了 640 x 450.我将背景设置为漂亮、红色和丑陋,以便您可以看到它.:)

I've created a simple textfield using FlexBuilder. It's an AS3 project, which extends Sprite. I've set its width to be 640 and height to 450. Then, in the swfobject parameters of the page, I've also set 640 x 450. I've made the background nice and red and ugly so you can see it. :)

http://www.brighttext.com/flash/TextFieldSetFormat.html

这似乎是正确的尺寸.但是我有一个文本字段,它的大小和高度应该几乎相同.这在 FlexBuilder 中运行良好(大小合适)但是一旦我添加了 swfobject 就全部搞砸了有人能看到发生了什么吗?

It seems to be the right dimensions. BUT I've got a textfield which is supposed to be almost the same size and height. This runs fine in FlexBuilder (is the right size) but is all messed up once I add swfobject Can anyone see what is happening?

编辑注意:我只是看着它,它看起来不错.但后来我刷新了页面,文本字段是邮票大小(再次 - 这是我看到的原始行为.)它现在在 firefox 中看起来不错,但在 IE8 中不行.Flash 应该在所有浏览器中看起来都一样!??

EDIT NOTE: I just looked at it and it looks ok. But then I refreshed the page and the textfield is postage-stamp size (again -- this is the original behavior I saw.) It's now looking OK in firefox but not in IE8. Flash is supposed to look the same in all browsers !!??

AS3 代码:

package {
 import flash.display.Sprite;
 import flash.text.TextField;
 import flash.text.TextFormat;
 import flash.text.Font;

[SWF(width="640", height="450", backgroundColor="#FFFFFF", frameRate="30")]
public class TextFieldSetFormat extends Sprite
{
    [Embed(source='C:/WINDOWS/Fonts/ArialBD.TTF',  fontWeight = 'bold', fontName='ArialBold')]

    [Embed(source='C:/WINDOWS/Fonts/Arial.TTF', fontWeight = 'regular', fontName='Arial')]

    public function TextFieldSetFormat()
    {
        var tf2:TextFormat = new TextFormat();
        tf2.size = 16;
        tf2.font = "Arial";
        Font.registerFont(_VerdanaFontBold);
        Font.registerFont(_VerdanaFont);
        var pad:Number = 10;
        var brightTextField:TextField = new TextField;
        brightTextField.backgroundColor = 0xDDF3B2;
        brightTextField.background = true;
        brightTextField.embedFonts = true;
        brightTextField.border = true;
        brightTextField.defaultTextFormat = tf2;
        brightTextField.wordWrap = true;
        brightTextField.multiline = true;
        brightTextField.width = stage.stageWidth - (4 * pad);
        brightTextField.height = stage.stageHeight - (3 * pad);
        brightTextField.x = 2*pad;
        brightTextField.y = 2*pad;

        brightTextField.text = "Dear Senators, I have become concerned over the idea that some in the Senate will oppose the public option because of a group of wild-eyed, overbearing but misinformed ideologues. These people mistakenly equate insurance reform with Socialism and call our  first African-American President unprintable epithets. This is unacceptable. The public option is the choice of more than 70% of Americans, a majority of the House and a great many opinion leaders. Passing insurance reform without a public option persists the current broken system. I am aware that many Senators would prefer to pass a reform bill with bipartisan support. But we cannot allow this critical debate to be hijacked by extremists or corporate profiteers. Thank you, and I look forward to hearing from you.";
        addChild(brightTextField);
    }
}
} 

推荐答案

好的,我已经想通了.

问题在于使用 stage.stageWidth 和 stage.stageHeight.我还不确定为什么会这样,但本着敏捷开发的精神,这是一个修复.:)

The problem is in using stage.stageWidth and stage.stageHeight. I'm not yet sure why this is so, but in the spirit of agile development, it's a fix. :)

不要使用 stage.stageWidth,只需使用多个像素.(640 x 450,就我而言).然后问题就迎刃而解了.

Instead of using stage.stageWidth, just use a number of pixels. (640 x 450, in my case). The problem then goes away.

我将很快在我的博客上发布更多相关信息——包括我拍摄的屏幕截图和我所做的测试,并将在此处发布链接.

I'll post more about this -- including screenshots I took, and tests I did, soon on my blog and will post a link here.

这篇关于swfobject 奇怪的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆