# Load diferent jpegs using variables

**URL:** https://forum.kirupa.com/t/load-diferent-jpegs-using-variables/21907
**Category:** Uncategorized
**Created:** [May 27, 2003, 9:29pm UTC](https://forum.kirupa.com/t/load-diferent-jpegs-using-variables/21907 "2003-05-27T21:29:51Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Felipe\_Bastos](https://avatars.discourse-cdn.com/v4/letter/f/f05b48/32.png) [@Felipe\_Bastos](https://forum.kirupa.com/u/Felipe_Bastos)
#### Post date: [May 27, 2003, 9:29pm UTC](https://forum.kirupa.com/t/load-diferent-jpegs-using-variables/21907/1 "2003-05-27T21:29:51Z")

</div>

Hey 🙂  
I have the same button several times in a loaded swf.  
On release, I want this buttons to attach a “mcextra” into target x  
This mcextra moves on vertical position and shows inside a jpeg.  
How can I use the same code to all the buttons so I can attach the mcextra and load diferent jpeg images? I guess I`ll have to set a variable calling the jpeg, isn`t?

Thanks

---

<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 28, 2003, 4:03pm UTC](https://forum.kirupa.com/t/load-diferent-jpegs-using-variables/21907/2 "2003-05-28T16:03:54Z")

</div>

Hi,  
You probably need to write an array rather than set a var, tho difficult to say without seeing your file.  
can you post an fla ?

SteveD

---

<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 29, 2003, 10:06am UTC](https://forum.kirupa.com/t/load-diferent-jpegs-using-variables/21907/3 "2003-05-29T10:06:49Z")

</div>

Hi,

Your post contradicts itself, but I am guessing that you want to dynamically load Jpegs into a movieclip that then scrolls vertically?

The easiest way would be to create a function that loads a jpeg into the “mcextra” clip.

loadmovie (pic, mcextra)

‘Pic’ would be the variable for the jpegs. Then to scroll it just manipulate the ‘mcextra.\_y’ value.

As for the buttons you just put,

onpress  
pic=“jpegname.jpg”

Each button has a different pic value, depending on the jpeg, then call the function to load and scroll it.

Those are the basics, just look up tutorials on functions if you need more help.

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 29, 2003, 3:02pm UTC](https://forum.kirupa.com/t/load-diferent-jpegs-using-variables/21907/4 "2003-05-29T15:02:27Z")

</div>

Hey guys!  
I got some help from a friend and we used the following solution.

In the first frame of the main timeline we created this function:

function loadextra (i) {  
// here it attaches the mc into an empty mc  
\_root.attachextra.attachMovie(“mcextra”, “mcextra”, 1);  
// here it sets the final Y position for the attached mc  
\_root.attachextra.posY = 400;  
// here it loads the image into “loadimg” inside mc extra  
\_root.attachextra.mcextra.loadimg.loadMovie ( i + “.jpg”, 1);  
}

On the button action we set:

on(release) {  
// call the function and set the parameter to load the img  
\_root.loadextra(“art/images/img” + “01”);  
}

Thanks for your help!  
🙂
