构建图库时出错

发布于 2024-10-25 07:21:38 字数 2145 浏览 1 评论 0原文

我的舞台上有 8 个 MovieClip,我正在尝试使用此脚本制作一个照片库:

var photo :XML = new XML();
var imgURL :Array = new Array();
var imgCaptions :Array = new Array();
var thumbImg :Array = new Array();
var totImgs : Number = 0;
var imgAtual : Number = 1;
var xPos :Number = Stage.width;
var yPos :Number = Stage.height;
var mclThumb :MovieClipLoader = new MovieClipLoader();
var listenerThumb :Object = new Object();

photo.ignoreWhite = true;

photo.onLoad = function(success) {
 if(success) {
  var photos :Array = new Array();

  photos = this.firstChild.childNodes;

  for(var i :Number = 0; i < photos.length; i++) {
   imgURL.push(photos[i].attributes.images);
   thumbImg.push(photos[i].attributes.thumb);
   imgCaptions.push(photos[i].attributes.descricao);
  }

  totImgs = imgURL.length;
 }
}

photo.load("photos.xml");

buildThumb = function() {
 for(var i :Number = 1; i <= 8; i++) {
  loadMovie(thumbImg[imgAtual],_root["img" + i]);
 }
}

buildThumb();

如果我对其进行测试,则会出现如下错误:

打开 URL“file:///C|/Documents%20and%20Settings/ 时出错” Eduardo%20Tavares/My%20Documents/Web%20Sites/site%20dj/images/undefined"

如果我​​删除 buildThumb?s 函数,我不会收到任何错误,但它不会加载任何内容。

这是我的 xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<slideshow>
<photo images="foto1.jpg" thumb="thumb1.jpg" descricao="DJ Chambinho fazendo o Gas     Total" />
<photo images="foto2.jpg" thumb="thumb2.jpg" descricao="DJ Chambinho fazendo o Gas     Total" />
<photo images="foto3.jpg" thumb="thumb3.jpg" descricao="DJ Chambinho fazendo o Gas     Total" />
<photo images="foto4.jpg" thumb="thumb4.jpg" descricao="DJ Chambinho fazendo o Gas     Total" />
<photo images="foto5.jpg" thumb="thumb5.jpg" descricao="DJ Chambinho fazendo o Gas     Total" />
<photo images="foto6.jpg" thumb="thumb6.jpg" descricao="DJ Chambinho fazendo o Gas     Total" />
<photo images="foto7.jpg" thumb="thumb7.jpg" descricao="DJ Chambinho fazendo o Gas     Total" />
<photo images="foto8.jpg" thumb="thumb8.jpg" descricao="DJ Chambinho fazendo o Gas     Total" />
</slideshow>

I have 8 MovieClips on my stage and I am trying to make a photo gallery using this script:

var photo :XML = new XML();
var imgURL :Array = new Array();
var imgCaptions :Array = new Array();
var thumbImg :Array = new Array();
var totImgs : Number = 0;
var imgAtual : Number = 1;
var xPos :Number = Stage.width;
var yPos :Number = Stage.height;
var mclThumb :MovieClipLoader = new MovieClipLoader();
var listenerThumb :Object = new Object();

photo.ignoreWhite = true;

photo.onLoad = function(success) {
 if(success) {
  var photos :Array = new Array();

  photos = this.firstChild.childNodes;

  for(var i :Number = 0; i < photos.length; i++) {
   imgURL.push(photos[i].attributes.images);
   thumbImg.push(photos[i].attributes.thumb);
   imgCaptions.push(photos[i].attributes.descricao);
  }

  totImgs = imgURL.length;
 }
}

photo.load("photos.xml");

buildThumb = function() {
 for(var i :Number = 1; i <= 8; i++) {
  loadMovie(thumbImg[imgAtual],_root["img" + i]);
 }
}

buildThumb();

if I test it I will have an error like this:

Error opening URL "file:///C|/Documents%20and%20Settings/Eduardo%20Tavares/My%20Documents/Web%20Sites/site%20dj/images/undefined"

if I remove buildThumb?s function I get no error but It doesnt load anything.

here is my xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<slideshow>
<photo images="foto1.jpg" thumb="thumb1.jpg" descricao="DJ Chambinho fazendo o Gas     Total" />
<photo images="foto2.jpg" thumb="thumb2.jpg" descricao="DJ Chambinho fazendo o Gas     Total" />
<photo images="foto3.jpg" thumb="thumb3.jpg" descricao="DJ Chambinho fazendo o Gas     Total" />
<photo images="foto4.jpg" thumb="thumb4.jpg" descricao="DJ Chambinho fazendo o Gas     Total" />
<photo images="foto5.jpg" thumb="thumb5.jpg" descricao="DJ Chambinho fazendo o Gas     Total" />
<photo images="foto6.jpg" thumb="thumb6.jpg" descricao="DJ Chambinho fazendo o Gas     Total" />
<photo images="foto7.jpg" thumb="thumb7.jpg" descricao="DJ Chambinho fazendo o Gas     Total" />
<photo images="foto8.jpg" thumb="thumb8.jpg" descricao="DJ Chambinho fazendo o Gas     Total" />
</slideshow>

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

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

发布评论

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

评论(1

伴我心暖 2024-11-01 07:21:38

嗯loadmovie...尝试在as3.0中使用loader而不是loadmovie,我还建议尝试先加载图像以在另一个fla中进行测试...加载器脚本在下面...hoep这有帮助...

功能loadClip (地址:字符串):无效
{
var ldr:Loader = new Loader();
ldr.contentLoaderInfo.addEventListener(Event.Complete, loadComplete);
var url:String = 地址;
var urlReq:URLRequest = new URLRequest(url);
ldr.load(urlReq);
addChild(ldr);
}

函数 loadComplete(evt:Event):void
{
跟踪(“电影已加载”);
}

hmm loadmovie... try using loader in as3.0 instead of loadmovie, i would also suggest try loading an image first for testing in another fla for testing ... loaders script is below ... hoep this helps...

function loadClip(addrs:String):void
{
var ldr:Loader = new Loader();
ldr.contentLoaderInfo.addEventListener(Event.Complete, loadComplete);
var url:String = addrs;
var urlReq:URLRequest = new URLRequest(url);
ldr.load(urlReq);
addChild(ldr);
}

function loadComplete(evt:Event):void
{
trace("movie loaded");
}

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