# Load external jpg into button for dragging

**URL:** https://forum.kirupa.com/t/load-external-jpg-into-button-for-dragging/12926
**Category:** Uncategorized
**Created:** [February 6, 2003, 5:49am UTC](https://forum.kirupa.com/t/load-external-jpg-into-button-for-dragging/12926 "2003-02-06T05:49:14Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![codeAddict](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@codeAddict](https://forum.kirupa.com/u/codeAddict)
#### Post date: [February 6, 2003, 5:49am UTC](https://forum.kirupa.com/t/load-external-jpg-into-button-for-dragging/12926/1 "2003-02-06T05:49:14Z")

</div>

I need to load a jpg into a button. After that I want to be able to drag the button (and subsequently the loaded jpg). Currently I am able to load a jpg into levels but I can’t seem to get it to properly load into a button and then be draggable. And ideas?

---

<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: [February 6, 2003, 7:48am UTC](https://forum.kirupa.com/t/load-external-jpg-into-button-for-dragging/12926/2 "2003-02-06T07:48:46Z")

</div>

Why load into a button when you can make the container you load to a button?

Confused?

Try this…

```php
_root.createEmptyMovieClip("container",1);
container.loadMovie("photo.jpg");
container._x = container._y = 50 ;

_root.onMouseDown = function () {
	startDrag ("container",false) ;
}
_root.onMouseUp = function () {
	stopDrag () ;
}

```

First it creates an empty movie clip on the stage with the instance name “container”. This is all done dynamically through AS.

Next is uses loadMovie on that clip to load in an image called photo.jpg. Now Flash can only load in Non-Progressive .jpg images mind you, so be aware of this in the future if your images don’t load.

It then moves the container the \_x and \_y 50 ((x,y) coords)

After that it uses dynamic event handlers to detect wheter the container clip has the mouse pressed down on it. If so, it drags the clip, and if not, it stops dragging the clip.

If you have any questions or I am misunderstanding what you want, please let me know.

---

<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: [February 6, 2003, 9:20am UTC](https://forum.kirupa.com/t/load-external-jpg-into-button-for-dragging/12926/3 "2003-02-06T09:20:56Z")

</div>

What I think he’s saying is that he wants to be able to drag the button around on the scene - not in the main .swf but rather to be able to place it where he wants instead of having to adjust it accordingly through code. \>But could be wrong\<

---

<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: [February 6, 2003, 2:52pm UTC](https://forum.kirupa.com/t/load-external-jpg-into-button-for-dragging/12926/4 "2003-02-06T14:52:55Z")

</div>

lost,

let’s say you had a folder of images - 1.jpg, 2.jpg, … 10.jpg and you wanted to load them all as separate draggable (and resizable!) files. How would you adjust the code to create an EmptyMovieClip for each that was draggable, resizable?

curious,  
JCS  
(-:

---

<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: [February 6, 2003, 5:54pm UTC](https://forum.kirupa.com/t/load-external-jpg-into-button-for-dragging/12926/5 "2003-02-06T17:54:22Z")

</div>

Well it would pretty much be the same, except for resizeability you would need to set something else up.

Usually components are used for that kind of thing, which I don’t think you can attach to a dynamically created clip.

---

<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: [February 6, 2003, 6:04pm UTC](https://forum.kirupa.com/t/load-external-jpg-into-button-for-dragging/12926/6 "2003-02-06T18:04:29Z")

</div>

Thanks for the quick replies. I don’t care whether I use buttons or a component. In the end I want to be able to do the following:

(1) In the params/embed section pass in a jpeg filename

FlashVars=“imageFile=someimage.jpg”

(2) Using \_root.imageFile I want to then attach the image located in the same directory as my .swf to something - a button, component, mov clip.

(3) So far I’ve tried to attach to buttons and mov clips without any great luck. I can get the image to load in the external jpg but I can’t make it draggable.

(4) So the tricky part for me is in attaching it to something that will allow me to manipulate and drag the image around. For example, I would like to drap and drop the image, be able to scale the image using \_xscale and \_yscale, and also align the image using \_x and \_y.

I hope that’s a better description of the problem and I’ll try your ideas tonight. 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: [February 6, 2003, 6:18pm UTC](https://forum.kirupa.com/t/load-external-jpg-into-button-for-dragging/12926/7 "2003-02-06T18:18:24Z")

</div>

It sounds like you are trying to do something like this…

[http://www.flashcomponents.net/component.cfm?nav=2&id=103](http://www.flashcomponents.net/component.cfm?nav=2&id=103)

I don’t know if you will be able to use something like that for a dynamically loaded image.

What you can try is to create an empty movie clip on the stage, attach the component to that, and load your .jpg to that clip.

Or you could can put another empty movie clip inside that empty movie clip and load the .jpg to that and see if it will work.

IF these don’t work, then I don’t think you can do it.

---

<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: [February 6, 2003, 6:24pm UTC](https://forum.kirupa.com/t/load-external-jpg-into-button-for-dragging/12926/8 "2003-02-06T18:24:47Z")

</div>

There is also this…

[http://www.flashcomponents.net/component.cfm?nav=2&id=132](http://www.flashcomponents.net/component.cfm?nav=2&id=132)
