Groups | Blog | Home
all groups > flash actionscript > march 2006 >

flash actionscript : duplicating a movieclip but not able to update the text field in using variable


insight orange
3/25/2006 10:36:34 PM
i am making a "virtual files cabinet" for which i have to create files icons
dynamicly and give them serial no too, but its not happening. movieclips are
sucessfully created.
i have a dynamic text filed in the movie clip. what i want is that when a new
movie clip is created that variable is updated and hance each movie clip has
its own serial no. this serial no. helps distinguish the files in a cabinet.i
dont want to unique names of clips but the unique serial no in the text field.
the code for dulicating movie clips is
on(release)
{ for (x=0;x<50;x++)
{
dummy.duplicateMovieClip("dummy+x", this.getNextHighestDepth(), {_x:90,
_y:x+x+x+x});
trace(x);
}
}

and the code which is in the movie clip is

on (rollOver)
{
rollno=_root.x;
_yscale=120;
}
on (rollOut)
{
rollno=_root.x;
_yscale=100;
}

what i think is that i am using a single variable when loop is executed its
value is updated and same value is updated in all the clips
how to avoid this and have uniquie value assigned to each duplicated movie clip
uomoDiCuore
3/25/2006 10:42:32 PM
("dummy+x", .....

This should be ("dummy"+x,.....

insight orange
3/26/2006 2:16:46 PM
Thanks uomoDiCuore my one problem of levels is solved
but still my unique variable value is n ot been doen

plz suggest me any thing

kglad
3/26/2006 4:02:48 PM
none of your movieclips "knows" it's the xth movieclip. you must store that
value somewhere for each movieclip to retrieve:


on(release)
{ for (x=0;x<50;x++)
{
rclip=dummy.duplicateMovieClip("dummy+x", this.getNextHighestDepth(), {_x:90,
_y:4*x});
rclip.xvar=x;
}
}

on (rollOver)
{
rollno=this.xvar;
_yscale=120;
}
on (rollOut)
{
rollno=this.xvar
_yscale=100;
}
insight orange
3/26/2006 7:37:20 PM
thanks kglad
your are master of action script .
my problem is about to solve. the problem of unique variable is solved but
when i rollover the movie clips they change there value in the text field.
i mean i am duplicating about 50 clips and when i rolover any mouse the value
of that mouse is stored in the xvar and then other dulicated movie clips
continue to show that value.
if you give me you mail address i can send you the file so that you can find
it out your self.
i am very much desprate to solve this problem otherwise my whole project will
stop
i have used the same code of urs.
i realy need help on this.
thanks again sir
kglad
3/27/2006 3:09:56 PM
here's your corrected file with the drawer opening and closing properly. i have no idea what that orange thing is supposed to do, though.

insight orange
3/27/2006 7:16:47 PM
oh man you infact did not understand my problem
these orange things are the icons of the files that reside in the cabinte draw
and what i want is those files should have unique serial no.
i masked the layers my self in that way the files fit in the draw but when i
mask the layer the text filed in the duplicated movieclips disapears.
even i dont mask the clips the text filed are not behaving correctly they
update them self wrongly if you rollover the duplicated movieclips two or three
times the text field becomes incorrect.

i hope you understand the problem
now you have the file and i hope you will solve the problem

i am waiting
thanks
salmans sadiq
bye

insight orange
3/28/2006 2:44:40 AM
people i am still waiting for the solution

kglad where are you
kglad
3/28/2006 3:03:52 AM
a masked textfields needs embedded font. if you're only using numbers in your
textfield you can decrease the size of the embedded font by unhighlighting text
and punctuation. i did some more work on your file so those files look like
they're in the file cabinet. i don't know what they're supposed to do when
they are clicked.

www.gladstienc.com/new/cabinet.fla
insight orange
3/28/2006 10:01:00 PM
kglad
3/29/2006 1:42:46 AM
see if this does what you want:

insight orange
3/29/2006 2:05:19 PM
Love You Love You Love You

KGLAD the Best LAD

my problem is 98% solved
the little problem is that when you roll down the dulicated movie clips from
the zero to 44th clips every thing is fine and its according to my requirement
but when i starts rollover from clips 44 to 1 they just dont go right you see
it your self closely
love you
remaining all is perfect now i can set sail to build the remain application
infact i am designer now i had to code too.
many many thanks for your sensior efforts
thanks
salman sadiq
kglad
3/29/2006 7:01:53 PM
you can replace the code attached to frame 1 of icons with the following code:


for (x=0; x<45; x++) {
rclip = dummy.duplicateMovieClip("dummy"+x, this.getNextHighestDepth(),
{_x:361, _y:3*x+245});
rclip.xvar = x;
rclip.tf.text = x;
rclip.onRollOver = function() {
this._y -= 15;
startY = _root._ymouse;
this.onMouseMove = function() {
if (Math.abs(startY-_root._ymouse)>2) {
this._y += 15;
delete this.onMouseMove;
}
};
};
rclip.onPress = function() {
trace("i'm icon number "+this.xvar);
};
}
insight orange
3/29/2006 7:51:26 PM
your realy have all the trick in the bag and can do any thing using action
scripts

you have now solved 99% of the problem
what is happeing at the moment is when we rollover from down to up some
flickering is happening can this be solved
i mean that when you rollover any icon from clip44 to clip 0 upwords the clips
behave correctly but the flicker, they disaper and then apear.
i hope this also could be solved

thanks
salman sadiq
kglad
3/29/2006 11:09:16 PM
try this code on icons timeline:


for (x=0; x<45; x++) {
rclip = dummy.duplicateMovieClip("dummy"+x, this.getNextHighestDepth(),
{_x:361, _y:3*x+245});
rclip.xvar = x;
rclip.tf.text = x;
rclip.onRollOver = function() {
this._y = 3*this.xvar+230;
this.onMouseMove = function() {
if (Math.abs(this._y-_root._ymouse)>=3) {
clearInterval(this.moveI);
rclip = this;
this.moveI = setInterval(moveF, 1, rclip);
delete this.onMouseMove;
}
};
};
rclip.onPress = function() {
trace("i'm icon number "+this.xvar);
};
}
function moveF(rclip) {
rclip._y = .5*(rclip._y+3*rclip.xvar+245);
if (3*rclip.xvar+245-rclip._y<1) {
clearInterval(rclip.moveI);
rclip._y = 3*rclip.xvar+245;
}
updateAfterEvent();
}
insight orange
3/30/2006 7:11:20 PM
no sir still there is flickering

infact flickering has increased now motion upwords to download also has gone
wrong. there is too much flickering in the clips animation

do some thing
thanks
also if you could explain what is this code doing
thanks

kglad
3/30/2006 8:15:15 PM
insight orange
4/2/2006 4:53:30 PM
Sorry for the delayed answer sir
i was too much busy and now my problem is fully solved thanks all the help
and ur gift a latest book on action script bible flash 8
you can download it from this link

********************************************************************************
*******

http://rapidshare.de/files/16834268/Wiley.Flash.8.ActionScript.Bible.Jan.2006.ra
r

********************************************************************************
*******

again thanks for your continuous support
thanks

kglad
4/2/2006 7:51:38 PM
AddThis Social Bookmark Button