2009-11-20 76 views
0

我正在使用swfobject嵌入我的闪存。这是奇怪的事情。swfobject怪异行为

我已经使用FlexBuilder创建了一个简单的文本字段。这是一个AS3项目,它扩展了Sprite。我已经将它的宽度设置为640,高度设置为450.然后,在页面的swfobject参数中,我也设置了640 x 450.我使背景变得好看又红又丑,这样你就可以看到它。 :)

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

这似乎是正确的尺寸。但是我有一个应该几乎相同大小和高度的文本框。这在FlexBuilder中运行正常(是正确的大小),但一旦我添加swfobject都搞砸了任何人都可以看到发生了什么?

编辑注:我只是看着它,它看起来没问题。但后来我刷新了页面,文本字段是邮票大小(再次 - 这是我看到的原始行为。)现在,在Firefox中查看OK,但在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); 
    } 
} 
} 

回答

0

好吧,我想到了这一点。

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

而不是使用stage.stageWidth,只需使用多个像素。 (在我的情况下是640 x 450)。问题就消失了。

我会在我的博客上发布更多关于此内容的信息 - 包括我拍摄的截图以及测试过的内容,并会在此发布链接。

0

尝试跟踪stage.stageWidth /身高的价值和使用像Flash示踪插件,看看它的输出。

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

+0

谢谢亚历克斯。不幸的是我找不到flashlog.txt,所以一直无法使Flash Tracer工作。 – David 2009-11-21 14:39:22

+0

试试这个:http://kb2.adobe.com/cps/193/tn_19323.html – 2009-11-23 14:37:56