# Random Boss

**URL:** <https://forum.kirupa.com/t/random-boss/20703>\
**Category:** flash\
**Created:** [May 12, 2003, 3:51pm UTC](https://forum.kirupa.com/t/random-boss/20703 "2003-05-12T15:51:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabriel\_muldoon](https://avatars.discourse-cdn.com/v4/letter/g/5daacb/32.png) [@gabriel\_muldoon](https://forum.kirupa.com/u/gabriel_muldoon)\
**Post date:** [May 12, 2003, 3:51pm UTC](https://forum.kirupa.com/t/random-boss/20703/1 "2003-05-12T15:51:11Z")

</div>

How do you load a random jpeg or swf file into a main swf file?

Cheers.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 12, 2003, 4:16pm UTC](https://forum.kirupa.com/t/random-boss/20703/2 "2003-05-12T16:16:36Z")

</div>

If your pics or swf are named 1.jpg 2.jpg or 1.swf 2.swf and so on you could put this code in your first frame:[AS]empty.loadMovie(random(5)+".jpg");[/AS]  
Of course you have to create an empty MC, place it on your scene and call it empty (or whatever you like…)  
5 is the number of pictures that you should load. All files has to be in the same folder, otherwise you have to specify where the pics are.

[size=1][edit][/size]  
The random() function is deprecated, but I still use it… Easier to write than Math.random… But if you use Math.random the code would be:  
[AS]empty.loadMovie(Math.floor(Math.random()\*5)+".jpg");[/AS]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 13, 2003, 8:01am UTC](https://forum.kirupa.com/t/random-boss/20703/3 "2003-05-13T08:01:17Z")

</div>

good man.
