# Quick Flash MX question

**URL:** <https://forum.kirupa.com/t/quick-flash-mx-question/8033>\
**Category:** flash\
**Created:** [November 12, 2002, 9:01pm UTC](https://forum.kirupa.com/t/quick-flash-mx-question/8033 "2002-11-12T21:01:51Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Casenote](https://avatars.discourse-cdn.com/v4/letter/c/82dd89/32.png) [@Casenote](https://forum.kirupa.com/u/Casenote)\
**Post date:** [November 12, 2002, 9:01pm UTC](https://forum.kirupa.com/t/quick-flash-mx-question/8033/1 "2002-11-12T21:01:51Z")

</div>

Hi,

I am trying to load a random jpg into a flash movie…I do not want it to be the background, so the (loading a random background tutorial did not help…I am sure it held alot of the concepts that I need to know)

I am new to flash and am not good at actionscript…

I realize that I need to create x number of swf files for the load…

but I do not know how to tell it where to load it…place it

( x 15.1 y 0 )

if you can help me I would highly appreciate it

thanks

Casey

---

<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:** [November 12, 2002, 9:16pm UTC](https://forum.kirupa.com/t/quick-flash-mx-question/8033/2 "2002-11-12T21:16:41Z")

</div>

```auto

_root.createemptymovieclip("empty");
empty._x=15;
empty._y=0;
empty.loadMovie("mymovie.jpg");

```

hope it helps.

---

<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:** [November 12, 2002, 9:19pm UTC](https://forum.kirupa.com/t/quick-flash-mx-question/8033/3 "2002-11-12T21:19:37Z")

</div>

How do I load this image so that it chooses a random swf?

thanks thus far, you replied super fast, I appreciate it

Casey

---

<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:** [November 12, 2002, 10:29pm UTC](https://forum.kirupa.com/t/quick-flash-mx-question/8033/4 "2002-11-12T22:29:52Z")

</div>

Well… a few ways, I guess.

What are your swf’s called?

How many are there?

You could load your swf names into an array, and choose a random number from the array…

```auto

myarray=["first.swf","second.swf","third.swf"];

picker=math.floor(math.random()*((2)+1));//pick zero, one, or two

mymovie.loadmovie(myarray[picker]);//pick an item from array

```

so, combine both posts, and you should have what you want. Let me know if you have questions.

---

<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:** [November 12, 2002, 10:49pm UTC](https://forum.kirupa.com/t/quick-flash-mx-question/8033/5 "2002-11-12T22:49:06Z")

</div>

First off your the man!

I have 6 swf’s

they are called

random1.swf  
random2.swf  
ect…

I was wondering if I had to make these into swf’s or could just leave them as jpg’s?

they are loading into in 200px x 200px portion in the middle of the movie.

Oh yeah…you are the man

Casey

---

<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:** [November 12, 2002, 10:53pm UTC](https://forum.kirupa.com/t/quick-flash-mx-question/8033/6 "2002-11-12T22:53:10Z")

</div>

Yes… Montoya is the man 🙂

---

<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:** [November 12, 2002, 10:53pm UTC](https://forum.kirupa.com/t/quick-flash-mx-question/8033/7 "2002-11-12T22:53:29Z")

</div>

in MX, they can be jpg or swf’s. It doesnt matter.

Nah… Im a rookie! But, thanks! Always glad to help!

---

<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:** [November 12, 2002, 10:55pm UTC](https://forum.kirupa.com/t/quick-flash-mx-question/8033/8 "2002-11-12T22:55:16Z")

</div>

Modest too 😛

---

<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:** [November 21, 2002, 7:51pm UTC](https://forum.kirupa.com/t/quick-flash-mx-question/8033/9 "2002-11-21T19:51:52Z")

</div>

I have 8 jpgs

random1.jpg - random8.jpg

```auto

_root.createemptymovieclip("empty");
empty._x=15;
empty._y=0;

myarray=["random1.jpg","random2.jpg","random3.jpg","random4.jpg","random5.jpg","random6.jpg","random8.jpg"];

****this is where I get confused*********

picker=math.floor(math.random()*((2)+1));//pick zero, one, or two

mymovie.loadmovie(myarray[picker]);//pick an item from array

```

also does it matter where I place these jpg’s, or do they have to be imported into the library?

If anyone could help I would appreciate, thanks

Case

---

<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:** [November 21, 2002, 9:24pm UTC](https://forum.kirupa.com/t/quick-flash-mx-question/8033/10 "2002-11-21T21:24:45Z")

</div>

Try this:

```php

picker = math.floor(math.random()*(4));// add 1 digit whenever u got more files

```

Hope it helps!

yours,  
h88

---

<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:** [November 22, 2002, 4:04am UTC](https://forum.kirupa.com/t/quick-flash-mx-question/8033/11 "2002-11-22T04:04:14Z")

</div>

Do I need to load the jpgs in the library…

Case

---

<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:** [November 24, 2002, 12:05am UTC](https://forum.kirupa.com/t/quick-flash-mx-question/8033/12 "2002-11-24T00:05:36Z")

</div>

Ok guys

here’s what i got

```auto

_root.createemptymovieclip("empty");
empty._x=133;
empty._y=0;
myarray=["random1.jpg","random2.jpg","random3.jpg","random4.jpg","random5.jpg","random6.jpg","random8.jpg"];
picker = math.floor(math.random()*(4));// add 1 digit whenever u got more files
mymovie.loadmovie(myarray[picker]);//pick an item from array

```

when I insert this EXACTLY into my movie nothing happens…  
I don’t know what I am doing wrong but could definitly use some help…

Thanks so much already guys,

Casey

p.s. I know the x,y values are different…but they are correct…fyi…to clear up any confusion

---

<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:** [November 24, 2002, 10:36am UTC](https://forum.kirupa.com/t/quick-flash-mx-question/8033/13 "2002-11-24T10:36:45Z")

</div>

```php
_root.createEmptyMovieClip("empty", 1);
empty._x = 133;
empty._y = 0;
myarray = ["random1.jpg", "random2.jpg", "random3.jpg", "random4.jpg", "random5.jpg", "random6.jpg", "random7.jpg"];
picker = Math.floor(Math.random()*(7));
// add 1 digit whenever u got more files
empty.loadMovie(myarray[picker]);
//pick an item from array

```

---

<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:** [November 24, 2002, 6:14pm UTC](https://forum.kirupa.com/t/quick-flash-mx-question/8033/14 "2002-11-24T18:14:38Z")

</div>

Still to know avail will this load the images into the movie…I tried converting the jpg’s into swf’s and trying that way as well…

…and still I am speechless

do I need to import them into my libarary under those specific names? or just have them in the same directory as my movie?

any how if anyone can see what the problem is I am dying to figure it out

h88 Thanks so far for the help…

Casey

---

<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:** [November 24, 2002, 7:35pm UTC](https://forum.kirupa.com/t/quick-flash-mx-question/8033/15 "2002-11-24T19:35:06Z")

</div>

hi h88,  
this code works greate with me, but when i want to use it in onPress function it didn’t work… ☹

```php

_root.createEmptyMovieClip("holder", 1);
holder._x = 50;
holder._y = 50;
myArray = ["1.jpg", "2.jpg", "3.jpg", "4.jpg", "5.jpg"];
picker = Math.floor(Math.random()*(5));
_root.my_mc.onPress = function() {
	_root.holder.loadMovie(myArray[picker]);
};

```

itried to but onPress in looping function (onEnterFrame) but the same …  
can i do it with onPress… :q:

thanx C:-)

---

<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:** [November 24, 2002, 7:47pm UTC](https://forum.kirupa.com/t/quick-flash-mx-question/8033/16 "2002-11-24T19:47:48Z")

</div>

I want this to load into movie on frame 25

Maybe this will help, but currently I am just pasting the above code into the action script?

Thanks

Casey

---

<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:** [November 24, 2002, 7:59pm UTC](https://forum.kirupa.com/t/quick-flash-mx-question/8033/17 "2002-11-24T19:59:29Z")

</div>

so what is your Prob.?  
put the code in frame 25 … 🙂

---

<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:** [November 24, 2002, 8:41pm UTC](https://forum.kirupa.com/t/quick-flash-mx-question/8033/18 "2002-11-24T20:41:47Z")

</div>

I do put the code in 25th frame, I have the listed jpgs in the same directory and loaded in the libarary…but it still pulls up nothing

Casey

---

<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:** [November 24, 2002, 9:06pm UTC](https://forum.kirupa.com/t/quick-flash-mx-question/8033/19 "2002-11-24T21:06:20Z")

</div>

nothing nothing…  
or load one jpg, just one…  
try the code i used it’s working with me. 🙂  
but if you load one jpg … it’s work too but it’ll change to another one when reach frame 25 for second time…

i think you need it change all time not in specific frame… RIGHT?  
i hope you fix your Prob.

C:-)

---

<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:** [November 24, 2002, 9:41pm UTC](https://forum.kirupa.com/t/quick-flash-mx-question/8033/20 "2002-11-24T21:41:41Z")

</div>

Huh, i always test something when i post here, check the attached zip, and don’t forget to unzip all the files in the same directory!

yours,  
h88

[Next page](https://forum.kirupa.com/t/quick-flash-mx-question/8033.md?page=2)
