【问题标题】:Import photo once from XML从 XML 导入照片一次
【发布时间】:2011-11-17 12:07:19
【问题描述】:

我想制作一个从远程服务器导入 jpg 的 .swf。
我可以用这段代码(actionscript 2)做到这一点:

var my_xml = new XML();
var url = new String;

my_xml.load("http://www.someURL.com/xml.php");
my_xml.onLoad = function(success){
if (success){
    //trace(this);
    }
    url = this;
    url = "https://graph.facebook.com/"+this+"/picture?type=large";
    picLoad.loadMovie(url);
    trace(url);

}

在显示 jpg 之后,我希望它重复执行一些操作。问题是每次重复播放电影剪辑时,都需要再次提取jpg,因此延迟了0.5秒左右。

我怎样才能让它得到一次 jpg 这样它就不会延迟?

【问题讨论】:

    标签: flash actionscript actionscript-2


    【解决方案1】:

    为什么不缓存加载操作的结果呢?实际上,根据您的代码,您可以简单地使用布尔值来告诉您是否应该再次加载图片。

    类似的东西应该可以工作:

    var my_xml = new XML();
    var url = new String;
    var pictureLoaded = false;
    
    my_xml.load("http://www.someURL.com/xml.php");
    my_xml.onLoad = function(success){
    if (success){
        if (pictureLoaded) return;
    
        url = this;
        url = "https://graph.facebook.com/"+this+"/picture?type=large";
        picLoad.loadMovie(url);
        pictureLoaded = true;
        trace(url);
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多