![]() |
|
||||||||||
|
|||||
|
[+4 18.07.08]
Регистрация: Sep 2006
Сообщений: 39
|
мдя....
не веришь вот доказательство: вот скрипт, что что был... var xmlFile:String = "test.xml";// адрес файла основного XML
var img_folderURL:String = "";// адрес папки с картинками, будет читаться из XML
var photoset:Object = new Object();// будет хранить все данные о странице
photoset.maxCellHeight = 0;
photoset.pics = 0;
var imgNameFormat:TextFormat = new TextFormat();// формат подписей к картинкам
imgNameFormat.font = "Arial";
imgNameFormat.size = 12;
imgNameFormat.indent = 2;
// Задаем параметры сцены, чтобы обеспечить реакцию на ресайз флэшки
Stage.showMenu = false;
Stage.scaleMode = "noScale";
Stage.align = "TL";
Stage.addListener(this);
this.onResize = align;
// * * * * * * * Ч Т Е Н И Е X M L * * * * * * * * *
function parsing(pageXML:XML) {
// XML загружен, создаем страницу галереи
var page:MovieClip = _root.createEmptyMovieClip("page_mc", 10);
page._x=10, page._y=45;
// вытаскиваем узел, с которым будем дальше работать
// pageXML.firstChild - это корневой узел 'show'
// pageXML.firstChild.firstChild - нужный нам узел 'page'
var imageList:XMLNode = pageXML.firstChild.firstChild;
// считываем данные об адресе папки с картинками
img_folderURL = imageList.attributes.imageFolder;
// считываем данные о странице
var pagenum:String = imageList.attributes.pageNum;
var pagetitle:String = imageList.attributes.pageTitle;
// выводим заголовок
var title_mc:MovieClip = _root.createEmptyMovieClip("title_mc", 20);
var title_txt:TextField = title_mc.createTextField("title_txt", 1, 0, 0, Stage.width, 35);
var titleFormat:TextFormat = new TextFormat();
titleFormat.font = "Trebuchet MS";
titleFormat.bold = true;
titleFormat.size = 24;
title_txt.text = pagenum+". "+pagetitle;
title_txt.autoSize = true;
title_txt.multiline = true;
title_txt.selectable = false;// опционально
title_txt.textColor = 0xaaaaaa;
title_txt.setTextFormat(titleFormat);
title_mc.lineStyle(1,0x666666);
title_mc.moveTo(5,title_txt._height);
title_mc.lineTo(Stage.width-5,title_txt._height);
// парсим список картинок в массив нодов
var arr:Array = imageList.childNodes;
photoset.pics = arr.length;
// начинаем просмотр массива
for (i=0; i<arr.length; i++) {
var currentNode:XMLNode = arr[i];
// считываем данные о текущей картинке
pic = img_folderURL+currentNode.attributes.pic;
titul = currentNode.attributes.titul;
hint = currentNode.attributes.hint;
link = img_folderURL+currentNode.attributes.big;
// вызываем функцию, загружающую превью и формирующую слайд
loadPic(i,pic,hint,titul,link);
}
}
sourceXML = new XML();
sourceXML.ignoreWhite = true;
sourceXML.load(xmlFile);
sourceXML.onLoad = function(success) {
success ? parsing(this) : title_mc.title_txt.text="LET'S PANIC NOW: XML DATA NOT LOADED!!!";
};
// * * * * * * * * * Г Р У З И М К А Р Т И Н К И * * * * * * * * * * * * * *
function loadPic(i:Number, pic:String, hint:String, titul:String, link:String) {
var mc:MovieClip = page_mc.createEmptyMovieClip("image"+i, i);
var mc_pic:MovieClip = mc.createEmptyMovieClip("pic", 2);
var mcLoader:MovieClipLoader = new MovieClipLoader();
var mcListener:Object = new Object();
mcLoader.addListener(mcListener);
mcListener.onLoadInit = function(mc_pic) {
mc = mc_pic._parent;
mc.hint = hint;
mc.titul = titul;
mc.link = link;
formatCell(mc);
align();
mc.onRollOver = imgOver;
mc.onRollOut = imgOut;
mc.onPress = imgPress;
};
mcLoader.loadClip(pic,mc_pic);
}
// * * * * * * * * * * * Ф О Р М А Т И Р У Е М Я Ч Е Й К У * * * * * * * * *
function formatCell(mc:MovieClip) {
// создаем подпись
var imgtitle:TextField = mc.createTextField("name_txt", 10, 0, mc._height+5, mc.mc_pic._width, 20);
imgtitle.autoSize = true;
imgtitle.multiline = true;
imgtitle.wordWrap = true;
imgtitle.text = mc.titul;
imgtitle.textColor = 0x888888;
imgtitle._width = mc._width;
imgtitle.setTextFormat(imgNameFormat);
// создаем рамку
var ramka:MovieClip = mc.createEmptyMovieClip("r", 0);
with (ramka) {
h = mc._height+3;
w = mc._width+3
lineStyle(0,0x505050);
beginFill(0x404040,100);
moveTo(0,0);
lineTo(w,0);
lineTo(w,h);
lineTo(0,h);
lineTo(0,0);
endFill();
_visible = 0
};
mc.pic._x = mc.pic._y=2;
}
// * * * * * * * * * * * * * * К Н О П О Ч Н Ы Е С О Б Ы Т И Я * * * * * * *
function imgOver() {
this.r._visible = true;
this.name_txt.textColor = 0xcccccc;
viewHint(this);
}
function imgOut() {
this.r._visible = false;
this.name_txt.textColor = 0x888888;
closeHint()
}
function imgPress() {
trace("Загружаем большую картинку "+this.link)
}
// * * * * * * * * * П О К А З Ы В А Е М П О Д С К А З К И * * * * * * * * *
function viewHint(mc:MovieClip){
hint_list = _root.createTextField("hint_list",_root.getNextHighestDepth(),_xmouse+2,_ymouse+1,50,10);
hint_list.selectable = false
hint_list.border = true;
hint_list.borderColor = 0x505050
hint_list.background = true;
hint_list.backgroundColor = 0x404040;
hint_list.text = " "+mc.hint;
hint_list.textColor = 0xaaaaaa;
hint_list.setTextFormat(imgNameFormat);
hint_list._width = hint_list.textWidth + 10;
hint_list._height = hint_list.textHeight + 4;
mc.onMouseMove = function () {
hint_list._x = _xmouse+2;
hint_list._y = _ymouse+1;
updateAfterEvent();
}
};
function closeHint(){
_root.hint_list.removeTextField();
}
// * * * * * * * * * В Ы С Т Р А И В А Е М П О Р Я Д О К * * * * * * * * *
function align() {
for (k=0; k<photoset.pics; k++) {
prex = page_mc["image"+(k-1)];
curent = page_mc["image"+k];
photoset.maxCellHeight = Math.max(photoset.maxCellHeight, curent._height);
curent.r._height = photoset.maxCellHeight;
curent._x = prex._x+prex._width+10;
curent._y = prex._y;
if ((curent._x+curent._width)>(Stage.width-10)) {
curent._x = 0;
curent._y += photoset.maxCellHeight+10;
}
}
}
|
|
|||||
|
[+4 18.07.08]
Регистрация: Sep 2006
Сообщений: 39
|
А вот что стало, после твоей замене _root на this...
var xmlFile:String = "test.xml";
// адрес файла основного XML
var img_folderURL:String = "";
// адрес папки с картинками, будет читаться из XML
var photoset:Object = new Object ();
// будет хранить все данные о странице
photoset.maxCellHeight = 0;
photoset.pics = 0;
var imgNameFormat:TextFormat = new TextFormat ();
// формат подписей к картинкам
imgNameFormat.font = "Arial";
imgNameFormat.size = 12;
imgNameFormat.indent = 2;
// Задаем параметры сцены, чтобы обеспечить реакцию на ресайз флэшки
Stage.showMenu = false;
Stage.scaleMode = "noScale";
Stage.align = "TL";
Stage.addListener (this);
this.onResize = align;
// * * * * * * * Ч Т Е Н И Е X M L * * * * * * * * *
function parsing (pageXML:XML) {
// XML загружен, создаем страницу галереи
var page:MovieClip = this.createEmptyMovieClip ("page_mc", 10);
page._x = 10, page._y = 45;
// вытаскиваем узел, с которым будем дальше работать
// pageXML.firstChild - это корневой узел 'show'
// pageXML.firstChild.firstChild - нужный нам узел 'page'
var imageList:XMLNode = pageXML.firstChild.firstChild;
// считываем данные об адресе папки с картинками
img_folderURL = imageList.attributes.imageFolder;
// считываем данные о странице
var pagenum:String = imageList.attributes.pageNum;
var pagetitle:String = imageList.attributes.pageTitle;
// выводим заголовок
var title_mc:MovieClip = this.createEmptyMovieClip ("title_mc", 20);
var title_txt:TextField = title_mc.createTextField ("title_txt", 1, 0, 0, Stage.width, 35);
var titleFormat:TextFormat = new TextFormat ();
titleFormat.font = "Trebuchet MS";
titleFormat.bold = true;
titleFormat.size = 24;
title_txt.text = pagenum + ". " + pagetitle;
title_txt.autoSize = true;
title_txt.multiline = true;
title_txt.selectable = false;
// опционально
title_txt.textColor = 0xaaaaaa;
title_txt.setTextFormat (titleFormat);
title_mc.lineStyle (1, 0x666666);
title_mc.moveTo (5, title_txt._height);
title_mc.lineTo (Stage.width - 5, title_txt._height);
// парсим список картинок в массив нодов
var arr:Array = imageList.childNodes;
photoset.pics = arr.length;
// начинаем просмотр массива
for (i = 0; i < arr.length; i++) {
var currentNode:XMLNode = arr[i];
// считываем данные о текущей картинке
pic = img_folderURL + currentNode.attributes.pic;
titul = currentNode.attributes.titul;
hint = currentNode.attributes.hint;
link = img_folderURL + currentNode.attributes.big;
// вызываем функцию, загружающую превью и формирующую слайд
loadPic (i, pic, hint, titul, link);
}
}
sourceXML = new XML ();
sourceXML.ignoreWhite = true;
sourceXML.load (xmlFile);
sourceXML.onLoad = function (success) {
success ? parsing (this) : title_mc.title_txt.text = "LET'S PANIC NOW: XML DATA NOT LOADED!!!";
};
// * * * * * * * * * Г Р У З И М К А Р Т И Н К И * * * * * * * * * * * * * *
function loadPic (i:Number, pic:String, hint:String, titul:String, link:String) {
var mc:MovieClip = page_mc.createEmptyMovieClip ("image" + i, i);
var mc_pic:MovieClip = mc.createEmptyMovieClip ("pic", 2);
var mcLoader:MovieClipLoader = new MovieClipLoader ();
var mcListener:Object = new Object ();
mcLoader.addListener (mcListener);
mcListener.onLoadInit = function (mc_pic) {
mc = mc_pic._parent;
mc.hint = hint;
mc.titul = titul;
mc.link = link;
formatCell (mc);
align ();
mc.onRollOver = imgOver;
mc.onRollOut = imgOut;
mc.onPress = imgPress;
};
mcLoader.loadClip (pic, mc_pic);
}
// * * * * * * * * * * * Ф О Р М А Т И Р У Е М Я Ч Е Й К У * * * * * * * * *
function formatCell (mc:MovieClip) {
// создаем подпись
var imgtitle:TextField = mc.createTextField ("name_txt", 10, 0, mc._height + 5, mc.mc_pic._width, 20);
imgtitle.autoSize = true;
imgtitle.multiline = true;
imgtitle.wordWrap = true;
imgtitle.text = mc.titul;
imgtitle.textColor = 0x888888;
imgtitle._width = mc._width;
imgtitle.setTextFormat (imgNameFormat);
// создаем рамку
var ramka:MovieClip = mc.createEmptyMovieClip ("r", 0);
with (ramka) {
h = mc._height + 3;
w = mc._width + 3;
lineStyle (0, 0x505050);
beginFill (0x404040, 100);
moveTo (0, 0);
lineTo (w, 0);
lineTo (w, h);
lineTo (0, h);
lineTo (0, 0);
endFill ();
_visible = 0;
}
mc.pic._x = mc.pic._y = 2;
}
// * * * * * * * * * * * * * * К Н О П О Ч Н Ы Е С О Б Ы Т И Я * * * * * * *
function imgOver () {
this.r._visible = true;
this.name_txt.textColor = 0xcccccc;
viewHint (this);
}
function imgOut () {
this.r._visible = false;
this.name_txt.textColor = 0x888888;
closeHint ();
}
function imgPress () {
trace ("Загружаем большую картинку " + this.link);
}
// * * * * * * * * * П О К А З Ы В А Е М П О Д С К А З К И * * * * * * * * *
function viewHint (mc:MovieClip) {
hint_list = this.createTextField ("hint_list", this.getNextHighestDepth (), _xmouse + 2, _ymouse + 1, 50, 10);
hint_list.selectable = false;
hint_list.border = true;
hint_list.borderColor = 0x505050;
hint_list.background = true;
hint_list.backgroundColor = 0x404040;
hint_list.text = " " + mc.hint;
hint_list.textColor = 0xaaaaaa;
hint_list.setTextFormat (imgNameFormat);
hint_list._width = hint_list.textWidth + 10;
hint_list._height = hint_list.textHeight + 4;
mc.onMouseMove = function () {
hint_list._x = _xmouse + 2;
hint_list._y = _ymouse + 1;
updateAfterEvent ();
};
}
function closeHint () {
this.hint_list.removeTextField ();
}
// * * * * * * * * * В Ы С Т Р А И В А Е М П О Р Я Д О К * * * * * * * * *
function align () {
for (k = 0; k < photoset.pics; k++) {
prex = page_mc["image" + (k - 1)];
curent = page_mc["image" + k];
photoset.maxCellHeight = Math.max (photoset.maxCellHeight, curent._height);
curent.r._height = photoset.maxCellHeight;
curent._x = prex._x + prex._width + 10;
curent._y = prex._y;
if ((curent._x + curent._width) > (Stage.width - 10)) {
curent._x = 0;
curent._y += photoset.maxCellHeight + 10;
}
}
}
|
|
|||||
|
Нуб нубам
модератор форума
Регистрация: Jan 2006
Адрес: Бердск, НСО
Сообщений: 6,445
|
M.™, Вы обиделись на iNilsa за то что он удалил часть моих комментариев? )))))))))))))
Не хотите учиться, хотите чтобы все делали за Вас - так и скажите. Так Вам ведь сделали, Вы всё недовольны.
__________________
Reality.getBounds(this); |
|
|||||
|
[+4 18.07.08]
Регистрация: Sep 2006
Сообщений: 39
|
я доволен, начиная с того что мне вообще ответили....
Да в скриптах я не всё понимаю...я просто хотел если не трудно...обьяснить по подробнее в чём была проблема...а не просто сказать заменил _root на this, сколько раз менял ничего не получалось...а он сделал, сказал что только заменил, а результат совсем другой... если тебе не трудно можешь посмотреть в чём проблела этой галереи... Я сделал так как сказал Добрый модератор а результата никакого... |
![]() |
![]() |
Часовой пояс GMT +4, время: 07:12. |
|
|
« Предыдущая тема | Следующая тема » |
|
|