Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript 1.0/2.0 (http://www.flasher.ru/forum/forumdisplay.php?f=93)
-   -   XML доступ к узлам (http://www.flasher.ru/forum/showthread.php?t=157485)

German 06.06.2011 17:13

XML доступ к узлам
 
Здравствуйте.
Подскажите как мне вывести фото с именами foto1 и foto2 в фрагмент ролика с именем thumbnails из XML файла, сейчас выводится только foto1.
Смысл сего вывод двух маленьких фото в окне предпросмотра, а при нажатии на одну из них она открывается из папки images только уже увеличенная.

вот парсер XML:

Код AS1/AS2:

myPhoto = new XML();
myPhoto.ignoreWhite = true;
myPhoto.onLoad = function(success) {
        //portfolioTag = this.firstChild.childNodes[i].childNodes[0].childNodes[0];
        numimages = this.firstChild.childNodes.length;
 
        spacing = 100;
 
        for (i=0; i<numimages; i++) {
                this.picHolder = this.firstChild.childNodes[i].childNodes[0].childNodes[0];
 
                this.thumbHolder = thumbnails.createEmptyMovieClip("thumbnail",i);
                //this.thumbHolder._x = i*spacing;
                this.thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 0);
                this.thumbLoader.loadMovie(this.picHolder.attributes.thmb);
                trace(this.picHolder.attributes.thmb);
 
                this.thumbHolder.title = this.picHolder.attributes.title;
                this.thumbHolder.main = this.picHolder.attributes.main;
 
                this.thumbHolder.onRelease = function() {
                        loader.loadMovie(this.main);
                        title_txt.text = this.title;
                        //trace(this.title);
 
                };
        }
};
myPhoto.load("image.xml");

Вот XML файл:

Код:

<image>     
      <picture_men>   
             
              <spring>     
                <image title="1" main="images/foto1.jpg" thmb="thumbnails/foto1.jpg"/> 
                <image title="2" main="images/foto2.jpg" thmb="thumbnails/foto2.jpg"/> 

             
              </spring>
             
              <summer>   
                <image title="5" main="images/foto3.jpg" thmb="thumbnails/foto3.jpg"/> 
                <image title="6" main="images/foto4.jpg" thmb="thumbnails/foto4.jpg"/> 
              </summer>
             
      </picture_men>
</image>

Могу приложить исходник.
Спасибо.

vivado 07.06.2011 15:22

Попробуй сделать переменные которые принимают значения из XML массивами.
Примерно так...

Код AS1/AS2:

titleM = new Array(); //Создаем массив для описаний к фотографиям
mainM = new Array(); //Создаем массив для URL к фотографиям
thmbM = new Array(); //Создаем массив для URL к превьюшкам
 
//Тут цикл и все остальное
 
 
titleM.push(numimages[i].attributes.title)
mainM.push(numimages[i].attributes.mail)
thmbM.push(numimages[i].attributes.thmb)

и еще "title" зарезервированная команда флеша, назови переменную по другому какнибудь.
Может ничего страшного не произойдет конечно, но так на всякий случай )))

А так вообще исходник лучше кинь, чтоб легче было разобраться...

German 08.06.2011 00:11

Vivado спасибо огромное, буду пробовать. Если не получится выложу исходник.


Часовой пояс GMT +4, время: 23:16.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.