在 htmlText <img> 中使用库中的符号ActionScript 3 中的标记 [英] Using symbol from library in htmlText <img> tag in ActionScript 3

查看:21
本文介绍了在 htmlText <img> 中使用库中的符号ActionScript 3 中的标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题是这样的:我需要使用 img 标签将图像添加到 textField,但我无法从我的 swf 文件中的库中引用符号.

Problem is this: I need to add image to textField using img tag, but I cannot reference a symbol from a library in my swf file.

txt.htmlText =  "test <img src='symbol1' height='10' width='10' align='right'/>";

此符号的 AS 链接是符号 1,我尝试将此 swf 嵌入到我的类中,但它总是出现错误 #2035 - 未找到 URL

AS linkage for this symbol is symbol1 and i tried embedding this swf in my class but it always gives error #2035 - URL not found

Adobe 说 img 标签接受库符号,但我找不到任何例子证明这是真的.

Adobe says that img tag accepts a library symbol, but I couldn't find any example where this is true.

任何帮助将不胜感激.

推荐答案

我已经有一段时间没有这样做了,但我认为您需要在库中创建一个带有位图的影片剪辑,然后将其导出到 ActionScript,然后将其添加为标签中的链接.

It's a while since I did this but I think you need to create a movie clip in the library with the bitmap inside it, then export that for ActionScript, then add that as the linkage in the tag.

因此,如果您的电影剪辑导出为myImage_mc",您的 html 将是:

So, if your movieClip is exported as 'myImage_mc", your html will be:

<img src="myImage_mc" width="100" height ="100"/>

更新.

澄清一下,这是我在库中的符号:

To clarify, here's my symbol in the library:

这是我的动作脚本:

import flash.text.TextField;

var textField:TextField = new TextField();
textField.htmlText = "<p>HKP</p><img src='HKP'/>";
textField.x = textField.y = 100;
stage.addChild(textField);

这是结果(诚然需要一些调整):

And here's the result (which admittedly needs a bit of tweaking):

注意:如果 img 是该字段中的唯一标签,这似乎不起作用.您必须添加一些文本,即使它不可见.空的 P 不起作用,因此其中任何一个都会失败:

textField.htmlText = "<img src='HKP'/>";
textField.htmlText = "<p></p><img src='HKP'/>";

...但这有效:

textField.htmlText = "<p> </p><img src='HKP'/>";

...这几乎是一个经典的 Adob​​e 陷阱 ;)

... which is pretty much a classic Adobe gotcha ;)

这篇关于在 htmlText &lt;img&gt; 中使用库中的符号ActionScript 3 中的标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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