# Pre-loading a random image in Flash in a different scene

**URL:** <https://forum.kirupa.com/t/pre-loading-a-random-image-in-flash-in-a-different-scene/237236>\
**Category:** Uncategorized\
**Created:** [August 28, 2007, 1:11pm UTC](https://forum.kirupa.com/t/pre-loading-a-random-image-in-flash-in-a-different-scene/237236 "2007-08-28T13:11:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![JayHunt](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@JayHunt](https://forum.kirupa.com/u/JayHunt)\
**Post date:** [August 28, 2007, 1:11pm UTC](https://forum.kirupa.com/t/pre-loading-a-random-image-in-flash-in-a-different-scene/237236/1 "2007-08-28T13:11:25Z")

</div>

[FONT=Times New Roman][SIZE=3]Hello,[/SIZE][/FONT]  
[SIZE=3][FONT=Times New Roman]I am trying to load an image at random in Flash. I have the image moving across the stage when the user first comes to the site. I have a pre-loader on the movie, but after the movie loads it goes to scene 2 and the random image still has to load. Is there away to load the image in scene 1 where the pre-loader is? Here is my random image script that I have in scene 2 where the image is.[/FONT][/SIZE]

[SIZE=3][FONT=Times New Roman]MovieClip.prototype.setRand = function() {[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]largest= 10;[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]lowest = 1;[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]rand = ((Math.floor(Math.random()\*100)%(largest-lowest+1))+lowest);[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]loadMovie(“indexpic/”+rand+".jpg", “empty”);[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]}[/FONT][/SIZE]

[FONT=Times New Roman][SIZE=3]setRand();[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]here is my pre-loader script in scene 1[/SIZE][/FONT]

[SIZE=3][FONT=Times New Roman]bytes\_loaded = Math.round(\_root.getBytesLoaded());[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]bytes\_total = Math.round(\_root.getBytesTotal());[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]getPercent = bytes\_loaded/bytes\_total;[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]\_root.loadBar.\_width = getPercent_100;[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]\_root.loadText = Math.round(getPercent_100)+"%";[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]if (bytes\_loaded == bytes\_total) {[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]gotoAndPlay(“Scene 2”, 1);[/FONT][/SIZE]  
[FONT=Times New Roman][SIZE=3]}[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]Thanks,[/SIZE][/FONT]
