Which method would you like me to expand on?
On 1/24/2011 12:33 PM, Christopher Lucas wrote:
> Anthony, I agree, it is hard to read these emails...but anyway, you said:
>
> OOPS...thank goodness I re-read my last post... realized I screwed up,
> because the first version I made should actually modify your original xml.
> Wow, sometimes I wish this was like a web Forum and you could just click
> edit.
>
> I had used XMLList, when it should have been new XML, and you should be
> sending in the imgList.IMAGE section. As well, in addition the quick fix,
> I
> updated the code to show the different method that makes a randomized Typed
> Array (otherwise known as a vector) that points to the index locations in
> the original xml. Don't hesitate to tell me if I screwed up again.
>
>
> //Updated example
> var ss:XML =<SLIDESHOW SPEED="2"><IMAGE SRC="images1.jpg" DESC="Rome"/>
> <IMAGE SRC="images2.jpg" DESC="Paris"/>
> <IMAGE SRC="images3.jpg" DESC="Cairo"/>
> <IMAGE SRC="images4.jpg" DESC="London"/>
> <IMAGE SRC="images5.jpg" DESC="New Yor City"/>
> <IMAGE SRC="images6.jpg" DESC="Paris"/>
> <IMAGE SRC="images7.jpg" DESC="Tokyo"/>
> <IMAGE SRC="images8.jpg" DESC="Toronto"/>
> <IMAGE SRC="images9.jpg" DESC="Nepal"/>
> <IMAGE SRC="images10.jpg" DESC="Venice"/>
> <IMAGE SRC="images11.jpg" DESC="what"/>
> <IMAGE SRC="images12.jpg" DESC="ever"/>
> <IMAGE SRC="images13.jpg" DESC="you"/>
> <IMAGE SRC="images14.jpg" DESC="get"/>
> <IMAGE SRC="images15.jpg" DESC="the"/>
> <IMAGE SRC="images16.jpg" DESC="idea"/>
> </SLIDESHOW>;
> var imgList:XML = new XML(ss);
> function randXMLList(xl:XMLList):void{
> var sn:int;//swap number
> var xh:XML;//temp xml holder
> var i:int=0;
> var l:int = xl.length();
> while(i!=l){
> sn = Math.floor(Math.random() *l);
> xh = xl[i];
> xl[i] = xl[sn];
> xl[sn] = xh;
> ++i;
> }
> }
> randXMLList(imgList.IMAGE);
> trace('............original xml...........\n'+ss.IMAGE+'\n\n');
> trace('..........New Modified xml.........\n'+imgList.IMAGE+'\n\n');
> //different method
> var l:int = ss.IMAGE.length();
> var randi:Vector.<int>=new Vector.<int>(l,true);//random array for index
> values
> var tv:int;//temp value
> var sn:int;//swap number
> for(var i:int = 0; i!=l;++i){
> randi[i]=i;
> }
> trace('...original order...\n'+randi+'\n');
> for(i=0;i!=l;++i){
> sn = Math.floor(Math.random()*l);
> tv = randi[sn];
> randi[sn] = randi[i];
> randi[i] = tv;
> }
> trace('...modified order...\n'+randi+'\n\n...IMAGE SRC values...');
> //example of how to make use of it
> for(i=0;i!=l;++i){
> trace(ss.IMAGE[randi[i]].@SRC);
> }
>
> I'm confused.... are you listing the path to the image and desc in the AS3
> code? I'm lost in what you have posted. I have over 300 images that are
> contained in my XML file. With more likely to be added.
> Sorry to be dense, but I'm not understanding your method. Any chance you
> can
> expand??
> Thanks!
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Are you saying the XML (<IMAGE SRC="images2.jpg" DESC="Paris"/> and all
other tags like this) be part of the AS3 code like in your example?
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders