![]() |
|
||||||||||
|
|||||||
|
|
« Предыдущая тема | Следующая тема » |
| Опции темы | Опции просмотра |
|
![]() |
![]() |
|
|||||
|
Регистрация: Apr 2009
Сообщений: 4
|
всем доброго времени суток!!!
![]() у меня вот какая ситуация: я сделал слайд шоу, а точнее нашел исходник=) с нужной мне анимацией. но когда я закинул туда свои фотографии, а их 30 штук и все тяжелые, то слайд шоу начал сильно тормозить. мне нужно сделать так, чтоб все фотки загружались не сразу, а по мере показа слайд шоу. примерно знаю что нужно испольщовать функцию загрузки, но вот куда ее вписать и с какими параметрами, ну никак не пойму=( помогите пожалуйста ![]() вот код xml: <slideshow width="400" height="400" speed="2"> <image url="images/image1.jpg" title="Market Walk" /> ... <image url="images/image10.jpg" title="Bored?" /> </slideshow> а вот код actionscript import mx.transitions.Tween; import mx.transitions.easing.*; var myShowXML = new XML(); myShowXML.ignoreWhite = true; myShowXML.load("slideshow.xml"); myShowXML.onLoad = function() { _root.myWidth = myShowXML.firstChild.attributes.width; _root.myHeight = myShowXML.firstChild.attributes.height; _root.mySpeed = myShowXML.firstChild.attributes.speed; _root.myImages = myShowXML.firstChild.childNodes; _root.myImagesNo = myImages.length; createContainer(); callImages(); }; function createContainer() { _root.createEmptyMovieClip("myContainer_mc",1); myContainer_mc.lineStyle(5,0x000000,100); myContainer_mc.lineTo(_root.myWidth,0); myContainer_mc.lineTo(_root.myWidth,_root.myHeight); myContainer_mc.lineTo(0,_root.myHeight); myContainer_mc.lineTo(0,0); myContainer_mc._x = (Stage.width-myContainer_mc._width)/2; myContainer_mc._y = (Stage.height-myContainer_mc._height)/2; } function callImages() { _root.myMCL = new MovieClipLoader(); _root.myPreloader = new Object(); _root.myMCL.addListener(_root.myPreloader); _root.myClips_array = []; _root.myPreloader.onLoadStart = function(target) { _root.createTextField("myText_txt",_root.getNextHighestDepth(),0,0,100,20); _root.myText_txt._x = (Stage.width-_root.myText_txt._width)/2; _root.myText_txt._y = (Stage.height-_root.myText_txt._height)/2; _root.myText_txt.autoSize = "center"; _root.myText_txt.text = "test"; }; _root.myPreloader.onLoadProgress = function(target) { _root.myText_txt.text = "Loading.. "+_root.myClips_array.length+"/"+_root.myImagesNo+" Completed"; }; _root.myPreloader.onLoadComplete = function(target) { _root.myClips_array.push(target); target._alpha = 0; if (_root.myClips_array.length == _root.myImagesNo) { _root.myText_txt._y = myContainer_mc._y + myContainer_mc._height; _root.target_mc = -1; moveSlide(); myShowInt = setInterval(moveSlide, (_root.mySpeed*1000)+1000); } }; for (i=0; i<_root.myImagesNo; i++) { temp_url = _root.myImages[i].attributes.url; temp_mc = myContainer_mc.createEmptyMovieClip(i, myContainer_mc.getNextHighestDepth()); _root.myMCL.loadClip(temp_url,temp_mc); } } function moveSlide() { current_mc = _root.myClips_array[_root.target_mc]; new Tween(current_mc, "_alpha", Strong.easeOut, 100, 0, 1, true); _root.target_mc++; if (_root.target_mc>=_root.myImagesNo) { _root.target_mc = 0; } _root.myText_txt.text = _root.myImages[target_mc].attributes.title; next_mc = _root.myClips_array[_root.target_mc]; new Tween(next_mc, "_alpha", Strong.easeOut, 0, 100, 1, true); } http://financy.kz/slide/slideshow.zip помогите пожалуйста=) с меня сто грам и булка ![]() |
|
|||||
|
Самый лучший выход, поинтересоваться у автора кода).
|
|
|||||
|
Регистрация: Apr 2009
Сообщений: 4
|
да я бы спросил, но это статья из самоучителя и это из американского сайта=(
|
|
|||||
|
listener
|
Как нибудь так, без заморочек:
import mx.transitions.Tween;
import mx.transitions.easing.*;
var myShowXML = new XML();
myShowXML.ignoreWhite = true;
createTextField("myText_txt", 1000, 0, 0, 200, 20);
myText_txt._x = (Stage.width - _root.myText_txt._width) / 2;
myText_txt._y = (Stage.height - _root.myText_txt._height) / 2;
myText_txt.autoSize = "center";
myText_txt.text = "test";
myText_txt.text = "Loading ...";
myShowXML.load("slideshow.xml");
var i = 0;
myShowXML.onLoad = function() {
_root.myWidth = myShowXML.firstChild.attributes.width;
_root.myHeight = myShowXML.firstChild.attributes.height;
_root.mySpeed = myShowXML.firstChild.attributes.speed;
_root.myImages = myShowXML.firstChild.childNodes;
_root.myImagesNo = myImages.length;
createContainer();
callImages();
};
function createContainer() {
_root.createEmptyMovieClip("myContainer_mc", 1);
myContainer_mc.lineStyle(5, 0x000000, 100);
myContainer_mc.lineTo(_root.myWidth, 0);
myContainer_mc.lineTo(_root.myWidth, _root.myHeight);
myContainer_mc.lineTo(0, _root.myHeight);
myContainer_mc.lineTo(0, 0);
myContainer_mc._x = (Stage.width - myContainer_mc._width) / 2;
myContainer_mc._y = (Stage.height - myContainer_mc._height) / 2;
}
function callImages() {
_root.myMCL = new MovieClipLoader();
_root.myPreloader = new Object();
_root.myMCL.addListener(_root.myPreloader);
_root.myClips_array = [];
_root.myPreloader.onLoadStart = function(target) {
};
_root.myPreloader.onLoadProgress = function(targetp, bytesLoaded, bytesTotal) {
var loadStatus:Number = Math.round(bytesLoaded / bytesTotal * 100);
_root.myText_txt.text = "Loading.. " + loadStatus + "%/" + (i + 1) + "/" + _root.myImagesNo + " Completed";
};
_root.myPreloader.onLoadComplete = function(target) {
_root.myClips_array.push(target);
target._alpha = 0;
if (_root.myClips_array.length == 1) {
_root.myText_txt._y = myContainer_mc._y + myContainer_mc._height;
_root.target_mc = -1;
moveSlide();
myShowInt = setInterval(moveSlide, (_root.mySpeed * 1000) + 1000);
}
if (i < _root.myImagesNo) {
i++;
temp_url = _root.myImages[i].attributes.url;
temp_mc = myContainer_mc.createEmptyMovieClip(i, i);
_root.myMCL.loadClip(temp_url, temp_mc);
}
};
temp_url = _root.myImages[i].attributes.url;
temp_mc = myContainer_mc.createEmptyMovieClip(i, i);
_root.myMCL.loadClip(temp_url, temp_mc);
}
function moveSlide() {
current_mc = _root.myClips_array[_root.target_mc];
if (_root.target_mc >= _root.myImagesNo-1) {
_root.target_mc = -1;
}
next_mc = _root.myClips_array[_root.target_mc + 1];
if (next_mc) {
_root.target_mc++;
new Tween(current_mc, "_alpha", Strong.easeOut, 100, 0, 1, true);
_root.myText_txt.text = _root.myImages[target_mc].attributes.title;
new Tween(next_mc, "_alpha", Strong.easeOut, 0, 100, 1, true);
current_mc = next_mc;
}
}
|
|
|||||
|
Регистрация: Apr 2009
Сообщений: 4
|
увожаемый alexcon314!
вы гений! большое спасибо что не оставили меня без внимания=) можете подсказать какая строка отвечает за подгрузку нового фото=) целый день парюсь с этим, вообще уже запутался=) и еще, когда вставляю свои фото, 30 штук, и меняю разрешение, то анимация тормозит. из-за чего это может быть. я вот сделал по вашему коду все, убрал границы и встаил свои картинки, тут их 15, а показываются только 5, хотя на свем компе этот же swf играет все 15=( здесь пример. www.financy.kz/2/ т.е. что я сделал с вашим кодом: import mx.transitions.Tween; import mx.transitions.easing.*; var myShowXML = new XML(); myShowXML.ignoreWhite = true; createTextField("myText_txt", 1000, 0, 0, 200, 20); myText_txt._x = (Stage.width - _root.myText_txt._width) / 2; myText_txt._y = (Stage.height - _root.myText_txt._height) / 2; myText_txt.autoSize = "center"; myText_txt.text = "test"; myText_txt.text = "Loading ..."; myShowXML.load("slideshow.xml"); var i = 0; myShowXML.onLoad = function() { _root.myWidth = myShowXML.firstChild.attributes.width; _root.myHeight = myShowXML.firstChild.attributes.height; _root.mySpeed = myShowXML.firstChild.attributes.speed; _root.myImages = myShowXML.firstChild.childNodes; _root.myImagesNo = myImages.length; createContainer(); callImages(); }; function createContainer() { _root.createEmptyMovieClip("myContainer_mc", 1); myContainer_mc.lineStyle(0, 0x000000, 100); myContainer_mc.lineTo(_root.myWidth, 0); myContainer_mc.lineTo(_root.myWidth, _root.myHeight); myContainer_mc.lineTo(0, _root.myHeight); myContainer_mc.lineTo(0, 0); } function callImages() { _root.myMCL = new MovieClipLoader(); _root.myPreloader = new Object(); _root.myMCL.addListener(_root.myPreloader); _root.myClips_array = []; _root.myPreloader.onLoadStart = function(target) { }; _root.myPreloader.onLoadProgress = function(targetp, bytesLoaded, bytesTotal) { var loadStatus:Number = Math.round(bytesLoaded / bytesTotal * 100); _root.myText_txt.text = "Loading.. " + loadStatus + "%/" + (i + 1) + "/" + _root.myImagesNo + " Completed"; }; _root.myPreloader.onLoadComplete = function(target) { _root.myClips_array.push(target); target._alpha = 0; if (_root.myClips_array.length == 1) { _root.myText_txt._y = myContainer_mc._y + myContainer_mc._height; _root.target_mc = -1; moveSlide(); myShowInt = setInterval(moveSlide, (_root.mySpeed * 1000) + 1000); } if (i < _root.myImagesNo) { i++; temp_url = _root.myImages[i].attributes.url; temp_mc = myContainer_mc.createEmptyMovieClip(i, i); _root.myMCL.loadClip(temp_url, temp_mc); } }; temp_url = _root.myImages[i].attributes.url; temp_mc = myContainer_mc.createEmptyMovieClip(i, i); _root.myMCL.loadClip(temp_url, temp_mc); } function moveSlide() { current_mc = _root.myClips_array[_root.target_mc]; if (_root.target_mc >= _root.myImagesNo-1) { _root.target_mc = -1; } next_mc = _root.myClips_array[_root.target_mc + 1]; if (next_mc) { _root.target_mc++; new Tween(current_mc, "_alpha", Strong.easeOut, 100, 0, 1, true); _root.myText_txt.text = _root.myImages[target_mc].attributes.title; new Tween(next_mc, "_alpha", Strong.easeOut, 0, 100, 1, true); current_mc = next_mc; } } myContainer_mc._x = (Stage.width - myContainer_mc._width) / 2; myContainer_mc._y = (Stage.height - myContainer_mc._height) / 2; подскажите пожалуйста ![]() |
|
|||||
|
listener
|
Цитата:
Переименуйте файл из "image6.JPG" в "image6.jpg". Это как минимум, что нужно сделать. На локальном компе у вас винда стоит? Ей пофиг на регистр букв в имени файла, а вот на серваке видно не винда. А вообще нужно приделать обработку ошибок при загрузке. Тормозит анимация потому, что пока не загрузится очередная картинка все останавливается. Если картинка большая, то грузиться может довольно долго. Попробуйте так: import mx.transitions.Tween;
import mx.transitions.easing.*;
var myShowXML = new XML();
myShowXML.ignoreWhite = true;
createTextField("myText_txt", 1000, 0, 0, 200, 20);
myText_txt._x = (Stage.width - _root.myText_txt._width) / 2;
myText_txt._y = (Stage.height - _root.myText_txt._height) / 2;
myText_txt.autoSize = "center";
myText_txt.text = "test";
myText_txt.text = "Loading ...";
myShowXML.load("slideshow.xml");
var i = 0;
myShowXML.onLoad = function() {
_root.myWidth = myShowXML.firstChild.attributes.width;
_root.myHeight = myShowXML.firstChild.attributes.height;
_root.mySpeed = myShowXML.firstChild.attributes.speed;
_root.myImages = myShowXML.firstChild.childNodes;
_root.myImagesNo = myImages.length;
createContainer();
callImages();
};
function createContainer() {
_root.createEmptyMovieClip("myContainer_mc", 1);
myContainer_mc.lineStyle(5, 0x000000, 100);
myContainer_mc.lineTo(_root.myWidth, 0);
myContainer_mc.lineTo(_root.myWidth, _root.myHeight);
myContainer_mc.lineTo(0, _root.myHeight);
myContainer_mc.lineTo(0, 0);
myContainer_mc._x = (Stage.width - myContainer_mc._width) / 2;
myContainer_mc._y = (Stage.height - myContainer_mc._height) / 2;
}
function callImages() {
_root.myMCL = new MovieClipLoader();
_root.myPreloader = new Object();
_root.myMCL.addListener(_root.myPreloader);
_root.myClips_array = [];
_root.myPreloader.onLoadStart = function(target) {
};
_root.myPreloader.onLoadProgress = function(targetp, bytesLoaded, bytesTotal) {
var loadStatus:Number = Math.round(bytesLoaded / bytesTotal * 100);
_root.myText_txt.text = "Loading.. " + loadStatus + "%/" + (i + 1) + "/" + _root.myImagesNo + " Completed";
};
_root.myPreloader.onLoadComplete = function(target) {
_root.myClips_array.push(target);
target._alpha = 0;
target.url = temp_url;
if (_root.myClips_array.length == 1) {
current_mc = _root.myClips_array[0];
new Tween(current_mc, "_alpha", Strong.easeOut, 0, 100, 1, true);
_root.myText_txt._y = myContainer_mc._y + myContainer_mc._height;
_root.target_mc = -1;
moveSlide();
myShowInt = setInterval(moveSlide, (_root.mySpeed * 1000) + 1000);
}
if (i < _root.myImagesNo) {
i++;
temp_url = _root.myImages[i].attributes.url;
temp_mc = myContainer_mc.createEmptyMovieClip(i, i);
_root.myMCL.loadClip(temp_url, temp_mc);
}
};
_root.myPreloader.onLoadError = _root.myPreloader.onLoadComplete;
temp_url = _root.myImages[i].attributes.url;
temp_mc = myContainer_mc.createEmptyMovieClip(i, i);
_root.myMCL.loadClip(temp_url, temp_mc);
}
function moveSlide() {
current_mc = _root.myClips_array[_root.target_mc];
if (_root.target_mc >= _root.myImagesNo - 1) {
_root.target_mc = -1;
}
next_mc = _root.myClips_array[_root.target_mc + 1];
if (next_mc) {
_root.target_mc++;
new Tween(current_mc, "_alpha", Strong.easeOut, 100, 0, 1, true);
_root.myText_txt.text = _root.myImages[target_mc].attributes.title;
new Tween(next_mc, "_alpha", Strong.easeOut, 0, 100, 1, true);
trace(next_mc.url);
current_mc = next_mc;
} else {
new Tween(current_mc, "_alpha", Strong.easeOut, 100, 0, 1, true);
_root.target_mc = -1;
current_mc = _root.myClips_array[_root.target_mc + 1];
new Tween(current_mc, "_alpha", Strong.easeOut, 0, 100, 1, true);
}
}
Кстати, image14.jpg тоже отсутствует на сервере. |
![]() |
![]() |
Часовой пояс GMT +4, время: 08:24. |
|
|
« Предыдущая тема | Следующая тема » |
|
|