swfobject 奇怪的行为

发布于 2024-08-12 07:44:09 字数 2749 浏览 3 评论 0原文

我正在使用 swfobject 来嵌入我的 Flash。它正在做一些奇怪的事情。

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

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

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

编辑注:我刚刚看了看,看起来还不错。但后来我刷新了页面,文本字段变成了邮票大小(再次——这是我看到的原始行为。)现在在 Firefox 中看起来不错,但在 IE8 中则不然。 Flash 在所有浏览器中看起来应该都是一样的!!!?

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);
    }
}
} 

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

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

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?

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 code:

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);
    }
}
} 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

森林迷了鹿 2024-08-19 07:44:09

尝试跟踪 stage.stageWidth/Height 的值并使用 Flash Tracer 等插件来查看其输出。

您可能只需要为 Event.ADDED_TO_STAGE/INIT 添加一个事件侦听器,并在该侦听器中执行您的设置代码。

Try tracing the value of stage.stageWidth/Height and use a plugin like Flash Tracer to see what its outputting.

You might just need to add an event listener for Event.ADDED_TO_STAGE/INIT and execute your setup code within that listener.

今天小雨转甜 2024-08-19 07:44:09

好吧,我已经弄清楚了。

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

不使用 stage.stageWidth,而是使用像素数。 (在我的例子中为 640 x 450)。然后问题就消失了。

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

OK, well, I've figured this out.

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. :)

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.

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