0

我正在使用 swfobject 嵌入我的闪存。它在做奇怪的事情。

我使用 FlexBuilder 创建了一个简单的文本字段。这是一个扩展 Sprite 的 AS3 项目。我将其宽度设置为 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);
    }
}
} 
4

2 回答 2

0

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

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

于 2009-11-20T19:21:08.643 回答
0

好的,好吧,我已经想通了。

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

而不是使用stage.stageWidth,只使用一些像素。(在我的情况下为 640 x 450)。然后问题就消失了。

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

于 2009-12-11T22:50:48.103 回答