
Adjust code so Flash slideshow works under Linux
5560
£45(approx. $60)
- Posted:
- Proposals: 1
- Remote
- #49270
- Archived
Description
Experience Level: Intermediate
Hi,
I need this code changed so my image files load in the same order as per the XML file. This does not occur currently due to the way Linux reads files from the HDD. From my research we first need to load all the files in one by one before we display them. This is not a big job, I just don\'t know how to re-code it.
=================
import mx.transitions.Tween;
import mx.transitions.easing.*;
var myShowXML = new XML();
myShowXML.ignoreWhite = true;
myShowXML.load(\"slideshow.xml?\"+Math.random());
//XMLUtils.sortXMLByAttribute(myShowXML,\'count\');
myShowXML.onLoad = function()
{
_root.myWidth = 1080;
_root.myHeight = 1920;
_root.mySpeed = 2;
_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;
}
_global.xml_time = new Array();
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 = \"Now 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);
}
};
//trace(_root.myClips_array);
//myImages.sortOn(sort_array.attributes.count);
//trace(_root.myImages);
//_root.myImages.sortOn(\"count\", Array.NUMERIC | Array.DESCENDING);
//_root.myImages.sortOn(\"count\", Array.NUMERIC | Array.DESCENDING);
//_root.myImages.sortOn (\"count\");
//
//trace(_root.myImages[0].attributes.count);
/*trace(_root.myImages[0]);
trace(_root.myImages[1]);
if(_root.myImages[1].attributes.count==1){
_root.myImages[0].attributes.url=_root.myImages[1].attributes.url;
trace(\"veve\");
}*/
//trace(_root.myImages);
/*****begin of sort array******/
var entry_items:Array = new Array();
for (var i:Number = 0; i < _root.myImagesNo; i++)
{
var temp_item:Object = new Object();
temp_item.count_num = Number(_root.myImages[i].attributes.count);
temp_item.entry = _root.myImages[i];
entry_items.push(temp_item);
}
entry_items.sortOn(\"count_num\",Array.NUMERIC);
_root.myImages = [];
for (var i:Number = 0; i < entry_items.length; i++)
{
//trace(entry_items[i].count_num);
//trace(entry_items[i].entry);
_root.myImages[i] = entry_items[i].entry;
//trace(entry_items[i].entry.attributes.url);
}
/*****end of sort array******/
for (i = 0; i < _root.myImagesNo; i++)
{
temp_url = _root.myImages[i].attributes.url;
temp_mc = myContainer_mc.createEmptyMovieClip(i, myContainer_mc.getNextHighestDepth());
xml_time[i] = _root.myImages[i].attributes.duration;
//trace(\"this xml_time \" + xml_time[i]);
//_root.myImages.count_num = _root.myImages[i].attributes.count;
_root.myMCL.loadClip(temp_url,temp_mc);
}//i=0;
//
//_root.myImages = entry_items;
//trace(_root.myImages[0]);
}
_global.stop_time;
stop_time = 1000;
_global.num;
num = 0;
setTimer(stop_time);
function setTimer(stop_time)
{
myShowInt = setInterval(Timer_1, stop_time);
}
function Timer_1()
{
//trace(\"num is \" + num);
stop_time = xml_time[num];
//trace(\"this stop_time \" + xml_time[num]);
if (num < (_root.myImagesNo-1))
{
moveSlide();
num++;
} else {
moveSlide();
num = 0;
}
}
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);
clearInterval(myShowInt);
setTimer(stop_time);
}
=================
<?xml version=\"1.0\"?><slideshow id=\"18\"><image url=\"green.jpg\" title=\"\" duration=\"10000\" count=\"1\"/><image url=\"yellow.jpg\" title=\"\" duration=\"5000\" count=\"2\"/><image url=\"pink.jpg\" title=\"\" duration=\"1500\" count=\"3\"/><image url=\"red.jpg\" title=\"\" duration=\"3000\" count=\"4\"/><image url=\"blue.jpg\" title=\"\" duration=\"2000\" count=\"5\"/></slideshow>
===============
I need this code changed so my image files load in the same order as per the XML file. This does not occur currently due to the way Linux reads files from the HDD. From my research we first need to load all the files in one by one before we display them. This is not a big job, I just don\'t know how to re-code it.
=================
import mx.transitions.Tween;
import mx.transitions.easing.*;
var myShowXML = new XML();
myShowXML.ignoreWhite = true;
myShowXML.load(\"slideshow.xml?\"+Math.random());
//XMLUtils.sortXMLByAttribute(myShowXML,\'count\');
myShowXML.onLoad = function()
{
_root.myWidth = 1080;
_root.myHeight = 1920;
_root.mySpeed = 2;
_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;
}
_global.xml_time = new Array();
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 = \"Now 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);
}
};
//trace(_root.myClips_array);
//myImages.sortOn(sort_array.attributes.count);
//trace(_root.myImages);
//_root.myImages.sortOn(\"count\", Array.NUMERIC | Array.DESCENDING);
//_root.myImages.sortOn(\"count\", Array.NUMERIC | Array.DESCENDING);
//_root.myImages.sortOn (\"count\");
//
//trace(_root.myImages[0].attributes.count);
/*trace(_root.myImages[0]);
trace(_root.myImages[1]);
if(_root.myImages[1].attributes.count==1){
_root.myImages[0].attributes.url=_root.myImages[1].attributes.url;
trace(\"veve\");
}*/
//trace(_root.myImages);
/*****begin of sort array******/
var entry_items:Array = new Array();
for (var i:Number = 0; i < _root.myImagesNo; i++)
{
var temp_item:Object = new Object();
temp_item.count_num = Number(_root.myImages[i].attributes.count);
temp_item.entry = _root.myImages[i];
entry_items.push(temp_item);
}
entry_items.sortOn(\"count_num\",Array.NUMERIC);
_root.myImages = [];
for (var i:Number = 0; i < entry_items.length; i++)
{
//trace(entry_items[i].count_num);
//trace(entry_items[i].entry);
_root.myImages[i] = entry_items[i].entry;
//trace(entry_items[i].entry.attributes.url);
}
/*****end of sort array******/
for (i = 0; i < _root.myImagesNo; i++)
{
temp_url = _root.myImages[i].attributes.url;
temp_mc = myContainer_mc.createEmptyMovieClip(i, myContainer_mc.getNextHighestDepth());
xml_time[i] = _root.myImages[i].attributes.duration;
//trace(\"this xml_time \" + xml_time[i]);
//_root.myImages.count_num = _root.myImages[i].attributes.count;
_root.myMCL.loadClip(temp_url,temp_mc);
}//i=0;
//
//_root.myImages = entry_items;
//trace(_root.myImages[0]);
}
_global.stop_time;
stop_time = 1000;
_global.num;
num = 0;
setTimer(stop_time);
function setTimer(stop_time)
{
myShowInt = setInterval(Timer_1, stop_time);
}
function Timer_1()
{
//trace(\"num is \" + num);
stop_time = xml_time[num];
//trace(\"this stop_time \" + xml_time[num]);
if (num < (_root.myImagesNo-1))
{
moveSlide();
num++;
} else {
moveSlide();
num = 0;
}
}
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);
clearInterval(myShowInt);
setTimer(stop_time);
}
=================
<?xml version=\"1.0\"?><slideshow id=\"18\"><image url=\"green.jpg\" title=\"\" duration=\"10000\" count=\"1\"/><image url=\"yellow.jpg\" title=\"\" duration=\"5000\" count=\"2\"/><image url=\"pink.jpg\" title=\"\" duration=\"1500\" count=\"3\"/><image url=\"red.jpg\" title=\"\" duration=\"3000\" count=\"4\"/><image url=\"blue.jpg\" title=\"\" duration=\"2000\" count=\"5\"/></slideshow>
===============
Tim J.
0% (0)Projects Completed
-
Freelancers worked with
-
Projects awarded
0%
Last project
13 Mar 2026
Australia
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies