# Dragging question

**URL:** https://forum.kirupa.com/t/dragging-question/18038
**Category:** Uncategorized
**Created:** [April 12, 2003, 1:33pm UTC](https://forum.kirupa.com/t/dragging-question/18038 "2003-04-12T13:33:47Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![RageW0lf](https://avatars.discourse-cdn.com/v4/letter/r/e495f1/32.png) [@RageW0lf](https://forum.kirupa.com/u/RageW0lf)
#### Post date: [April 12, 2003, 1:33pm UTC](https://forum.kirupa.com/t/dragging-question/18038/1 "2003-04-12T13:33:47Z")

</div>

I have been playing with dragging as I know nothing about it.  
I have my stage 500 x 500.

and following on from a tutorial I saw here on kirupa, I am loading a picture dynamically into flash, into a new movie clip which gets created, then making it draggable.  
Here is the code I am using:

```auto

_root.createEmptyMovieClip("container", 1);
container.loadMovie("photo.jpg");
container._x = 0;
container._y = 0;
h = 500 - (container._height);
w = 500 - (conatiner._width);
_root.onMouseDown = function() {
    startDrag("container", false, 0, 0, w, h);
};
_root.onMouseUp = function() {
    stopDrag();
};

```

ok What I am trying to do is keep the ENTIRE picture within the stage at ALL times. However currently if you grab the edge you can drag the picture off the stage until just the edge of the picture is showing.  
I thought (in my mind) this code would do this because “conatiner” would take the proportions of the picture… does it not?  
I am obviously doing something wrong, what would be the code to do this?  
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: [April 12, 2003, 2:37pm UTC](https://forum.kirupa.com/t/dragging-question/18038/2 "2003-04-12T14:37:15Z")

</div>

At the time you load, container (careful with the typos) still has a width and a height of 0. You must wait for the whole picture to load before you can do that.

pom :phil:

---

<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: [April 12, 2003, 3:23pm UTC](https://forum.kirupa.com/t/dragging-question/18038/3 "2003-04-12T15:23:35Z")

</div>

how do I do that?

onClipEventLoad?

---

<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: [April 12, 2003, 5:03pm UTC](https://forum.kirupa.com/t/dragging-question/18038/4 "2003-04-12T17:03:51Z")

</div>

You can’t use onClipEvent (load) because you have to use dynamic event handlers (dynamically created clip). Just set up an actionscript preloader. The code is all around here, but my favorite is here: [http://actionscript-toolbox.com/samplemx\_loadjpg.php](http://actionscript-toolbox.com/samplemx_loadjpg.php)

---

<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: [April 12, 2003, 5:38pm UTC](https://forum.kirupa.com/t/dragging-question/18038/5 "2003-04-12T17:38:52Z")

</div>

omg is looks like a total nightmareish hassle!! check my other drag question please!
