RE: [Flashcoders] Re: Help with Image Slideshow - displaying random image
> Won't the image and corresponding desc both > be scrambled in an array since I > want to display them together? Christopher, Have you considered adding each textfield as a child of each image container? Regards, Keith Reinfeld Home Page: http://keithreinfeld.home.comcast.net ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Re: Help with Image Slideshow - displaying random image
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 = ; 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.=new Vector.(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 Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Re: Help with Image Slideshow - displaying random image (Anthony Pace)
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 = ; 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.=new Vector.(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); } On 1/22/2011 4:41 PM, Anthony Pace wrote: Sorry I took so long. I had no internet at home for that past couple of days. ...Well, you don't really have to make it an array. I guess I should have said, use it like you would an array. Since it seems you want to know how to keep the original order and have a new list with a randomized order,for ease of use, I figured you might want an XMLList, so I made the example below. //there is another way without duplicating data in memory, but I figure this might be easy to work with. var ss:XML = ; var imgList:XMLList = ss.IMAGE; 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); trace(imgList); On 1/21/2011 3:47 PM, Christopher Lucas wrote: Anthony, Thanks for your response. I conceptually understand Arrays, but really am lost in how they work with AS3. Any change you might be willing to show me how this would be done? Won't the image and corresponding desc both be scrambled in an array since I want to display them together? Thanks ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Re: Help with Image Slideshow - displaying random image (Anthony Pace)
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 list 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 examplevar ss:XML =SRC="images1.jpg" DESC="Rome"/> ; 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.=new Vector.(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); } On 1/22/2011 4:41 PM, Anthony Pace wrote: Sorry I took so long. I had no internet at home for that past couple of days. ...Well, you don't really have to make it an array. I guess I should have said, use it like you would an array. Since it seems you want to know how to keep the original order and have a new list with a randomized order,for ease of use, I figured you might want an XMLList, so I made the example below. //there is another way without duplicating data in memory, but I figure this might be easy to work with. var ss:XML = ; var imgList:XMLList = ss.IMAGE; 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); trace(imgList); On 1/21/2011 3:47 PM, Christopher Lucas wrote: Anthony, Thanks for your response. I conceptually understand Arrays, but really am lost in how they work with AS3. Any change you might be willing to show me how this would be done? Won't the image and corresponding desc both be scrambled in an array since I want to display them together? Thanks ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Re: Help with Image Slideshow - displaying random image (Anthony Pace)
Sorry I took so long. I had no internet at home for that past couple of days. ...Well, you don't really have to make it an array. I guess I should have said, use it like you would an array. Since it seems you want to know how to keep the original order and have a new list with a randomized order,for ease of use, I figured you might want an XMLList, so I made the example below. //there is another way without duplicating data in memory, but I figure this might be easy to work with. var ss:XML = ; var imgList:XMLList = ss.IMAGE; 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); trace(imgList); On 1/21/2011 3:47 PM, Christopher Lucas wrote: Anthony, Thanks for your response. I conceptually understand Arrays, but really am lost in how they work with AS3. Any change you might be willing to show me how this would be done? Won't the image and corresponding desc both be scrambled in an array since I want to display them together? Thanks ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders