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:
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
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?
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");
}
}
What did it trace before? and why does the name of the object have to be the value of that array item?
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");
}
}
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:
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)
try traceing it more specifically to see where it looses it’s value:
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");
}
}
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
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
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++;
}
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.
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?
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)