as3文本换行问题,firefox,mac

发布于 2024-12-08 08:44:38 字数 2491 浏览 2 评论 0原文

因此,我为客户建立了一个小网站,这对我来说似乎没有任何问题。我发布了它,我的客户向我报告说,文本字段中的一些文本被剪掉了。我尝试使用 Chrome 和 Firefox 在我的电脑上重现该问题,但一切正常。但他用 Firefox 给我发了他的 mac 屏幕截图,果然它们被剪掉了。他声称这是唯一的火狐,而且它与窗户尺寸无关。所以这里是显示发生了什么的图像:

text-wrap Problem example

最右边的单词应该是“Alabama”& ; “增长”

,这里是生成该文本的代码(descTextNew 是这里的罪魁祸首):

        nameText.text = names[elementNumber];
        nameText.autoSize = "center";
        nameText.x = object.x + (.5 * videoWidth) - (.5 * nameText.width);
        nameText.y = object.y + videoHeight + 8;
        nameText.background = true;
        nameText.backgroundColor = 0x000000;
        textStyling.color = 0xFFFFFF;
        textStyling.size = 20;
        textStyling.font = myFont.fontName;
        textStyling.letterSpacing = 3;
        textStyling.align = "center";
        nameText.embedFonts = true;
        nameText.setTextFormat(textStyling);
        container.addChild(nameText);

        descTextNew.text = descArrayContent[elementNumber];
        descTextNew.y = object.y + videoHeight + nameText.textHeight + margin - 15;
        descTextNew.width = nameText.textWidth + 30;
        descTextNew.x = object.x + ( (videoWidth - descTextNew.width) / 2 );
        descTextNew.wordWrap = true;
        descTextNew.autoSize = "left";
        descTextNew.background = true;
        descTextNew.backgroundColor = 0x000000;
        descTextStyling.color = 0xFFFFFF;
        descTextStyling.size = Math.round(11 * 1000/stage.stageWidth);
        descTextStyling.font = myFont.fontName;
        descTextStyling.letterSpacing = .5;
        descTextStyling.align = "left";
        descTextNew.setTextFormat(descTextStyling);
        container.addChild(descTextNew);

其中一些变量被声明为实例变量,如下所示:

    var names:Array = new Array();
    var nameText:TextField = new TextField();
    var textStyling:TextFormat = new TextFormat();
    var descTextNew:TextField = new TextField();
    var descTextStyling:TextFormat = new TextFormat();
    var margin:int = 28;
    var videoWidth:int = 267;
    var videoHeight:int = 150;

数组 namesdescArrayContent 具有字符串“Paul Rollins, Sr.”并在由变量 elementNumber 确定的索引号处添加到它们。另外,object 是您在图片中看到的图像。认为没有必要向您展示该代码。

如果您想查看实际效果,请点击以下链接:

www.footsoldiers.org/test2/

任何想法到底是怎么回事?我不知道从哪里开始。

So, I've built a little site for a client that doesn't seem to have any problems for me. I post it, and my client reports to me that some of the text is being clipped off in the text fields. I try to recreate the problem on my pc with chrome and firefox, but everything works fine. But he sends me screenshots from his mac with firefox, and sure enough they are being clipped. He claims its only fire-fox, and it is not a factor of window size. so here are the images to show whats going on:

text-wrap problem example

Further most right words should be "Alabama" & "growing"

and here is the code that produces that text (descTextNew is the culprit here):

        nameText.text = names[elementNumber];
        nameText.autoSize = "center";
        nameText.x = object.x + (.5 * videoWidth) - (.5 * nameText.width);
        nameText.y = object.y + videoHeight + 8;
        nameText.background = true;
        nameText.backgroundColor = 0x000000;
        textStyling.color = 0xFFFFFF;
        textStyling.size = 20;
        textStyling.font = myFont.fontName;
        textStyling.letterSpacing = 3;
        textStyling.align = "center";
        nameText.embedFonts = true;
        nameText.setTextFormat(textStyling);
        container.addChild(nameText);

        descTextNew.text = descArrayContent[elementNumber];
        descTextNew.y = object.y + videoHeight + nameText.textHeight + margin - 15;
        descTextNew.width = nameText.textWidth + 30;
        descTextNew.x = object.x + ( (videoWidth - descTextNew.width) / 2 );
        descTextNew.wordWrap = true;
        descTextNew.autoSize = "left";
        descTextNew.background = true;
        descTextNew.backgroundColor = 0x000000;
        descTextStyling.color = 0xFFFFFF;
        descTextStyling.size = Math.round(11 * 1000/stage.stageWidth);
        descTextStyling.font = myFont.fontName;
        descTextStyling.letterSpacing = .5;
        descTextStyling.align = "left";
        descTextNew.setTextFormat(descTextStyling);
        container.addChild(descTextNew);

Some of these variables are declared as instance variables prior like this:

    var names:Array = new Array();
    var nameText:TextField = new TextField();
    var textStyling:TextFormat = new TextFormat();
    var descTextNew:TextField = new TextField();
    var descTextStyling:TextFormat = new TextFormat();
    var margin:int = 28;
    var videoWidth:int = 267;
    var videoHeight:int = 150;

arrays names and descArrayContent have the strings "Paul Rollins, Sr." and "Paul Rollins runs a funeral... " added to them at an index number determined by the variable elementNumber. Also object is the image you see in the pic. don't think its necessary to show you that code.

Here's a link if you want to see it in action:

www.footsoldiers.org/test2/

Any ideas what the hell is going on? I don't know where to start.

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

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

发布评论

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

评论(2

往昔成烟 2024-12-15 08:44:39

您是否尝试过手动使重绘控件无效?

this.invalidateDisplayList();
this.invalidateLayering();
this.invalidateLayoutDirection();
this.invalidateProperties();
this.invalidateSize();

Have you tried invalidating the control for redraw manually?

this.invalidateDisplayList();
this.invalidateLayering();
this.invalidateLayoutDirection();
this.invalidateProperties();
this.invalidateSize();
鱼忆七猫命九 2024-12-15 08:44:39

在设置所有其他属性后,我会尝试设置 .text 属性。
因此,尝试将 descTextNew.text = descArrayContent[elementNumber] 操作放在最后一行。

如果这仍然不能解决您的问题,我建议还包括 descTextNew.multiline = true 财产。

祝你好运!

I would try to set the .text property after you have set all the other properties.
So try putting the descTextNew.text = descArrayContent[elementNumber] action on the last line.

If this still doesn't fix your problem, I would recommend to also include the descTextNew.multiline = true property.

Good luck!

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