1

我在 Edge Animate 中创建了一个符号,其中包含一个矩形作为视图区域以及一个图像和文本作为该视图区域的内容。我想在开始符号的动画之前设置文本和图像 src。所以当点击某个区域时,我可以设置“文本”

var thing = sym.getSymbol("mySymbol");
thing.$("Text").html("I can set some text here to change the content of Text.");

现在的问题是,如何在该符号中设置“图像”项的图像源。我查看了 Edge Animate 创建的文件,上面显示的文本位于名为“text”的字段中,而图像名称与其他信息包含在名为“fill”的字段中。我不知道如何设置图像源。任何指针?

提前致谢

M。

4

2 回答 2

1

Here's a solid solution, which I've been working out over the past few hours.


General

The first step is to get a reference to the element, for example, if the element is named "MyTextBox", you would address it like this:

$(sym.lookupSelector("MyTextBox"));

Dynamically Changing Text

To do this, you can set the HTML property for the referenced element:

$(sym.lookupSelector("MyTextBox")).html("Hello World");

Dynamically Changing Images

Images are implemented by using the background-image CSS property of a DIV. If you had an image element named MyImageBox, the syntax would be:

$(sym.lookupSelector("MyImageBox")).css('background-image', [image]);

There's a second part, which is getting the [image] reference correct.

  • If it's in the default Edge images directory, use the relative URL: images/MyNewImage.png
  • Use standard syntax for CSS background-image: url(images/MyNewImage.png)
于 2013-05-20T05:50:06.153 回答
0

一种方法可能是附加一个 img 标签并定义其来源。

例如:

$('<img src="mypic.png">').appendTo($('Text'));

将“ mypic.png”替换为您要使用的图像的路径。

希望这可以帮助。

于 2013-03-01T20:05:22.900 回答