0

我是 AS3 的新手,我想用 flash 打开多个浏览器选项卡。

我试图简单地启动多个navigateToURL() 实例。

for each (var str:String in arrayofrequests) 
{
[...]
    try { navigateToURL(request, "_blank");}
[...]
}

但只有最后一个 navigateToURL 实例会在浏览器中执行。我在网上搜索,有人指出 callLater 可以解决这个问题。但是每次我尝试使用 callLater 我都会得到

 Error: Call to a possibly undefined method callLater.

我在这里分析了 adobe 文档:http: //help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7b06.html

所有从 UIComponent 类继承的对象都可以打开 callLater() 方法。

我该怎么做?我试图将我的代码更改为这样的

public class Main extends UIComponent

但它不起作用。

4

1 回答 1

0

首先,UIComponent类是 Flex 中使用的所有可视化组件的基类(如Label, Progressbar, ...),但我认为您使用的是 Flash,所以这不是好方法。

真的我不知道你为什么要同时在浏览器中打开许多网址(我认为你的最终用户可能不会那样),但你必须在每次navigateToURL()调用之间使用一些间隔,使用一个Timer对象例子 :

var urls:Array = [
    'http://www.wikipedia.org',
    'http://www.ubuntu.com',
    'http://www.stackoverflow.com'
];

var timer:Timer = new Timer(300, urls.length);
    timer.addEventListener(TimerEvent.TIMER, onTimer);
    function onTimer(e:TimerEvent):void {
        navigateToURL(new URLRequest(urls[timer.currentCount - 1]), '_blank');
    }
    timer.start();

希望能有所帮助。

于 2015-03-30T06:19:01.050 回答