SWFObject的怪异行为 [英] swfobject weird behavior

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

问题描述

我使用SWFObject嵌入我的Flash。它做奇怪的事情。

我已经使用弹性创建一个简单的文本框。这是一个AS3的项目,它扩展了雪碧。我已经设置其宽度为640和高度为450。然后,在网页的SWFObject的参数,我还设置640×450。我做了很好的背景和红色的丑,所以你可以看到它。 :)

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

这似乎是正确的尺寸。但我有一个文本框它应该是几乎相同的尺寸和高度。这运行正常的弹性生成器(是正确的大小),但是全乱了,一旦我添加SWFObject的任何人都可以看到发生了什么事?

编辑注:我只是看着它,它看起来OK。但后来我刷新页面,文本字段是邮票大小(再次 - 这是我看到原来的行为),它现在希望在Firefox,而不是在IE8确定。闪光灯应该看起来一样在所有浏览器!! ??

AS3 code:

 包{
 进口flash.display.Sprite;
 进口API元素flash.text.TextField;
 进口flash.text.TextFormat用于;
 进口flash.text.Font;

[SWF(宽度=640,高度=450,的backgroundColor =#FFFFFF,帧率=30)]
公共类TextFieldSetFormat扩展Sprite
{
[嵌入(来源=C:/WINDOWS/Fonts/ArialBD.TTF',fontWeight设置='大胆',的fontName ='ArialBold')]

[嵌入(来源=C:/WINDOWS/Fonts/Arial.TTF',的fontWeight =常规,的fontName ='宋体')]

公共职能TextFieldSetFormat()
{
VAR TF2:的TextFormat =新的TextFormat();
tf2.size = 16;
        tf2.font =宋体;
Font.registerFont(_VerdanaFontBold);
        Font.registerFont(_VerdanaFont);
        VAR垫:数= 10;
VAR brightTextField:文本字段=新的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 *垫);
        brightTextField.height = stage.stageHeight  - (3 *垫);
        brightTextField.x = 2 *垫;
        brightTextField.y = 2 *垫;

        brightTextField.text =亲爱的参议员,我已经成为关切的想法,一些在参议院会反对,因为一组怒目而视,霸道而误导理论家的公共选择。这些人错误地等同于保险改革与社会主义相适应,并呼吁我们第一位非洲裔president无法打印的口号,这是不可接受的。公共选择是美国人的70%以上,大部分房子和许多意见领袖的选择;通过保险改革没有一个公共选择仍然存在目前的破碎系统。据我所知,许多参议员将preFER通过与两党的支持改革法案。但是,我们不能让这个关键的辩论极端主义分子或组织的奸商被劫持。谢谢你,我期待着听到您。;
        的addChild(brightTextField);
}
}
}
 

解决方案

好了,好了,我已经想通了这一点。

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

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

我会后更多关于这一点 - 包括截图我拿来,测试我做了,很快我的博客上,并将在此处张贴链接

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

解决方案

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.

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

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