|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
duplicate and drag empty mc
Could someone please help I am going crazy!! I am connecting to a php file then it retrieves data from a mySQL database then flash presents it. This all works great. But here is the problem I want to then be able to duplicate the data (which is images). Please view the code below, I have tried many different ways but nothing seems to work. Any help would be greatly appreciated!!!
Thank you skezo Code:
userData = new LoadVars();
userData.load("testme.php");
userData.ref = this;
offset = 60;
userData.onLoad = function(succes) {
if (succes) {
for (var i = 0; i<this.cant; i++) {
this.ref.createEmptyMovieClip("clip_"+i, i);
this.ref["clip_"+i].createEmptyMovieClip("holder_"+i, i);
this.ref["clip_"+i]["holder_"+i].loadMovie(this["Image"+i]);
this.ref["clip_"+i]._yscale = 40;
this.ref["clip_"+i]._xscale = 40;
this.ref["clip_"+i].onPress = function() {
duplicateMovieClip(this, "mc"+i, 500+i);
startDrag("mc"+i);
};
this.ref["clip_"+i].onRelease = function() {
stopDrag();
};
if (i != 0) {
this.ref["clip_"+i]._y = this.ref["clip_"+(i-1)]._y+this.ref["clip_"+(i-1)]._height+offset;
}
}
} else {
trace("Something is wrong!!!");
}
};
stop();
|
|
#2
|
|||
|
|||
|
Hi, I don't think that will work. Duplicating will not copy the image as well, you must assign it again:
Code:
this.ref["clip_"+i]["holder_"+i].loadMovie(this["Image"+i]);
this.ref["clip_"+i]._yscale = 40;
this.ref["clip_"+i]._xscale = 40;
this.ref["clip_"+i].onPress = function()
{
newOne = duplicateMovieClip(this, "mc"+i, 500+i);
newOne.loadMovie(this["Image"+i]);
newOne._yscale = 40;
newOne._xscale = 40;
newOne.startDrag();
};
|
|
#3
|
|||
|
|||
|
Hi Tann, thanks for the reply i tried what you have suggested but still not duplicating the image it is driving me crazy! In theory it should work but nothing
if you have time check this address http://www.aburningwater.com/testme1.html |
|
#4
|
|||
|
|||
|
This is very frustrating; this is what I have done so far (also including the code from my first post)
When I add loadMovie(this["Image"+i]); instead of loadMovie("image1.jpg"); it does not work, can anyone see a fix to this, example of it can be found here: http://www.aburningwater.com/testme1.html Code:
this.ref["clip_"+i].onPress = function() {
_root.createEmptyMovieClip("mc"+i, i+500);
_root["mc"+i].createEmptyMovieClip("holdme"+i, i+600);
_root["mc"+i]["holdme"+i].loadMovie("image1.jpg");
_root["mc"+i]._yscale = 40;
_root["mc"+i]._xscale = 40;
_root["mc"+i].startDrag();
_root["mc"+i].onPress = function() {
_root["mc"+i].startDrag();
}
};
|
|
#5
|
|||
|
|||
|
Hi, I've got a few ideas as to what may be going wrong..it could take a while though going backwards and forwards here. Can you post a link or attach a zip of the .fla in MX format. I'll take a look today and get back to you.
|
|
#6
|
|||
|
|||
|
Hi Tann, thanks again for the reply.
|
|
#7
|
|||
|
|||
|
Hi, I copied your php output to a text file. I had to add &cap=capped to the end to get the loop to read the number "cant" correctly. This is the updated and working code:
Code:
offset = 60;
globalCount = 5;
myData = new LoadVars();
myData.load("testme.txt");
myData.ref = this;
myData.onLoad = function(succes) {
if (succes) {
for (var i = 0; i<Number(this.cant); i++) {
this.ref.createEmptyMovieClip("clip_"+i, i);
this.ref["clip_"+i].createEmptyMovieClip("holder_"+i, i);
this.ref["clip_"+i]["holder_"+i].loadMovie(this["Image"+i]);
this.ref["clip_"+i]._yscale = 40;
this.ref["clip_"+i]._xscale = 40;
this.ref["clip_"+i].onPress = function() {
_root.globalCount++;
blankOne = _root.createEmptyMovieClip("mc"+_root.globalCount, _root.globalCount);
newClicker = blankOne.createEmptyMovieClip("holdme1", 1);
trace(_root.globalCount);
newClicker.loadMovie(_root.myData["Image"+this.getDepth()]);
blankOne._yscale = 40;
blankOne._xscale = 40;
blankOne.startDrag();
blankOne.onPress = function() {
this.startDrag();
};
};
this.ref["clip_"+i].onMouseUp = function() {
stopDrag();
};
if (i != 0) {
this.ref["clip_"+i]._y = this.ref["clip_"+(i-1)]._y+this.ref["clip_"+(i-1)]._height+offset;
}
}
} else {
trace("Something is wrong!!!");
}
};
stop();
|
|
#8
|
|||
|
|||
|
Tann you are a King among men, thank you very much, it has been an educational roller coaster. Just a quick question why did you need to add &cap=capped to the text file? i have not touched my php file and it seems to work.. But thank you again!!!!
-skezo |
|
#9
|
|||
|
|||
|
Hi, oh that's just for the text file. Sometimes flash has trouble telling when the end of the line is. I think it depends on what os you write the text file. With a php file you shouldn't have a problem. Without the extra (non used) variable flash might read "cant=3\r\n" or some variant (maybe..!?..) so it wont work in a loop correctly. I'm not too sure if Number(cant) will make ignore the extras or not so I do it anyway for now. I kind of left text files for a while in favor of php and xml so I havent really bothered to experiment, maybe I will now though :¬)
|
![]() |
| Viewing: Dev Shed Forums > Web Design > Flash Help > duplicate and drag empty mc |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|