sriframes
asked on
selecting random images for flash banner
Hi,
I had a image slider. you can see that here. http://www.sriframes.com/sliders/22gallery.html.
all data is loading from xml. there is about 1050 images... in that . I want to load images RANDOMLY say 20 images in that xml. if browser refresh loding images should change . IS there any chance.?
regards,
sriframes..
I had a image slider. you can see that here. http://www.sriframes.com/sliders/22gallery.html.
all data is loading from xml. there is about 1050 images... in that . I want to load images RANDOMLY say 20 images in that xml. if browser refresh loding images should change . IS there any chance.?
regards,
sriframes..
ASKER
I think it is AS2.
here is script :
function MoveImages()
{
var _loc3 = center - this._xmouse;
var _loc2 = Stage.width - mainHolder._width;
if (this._xmouse >= mainHolder._x && this._ymouse < 200)
{
mainHolder._x = mainHolder._x + _loc3 / 200;
} // end if
if (mainHolder._x >= 0)
{
mainHolder._x = 0;
}
else if (mainHolder._x <= _loc2)
{
mainHolder._x = _loc2 - 0;
} // end else if
} // End of the function
loadVariables("22gallery.h tml", "POST");
Stage.align = "BL";
var myxml = new XML();
var mypath = new Object();
var xpos = 1;
var j = 1;
var center = Stage.width / 2;
this.createEmptyMovieClip( "mainHolde r", getNextHighestDepth());
mainHolder._x = -10;
mainHolder._y = 0;
_root.nextButton.swapDepth s(110);
_root.overImage.swapDepths (100);
_root.leftBar.swapDepths(1 05);
_root.previousButton.swapD epths(115) ;
myxml.ignoreWhite = true;
demo.text = flashvars;
valuename = flashvars1.text;
flashvars1.text = "\"" + flashvars1.text + "\"";
xmlfile = flashvars1.text;
myxml.load(flashvars);
myxml.onLoad = function (s)
{
if (s)
{
var _loc2 = myxml.firstChild.childNode s.length;
for (var _loc1 = 0; _loc1 < _loc2; ++_loc1)
{
mypath.path = myxml.firstChild.childNode s[_loc1].c hildNodes[ 4].firstCh ild.nodeVa lue;
mainHolder.attachMovie("th umb", "t" + _loc1, mainHolder.getNextHighestD epth(), mypath);
mainHolder["t" + _loc1]._x = xpos;
xpos = xpos + mainHolder["t" + _loc1]._width + 1;
mainHolder["t" + _loc1].productName.status_ txt.text = myxml.firstChild.childNode s[_loc1].c hildNodes[ 0].firstCh ild.nodeVa lue;
mainHolder["t" + _loc1].sellingPrice.status _txt.text = myxml.firstChild.childNode s[_loc1].c hildNodes[ 1].firstCh ild.nodeVa lue;
mainHolder["t" + _loc1].review.status_txt.t ext = myxml.firstChild.childNode s[_loc1].c hildNodes[ 2].firstCh ild.nodeVa lue;
banner_link = myxml.firstChild.childNode s[_loc1].c hildNodes[ 3].firstCh ild.nodeVa lue;
mainHolder["t" + _loc1].banner_mc.frame_url .text = banner_link;
trace (myxml.firstChild.childNod es[_loc1]. childNodes [3].firstC hild.nodeV alue);
} // end of for
}
else
{
trace ("XML NOT LOADED");
} // end else if
};
here is script :
function MoveImages()
{
var _loc3 = center - this._xmouse;
var _loc2 = Stage.width - mainHolder._width;
if (this._xmouse >= mainHolder._x && this._ymouse < 200)
{
mainHolder._x = mainHolder._x + _loc3 / 200;
} // end if
if (mainHolder._x >= 0)
{
mainHolder._x = 0;
}
else if (mainHolder._x <= _loc2)
{
mainHolder._x = _loc2 - 0;
} // end else if
} // End of the function
loadVariables("22gallery.h
Stage.align = "BL";
var myxml = new XML();
var mypath = new Object();
var xpos = 1;
var j = 1;
var center = Stage.width / 2;
this.createEmptyMovieClip(
mainHolder._x = -10;
mainHolder._y = 0;
_root.nextButton.swapDepth
_root.overImage.swapDepths
_root.leftBar.swapDepths(1
_root.previousButton.swapD
myxml.ignoreWhite = true;
demo.text = flashvars;
valuename = flashvars1.text;
flashvars1.text = "\"" + flashvars1.text + "\"";
xmlfile = flashvars1.text;
myxml.load(flashvars);
myxml.onLoad = function (s)
{
if (s)
{
var _loc2 = myxml.firstChild.childNode
for (var _loc1 = 0; _loc1 < _loc2; ++_loc1)
{
mypath.path = myxml.firstChild.childNode
mainHolder.attachMovie("th
mainHolder["t" + _loc1]._x = xpos;
xpos = xpos + mainHolder["t" + _loc1]._width + 1;
mainHolder["t" + _loc1].productName.status_
mainHolder["t" + _loc1].sellingPrice.status
mainHolder["t" + _loc1].review.status_txt.t
banner_link = myxml.firstChild.childNode
mainHolder["t" + _loc1].banner_mc.frame_url
trace (myxml.firstChild.childNod
} // end of for
}
else
{
trace ("XML NOT LOADED");
} // end else if
};
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
how you're going to do it depends on a number of things.
1. AS2 or AS3.
2. do you want unique random numbers.
the best way to do it is probably load the xml into an array.
have a look in the help files for generating random numbers.
pop your numbers into a new array for the 20.
use a for loop to pull those images.