Flash AS2 影片中启用滚动 HTML 的动态文本字段中的可点击链接 - 适用于 Flash Pro,不适用于浏览器

发布于 2024-10-07 17:16:24 字数 587 浏览 1 评论 0原文

我使用 Actionscript 2 在 Flash 中开发了一个滚动片尾风格的影片剪辑。文本从 XML 文件加载并解析到动态文本字段中。该文本包括指向由 xml 中的 url 节点定义的网页的超链接,以便 Flash 可以将适当的 a href 添加到动态文本字段并使链接可单击。

在我第一次尝试执行此操作时,文本字段保持静止,并且所有链接都工作正常,无论是在本地测试还是在我的网站上的浏览器中运行它时。

然后我想让事情移动......我很容易实现并在本地进行测试(在 Flash Professional 中)并且链接仍然可点击,浏览器窗口打开并且我期望看到打开的网页......很棒

但是,当我导出 swf、上传它并从我的网站运行它,突然链接不起作用。所以我尝试在 Flash Pro 的浏览器中测试电影 - 同样的问题,它一定与 Flash Player 和移动的动态文本字段有关。

一些观察结果-当您在链接上时,光标将变为手形图标,正如您所期望的那样,如果我右键单击链接并单击在新窗口中打开,则链接可以正常工作,只是当我左键单击时则不行。如果我停止滚动,则链接再次可单击,只有当文本字段移动时......实际上它在技术上不是滚动,我正在移动整个文本字段。

有什么想法吗?

I have developed a rolling credits style movieclip in Flash using Actionscript 2. Text is loaded from an XML file and parsed into a dynamic textfield. This text includes hyperlinks to webpages defined by a url node in the xml so Flash can add the appropriate a href to the dynamic text field and make the link clickable.

In my first attempts to do this the textfield stayed still and all the links worked fine both testing locally and when I run it in a browser on my website.

Then I wanted to make things move ... which I achieved easily enough and tested locally (from within Flash Professional) and the links remained clickable, a browser window opened and the webpage i was expecting to see opened... great

However, when I export the swf, upload it and run it from my website suddenly the links are not working. So I tried to test the movie in a browser from Flash Pro - same problem, it must be something to do with Flash Player and the moving dynamic textfield.

a couple of observations - the cursor will change to a hand icon when over the links as you would expect, and if I right click on the link and click open in a new window the link works ok, just not when I left click. If I stop the scrolling then the links become clickable again, it is only when the textfield is moving... actually its not technically scrolling, im moving the whole textfield.

Any ideas?

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

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

发布评论

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

评论(1

风柔一江水 2024-10-14 17:16:24

我建议不要使用动态文本字段的 href 属性,而是将文本字段包装为 MovieClip,然后使用 MovieClips onRelease() 方法。

您可以将 xml 中的文本加载到包装的文本字段中,并将关联的链接 url 加载到数组中。下面假设您有一个链接库元件,它是一个带有动态文本字段的影片剪辑。 textField 的实例名称是tf。库链接 ID 为 myListItem,保存列表的容器 ID 为 myListContainernextY 变量用于将每个链接放置在最后一个链接的下方,listItemSpacing 变量是每个列表项之间的间距像素数。

免责声明 - 这是伪代码的一部分 - 我在没有实际编译的情况下将其全部输入,因此可能存在拼写错误或 as2/3 语法错误,但它应该让您朝着正确的方向前进

var listContainer = myListContainer;
var xmlList = theXmlYouHaveParsed;
var urlArray = new Array();
var nextY = 0;
var listItemSpacing = 5;
var thisInstance = this;

for(i=0; i < theXmlYouHaveParsed.length; i++)
{
     var mc = listContainer.attachMovieClip("myListItem", i+1);
     mc._y = nextY;

     mc.tf.htmlText = theXmlYouHaveParsed[i].someText;
     mc.id = String(i);

     urlArray.push(theXmlYouHaveParsed[i].someUrl);

     mc.onRelease = function()
     {
         thisInstance.onLinkClicked(this.id);
     }

     nextY += mc._height + listItemSpacing;
}

function onLinkClicked(id)
{
     getURL(urlArray[id]);
}

Rather than using the href property of the dynamic textField, I would suggest wrapping the textFields as MovieClips and then using the MovieClips onRelease() method.

You could load your text from your xml into the wrapped textFields, and load the associated link urls into an array. Below presumes you have a linked library symbol that is a movieclip with a dynamic textField in it. The textField's instance name is tf. The library link ID is myListItem, the ID of the container to hold the list is myListContainer. The nextY variable is for placing each link below the last, and the listItemSpacing variable is how many pixels of spacing between each list item.

DISCLAIMER - THIS IS PART PSEUDO CODE - I typed this all out without actually compiling it, so there may be typos or as2/3 syntax goofs, but it should get you going in the right direction

var listContainer = myListContainer;
var xmlList = theXmlYouHaveParsed;
var urlArray = new Array();
var nextY = 0;
var listItemSpacing = 5;
var thisInstance = this;

for(i=0; i < theXmlYouHaveParsed.length; i++)
{
     var mc = listContainer.attachMovieClip("myListItem", i+1);
     mc._y = nextY;

     mc.tf.htmlText = theXmlYouHaveParsed[i].someText;
     mc.id = String(i);

     urlArray.push(theXmlYouHaveParsed[i].someUrl);

     mc.onRelease = function()
     {
         thisInstance.onLinkClicked(this.id);
     }

     nextY += mc._height + listItemSpacing;
}

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