Solved

selecting random images for flash banner

Posted on 2008-10-27
3
288 Views
Last Modified: 2013-11-11
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..

0
Comment
Question by:sriframes
  • 2
3 Comments
 
LVL 39

Expert Comment

by:blue-genie
ID: 22813211
yes it is doable.
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.

0
 

Author Comment

by:sriframes
ID: 22814202
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.html", "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("mainHolder", getNextHighestDepth());
mainHolder._x = -10;
mainHolder._y = 0;
_root.nextButton.swapDepths(110);
_root.overImage.swapDepths(100);
_root.leftBar.swapDepths(105);
_root.previousButton.swapDepths(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.childNodes.length;
        for (var _loc1 = 0; _loc1 < _loc2; ++_loc1)
        {
            mypath.path = myxml.firstChild.childNodes[_loc1].childNodes[4].firstChild.nodeValue;
            mainHolder.attachMovie("thumb", "t" + _loc1, mainHolder.getNextHighestDepth(), mypath);
            mainHolder["t" + _loc1]._x = xpos;
            xpos = xpos + mainHolder["t" + _loc1]._width + 1;
            mainHolder["t" + _loc1].productName.status_txt.text = myxml.firstChild.childNodes[_loc1].childNodes[0].firstChild.nodeValue;
            mainHolder["t" + _loc1].sellingPrice.status_txt.text = myxml.firstChild.childNodes[_loc1].childNodes[1].firstChild.nodeValue;
            mainHolder["t" + _loc1].review.status_txt.text = myxml.firstChild.childNodes[_loc1].childNodes[2].firstChild.nodeValue;
            banner_link = myxml.firstChild.childNodes[_loc1].childNodes[3].firstChild.nodeValue;
            mainHolder["t" + _loc1].banner_mc.frame_url.text = banner_link;
            trace (myxml.firstChild.childNodes[_loc1].childNodes[3].firstChild.nodeValue);
        } // end of for
    }
    else
    {
        trace ("XML NOT LOADED");
    } // end else if
};
0
 
LVL 39

Accepted Solution

by:
blue-genie earned 60 total points
ID: 22819373
just have a look in the help file on how to generate a random number
change your for loop length to 20, get a random number and put that into your xml instead of the variable

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now