# Problems with loaded movieclips

**URL:** https://forum.kirupa.com/t/problems-with-loaded-movieclips/185069
**Category:** Uncategorized
**Created:** [April 10, 2006, 6:29pm UTC](https://forum.kirupa.com/t/problems-with-loaded-movieclips/185069 "2006-04-10T18:29:11Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Maarten\_Lierop](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Maarten\_Lierop](https://forum.kirupa.com/u/Maarten_Lierop)
#### Post date: [April 10, 2006, 6:29pm UTC](https://forum.kirupa.com/t/problems-with-loaded-movieclips/185069/1 "2006-04-10T18:29:11Z")

</div>

Hi there!

I am trying to make mc’s wich are loaded (by data wich stored in a database) on the internet draggable.  
This should be easy, but for some reason it won’t work.  
My code looks like this:

```auto

AnDo = new LoadVars()
AnDo.load("http://www.maartenlierop.nl/janv/janv.php") 
AnDo.onLoad = function(succes){
    if(succes){
        trace("communicatie succesvol");
        for(var i=0; i<this.cant; i++){
// loading the movieclips, and put them on their place
            createEmptyMovieClip (AnDo["instance"+i], i)
            loadMovie(AnDo["link"+i], AnDo["instance"+i]);
            setProperty (AnDo["instance"+i], _x, Ando["xpos"+i]);
            setProperty (AnDo["instance"+i], _y, Ando["ypos"+i]);
// this part shopuld make the loaded movieclip draggable, but this won't work
            AnDo["instance"+i].onPress = function () {
                AnDo["instance"+i]._x = mouse_x;
                AnDo["instance"+i]._y = mouse_y;
            }
            trace (AnDo["instance"+i]);
        }
    }else{
        trace("communicatie niet succesvol");
    }
}

```

Please note that for some reason i have to use the setproperty command to put the movieclips on place. When i change the setproperty method to

```auto

AnDo["instance"+i].[COLOR=#000084]_x[/COLOR] = Ando["xpose"+i];

```

it should de exactly the same, but in my case this won’t work anymore.

I’m right now only testing this script in a empty movieclip. Could anybody tell my what’s wrong here?

---

<div class="post-metadata">

### Author: ![JoshuaJonah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshuajonah/32/1775_2.png) [@JoshuaJonah](https://forum.kirupa.com/u/JoshuaJonah)
#### Post date: [April 10, 2006, 6:33pm UTC](https://forum.kirupa.com/t/problems-with-loaded-movieclips/185069/2 "2006-04-10T18:33:23Z")

</div>

What dont you just use the drag function? Example:

```auto
something.onPress = function(){
   startDrag();
}
something.onRelease = function(){
   stopDrag();
}

```

---

<div class="post-metadata">

### Author: ![Maarten\_Lierop](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Maarten\_Lierop](https://forum.kirupa.com/u/Maarten_Lierop)
#### Post date: [April 10, 2006, 6:46pm UTC](https://forum.kirupa.com/t/problems-with-loaded-movieclips/185069/3 "2006-04-10T18:46:12Z")

</div>

hi!

Thanks fir your time.  
Using the startdrag was the first thing i tried. But it didn’t work so i started to look for other ways to get this working. But without succes.

Is there something wrong in the way i am using the variable instancename for the mc’s?

---

<div class="post-metadata">

### Author: ![JoshuaJonah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshuajonah/32/1775_2.png) [@JoshuaJonah](https://forum.kirupa.com/u/JoshuaJonah)
#### Post date: [April 10, 2006, 6:51pm UTC](https://forum.kirupa.com/t/problems-with-loaded-movieclips/185069/4 "2006-04-10T18:51:11Z")

</div>

Try this:

```auto
AnDo = new LoadVars()
AnDo.load("http://www.maartenlierop.nl/janv/janv.php") 
AnDo.onLoad = function(succes){
    if(succes){
        trace("communicatie succesvol");
        for(var i=0; i<this.cant; i++){
// loading the movieclips, and put them on their place
            var dragclip:MovieClip = createEmptyMovieClip (AnDo["instance"+i], i)
            loadMovie(AnDo["link"+i], AnDo["instance"+i]);
            setProperty (AnDo["instance"+i], _x, Ando["xpos"+i]);
            setProperty (AnDo["instance"+i], _y, Ando["ypos"+i]);
// this part shopuld make the loaded movieclip draggable, but this won't work
            dragclip.onPress = function () {
                this.startDrag();
            }
            trace (dragclip);
        }
    }else{
        trace("communicatie niet succesvol");
    }
}

```

---

<div class="post-metadata">

### Author: ![Maarten\_Lierop](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Maarten\_Lierop](https://forum.kirupa.com/u/Maarten_Lierop)
#### Post date: [April 10, 2006, 6:57pm UTC](https://forum.kirupa.com/t/problems-with-loaded-movieclips/185069/5 "2006-04-10T18:57:57Z")

</div>

Hi,

the result is :  
communicatie succesvol  
undefined  
undefined

and the movieclips are not draggable

this ‘undefined’ wories me somehow

---

<div class="post-metadata">

### Author: ![JoshuaJonah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshuajonah/32/1775_2.png) [@JoshuaJonah](https://forum.kirupa.com/u/JoshuaJonah)
#### Post date: [April 10, 2006, 7:09pm UTC](https://forum.kirupa.com/t/problems-with-loaded-movieclips/185069/6 "2006-04-10T19:09:42Z")

</div>

What did it trace before? and why does the name of the object have to be the value of that array item?

```auto
AnDo = new LoadVars()
AnDo.load("http://www.maartenlierop.nl/janv/janv.php") 
AnDo.onLoad = function(succes){
    if(succes){
        trace("communicatie succesvol");
        for(var i=0; i<this.cant; i++){
// loading the movieclips, and put them on their place
            var dragclip:MovieClip = createEmptyMovieClip ("dragger"+i, i)
            var link:String = eval(AnDo["link"+i])
            dragclip.loadMovie(link);
            dragclip._x = Ando["xpos"+i];
            dragclip._y = Ando["ypos"+i];
// this part shopuld make the loaded movieclip draggable, but this won't work
            dragclip.onPress = function () {
                this.startDrag();
            }
            trace (dragclip);
        }
    }else{
        trace("communicatie niet succesvol");
    }
}

```

---

<div class="post-metadata">

### Author: ![Maarten\_Lierop](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Maarten\_Lierop](https://forum.kirupa.com/u/Maarten_Lierop)
#### Post date: [April 10, 2006, 7:31pm UTC](https://forum.kirupa.com/t/problems-with-loaded-movieclips/185069/7 "2006-04-10T19:31:28Z")

</div>

My previous trace actions did show “undefined”, that’s why i think something is wrong with the names, but i don’t know what.

When i change the trace-action as below

```auto

            trace ("dragclip : " + dragclip);
            trace ("name : " + AnDo[instance]);

```

the result becomes

communicatie succesvol  
dragclip :  
name : anekdote03  
dragclip :  
name : anekdote04

dragclip is empty, and anekdotexx is the name, but i also have a varible wich has this name in it, and whan i use this variable, i wouldn’t need the i anymore:

```auto

AnDo = new LoadVars()
AnDo.load("http://www.maartenlierop.nl/janv/janv.php")
AnDo.onLoad = function(succes){
    if(succes){
        trace("communicatie succesvol");
        for(var i=0; i<this.cant; i++){
// loading the movieclips, and put them on their place
            var dragclip:MovieClip = createEmptyMovieClip (AnDo[instance], i)
            loadMovie(AnDo["link"+i], AnDo[instance]);
            setProperty (AnDo[instance], _x, Ando["xpos"+i]);
            setProperty (AnDo[instance], _y, Ando["ypos"+i]);
// this part shopuld make the loaded movieclip draggable, but this won't work
            dragclip.onPress = function () {
                this.startDrag();
            }
            trace ("dragclip : " + dragclip);
            trace ("name : " + AnDo[instance]);
        }
    }else{
        trace("communicatie niet succesvol");
    }
}

```

with this script the movies are again not draggalbe, and i only see one of them (I’ve got two movies in the database now)

---

<div class="post-metadata">

### Author: ![JoshuaJonah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshuajonah/32/1775_2.png) [@JoshuaJonah](https://forum.kirupa.com/u/JoshuaJonah)
#### Post date: [April 10, 2006, 7:38pm UTC](https://forum.kirupa.com/t/problems-with-loaded-movieclips/185069/8 "2006-04-10T19:38:57Z")

</div>

did you copy and paste my above code?

---

<div class="post-metadata">

### Author: ![Maarten\_Lierop](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Maarten\_Lierop](https://forum.kirupa.com/u/Maarten_Lierop)
#### Post date: [April 10, 2006, 7:42pm UTC](https://forum.kirupa.com/t/problems-with-loaded-movieclips/185069/9 "2006-04-10T19:42:39Z")

</div>

yes i did, the movieclips did not show up at all  
output was:

communicatie succesvol  
undefined  
undefined

---

<div class="post-metadata">

### Author: ![JoshuaJonah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshuajonah/32/1775_2.png) [@JoshuaJonah](https://forum.kirupa.com/u/JoshuaJonah)
#### Post date: [April 10, 2006, 7:49pm UTC](https://forum.kirupa.com/t/problems-with-loaded-movieclips/185069/10 "2006-04-10T19:49:44Z")

</div>

try traceing it more specifically to see where it looses it’s value:

```auto
AnDo = new LoadVars()
AnDo.load("http://www.maartenlierop.nl/janv/janv.php") 
AnDo.onLoad = function(succes){
    if(succes){
        trace("communicatie succesvol");
        for(var i=0; i<this.cant; i++){
// loading the movieclips, and put them on their place
            var dragclip:MovieClip = createEmptyMovieClip ("dragger"+i, i)
            trace (dragclip+" has been created")
            var link:String = eval(AnDo["link"+i])
            trace ("Link: "+link)
            dragclip.loadMovie(link);
            trace (dragclip)
            dragclip._x = AnDo["xpos"+i];
            trace (dragclip._x)
            dragclip._y = AnDo["ypos"+i];
            trace (dragclip._y)
// this part shopuld make the loaded movieclip draggable, but this won't work
            dragclip.onPress = function () {
                trace ("you clicked")
                this.startDrag();
            }
            trace (dragclip);
        }
    }else{
        trace("communicatie niet succesvol");
    }
}

```

---

<div class="post-metadata">

### Author: ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)
#### Post date: [April 10, 2006, 7:52pm UTC](https://forum.kirupa.com/t/problems-with-loaded-movieclips/185069/11 "2006-04-10T19:52:37Z")

</div>

You need to make sure the movies are loaded before using function

```auto
dragclip.onPress = function () {
                this.startDrag();
            }

```

---

<div class="post-metadata">

### Author: ![Maarten\_Lierop](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Maarten\_Lierop](https://forum.kirupa.com/u/Maarten_Lierop)
#### Post date: [April 10, 2006, 8:03pm UTC](https://forum.kirupa.com/t/problems-with-loaded-movieclips/185069/12 "2006-04-10T20:03:01Z")

</div>

ouptu for your script is:  
communicatie succesvol  
has been created  
Link:  
undefined  
undefined  
undefined  
undefined  
has been created  
Link:  
undefined  
undefined  
undefined  
undefined

I tried to implement the trace actions also to your first script because in that script the mc’s did show up

```auto

AnDo = new LoadVars()
AnDo.load("http://www.maartenlierop.nl/janv/janv.php")
AnDo.onLoad = function(succes){
    if(succes){
        trace("communicatie succesvol");
        for(var i=0; i<this.cant; i++){
// loading the movieclips, and put them on their place
            var dragclip:MovieClip = createEmptyMovieClip (AnDo["instance"+i], i)
              trace (dragclip+" has been created")
            loadMovie(AnDo["link"+i], AnDo["instance"+i]);
              trace ("Link: "+link)
              trace (dragclip)
            setProperty (AnDo["instance"+i], _x, Ando["xpos"+i]);
            setProperty (AnDo["instance"+i], _y, Ando["ypos"+i]);
              trace (dragclip);
            dragclip.onPress = function () {
                this.startDrag();
                trace ("you clicked")
            }
              trace (dragclip);
        }
    }else{
        trace("communicatie niet succesvol");
    }
}

```

the output is here not much more hopegiving:  
communicatie succesvol  
has been created  
Link:  
undefined  
undefined  
undefined  
has been created  
Link:  
undefined  
undefined  
undefined

---

<div class="post-metadata">

### Author: ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)
#### Post date: [April 10, 2006, 8:12pm UTC](https://forum.kirupa.com/t/problems-with-loaded-movieclips/185069/13 "2006-04-10T20:12:29Z")

</div>

> [@Maarten Lierop](#):
>
> ouptu for your script is:  
> communicatie succesvol  
> has been created  
> Link:  
> undefined  
> undefined  
> undefined  
> undefined  
> has been created  
> Link:  
> undefined  
> undefined  
> undefined  
> undefined
> 
> I tried to implement the trace actions also to your first script because in that script the mc’s did show up
> 
> ```auto
> 
> AnDo = new LoadVars()
> AnDo.load("http://www.maartenlierop.nl/janv/janv.php")
> AnDo.onLoad = function(succes){
> if(succes){
> trace("communicatie succesvol");
> for(var i=0; i<this.cant; i++){
> // loading the movieclips, and put them on their place
> var dragclip:MovieClip = createEmptyMovieClip (AnDo["instance"+i], i)
> trace (dragclip+" has been created")
> loadMovie(AnDo["link"+i], AnDo["instance"+i]);
> trace ("Link: "+link)
> trace (dragclip)
> setProperty (AnDo["instance"+i], _x, Ando["xpos"+i]);
> setProperty (AnDo["instance"+i], _y, Ando["ypos"+i]);
> trace (dragclip);
> dragclip.onPress = function () {
> this.startDrag();
> trace ("you clicked")
> }
> trace (dragclip);
> }
> }else{
> trace("communicatie niet succesvol");
> }
> }
> 
> ```
> 
> the output is here not much more hopegiving:  
> communicatie succesvol  
> has been created  
> Link:  
> undefined  
> undefined  
> undefined  
> has been created  
> Link:  
> undefined  
> undefined  
> undefined

```auto
AnDo = new LoadVars();
AnDo.load("http://www.maartenlierop.nl/janv/janv.php");
AnDo.onLoad = function(succes) {
	if (succes) {
		trace("communicatie succesvol");
		for (var i = 0; i<this.cant; i++) {
			// loading the movieclips, and put them on their place
			var dragclip:MovieClip = _root.createEmptyMovieClip("dragger"+i, i);
			dragclip.loadMovie(this["link"+i]);
			checkload(dragclip);
			dragclip._x = Ando["xpos"+i];
			dragclip._y = Ando["ypos"+i];
			// this part shopuld make the loaded movieclip draggable, but this won't work
			trace(dragclip);
		}
	} else {
		trace("communicatie niet succesvol");
	}
};
var i = 1000;
function checkload(clip) {
	var clap = this.createEmptyMovieClip("checker"+i, i);
	clap.onEnterFrame = function() {
		if (clip._width) {
			clip.onPress = function() {
				this.startDrag();
			};
			this.removeMovieClip();
		}
	};
	i++;
}

```

---

<div class="post-metadata">

### Author: ![JoshuaJonah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshuajonah/32/1775_2.png) [@JoshuaJonah](https://forum.kirupa.com/u/JoshuaJonah)
#### Post date: [April 10, 2006, 8:15pm UTC](https://forum.kirupa.com/t/problems-with-loaded-movieclips/185069/14 "2006-04-10T20:15:22Z")

</div>

thanx Stringy, didn’t think we’d have to break out a function 🙂

---

<div class="post-metadata">

### Author: ![Maarten\_Lierop](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Maarten\_Lierop](https://forum.kirupa.com/u/Maarten_Lierop)
#### Post date: [April 10, 2006, 8:19pm UTC](https://forum.kirupa.com/t/problems-with-loaded-movieclips/185069/15 "2006-04-10T20:19:40Z")

</div>

For Stringy:

I think it goes wrong far before the startdrag command is assigned.  
I tried to place the startdrag inside an onload together with a trace “movie loaded.” But although the movies showed up on screen, the trace Movies loaded never showed up.

---

<div class="post-metadata">

### Author: ![Maarten\_Lierop](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Maarten\_Lierop](https://forum.kirupa.com/u/Maarten_Lierop)
#### Post date: [April 10, 2006, 8:25pm UTC](https://forum.kirupa.com/t/problems-with-loaded-movieclips/185069/16 "2006-04-10T20:25:37Z")

</div>

oke, i think i understand what you did (but this is starting to look far more complicated).  
But still; in my window i do not see the mc’s  
do they show up on your screens?

---

<div class="post-metadata">

### Author: ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)
#### Post date: [April 10, 2006, 8:27pm UTC](https://forum.kirupa.com/t/problems-with-loaded-movieclips/185069/17 "2006-04-10T20:27:05Z")

</div>

> [@Maarten Lierop](#):
>
> For Stringy:
> 
> I think it goes wrong far before the startdrag command is assigned.  
> I tried to place the startdrag inside an onload together with a trace “movie loaded.” But although the movies showed up on screen, the trace Movies loaded never showed up.

hmm seems to work ok for me-maybe i am missing something  
This just uses code by Defective + my checkload thingy  
[http://www.fmx6.com/teststuff/flash1.zip](http://www.fmx6.com/teststuff/flash1.zip)

---

<div class="post-metadata">

### Author: ![Maarten\_Lierop](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Maarten\_Lierop](https://forum.kirupa.com/u/Maarten_Lierop)
#### Post date: [April 10, 2006, 8:38pm UTC](https://forum.kirupa.com/t/problems-with-loaded-movieclips/185069/18 "2006-04-10T20:38:11Z")

</div>

:pa: Wich version are you using?

I have Flash MX 2004 prof. and i cannot open your fla file

---

<div class="post-metadata">

### Author: ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)
#### Post date: [April 10, 2006, 8:42pm UTC](https://forum.kirupa.com/t/problems-with-loaded-movieclips/185069/19 "2006-04-10T20:42:42Z")

</div>

> [@Maarten Lierop](#):
>
> :pa: Wich version are you using?
> 
> I have Flash MX 2004 prof. and i cannot open your fla file

flash 8  
here in mx2004  
[http://www.fmx6.com/teststuff/flash.rar](http://www.fmx6.com/teststuff/flash.rar)

---

<div class="post-metadata">

### Author: ![Maarten\_Lierop](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Maarten\_Lierop](https://forum.kirupa.com/u/Maarten_Lierop)
#### Post date: [April 10, 2006, 8:58pm UTC](https://forum.kirupa.com/t/problems-with-loaded-movieclips/185069/20 "2006-04-10T20:58:48Z")

</div>

Thank you guys! it works!:thumb:  
I spent four days changing this code again and again, but it finaly works!  
I need it for my final project on art school, When i’ve finished my project i will show it to you (takes a couple of weeks)

Thanks very much for your time!

[Next page](https://forum.kirupa.com/t/problems-with-loaded-movieclips/185069.md?page=2)
