PDA

View Full Version : pass dynamic variable from duplicated mc


crion
04-21-2005, 05:57 PM
hi everyone, i'm in trouble again... this is some kind of logical/variable stuff but i can't figure it out.

i've got duplicated movieclip containing dynamic textfield. value of this field and number of duplicates is taken from php script. all of this is put into scrollpane.

now, when i click on single of these duplicated mcs there is second dynamic textfield activated on a main timeline and i need it to show exactly the same stuff as in i-duplicaded.textfield within i-duplicated.mc (i hope it's understandable:). but unfortunatelly i have no idea how ot pass this i-value.

main part of the code:
this.loadVariables ("php.php", "POST");
_root.DisplayMC.DynTxt1.text="empty";
this.onData = function ()
{
for(i=0;i<this.total;i++)
// 'total' is taken from php
{
duplicateMovieClip(this.RecMC,"RecMC"+i, i);
this["RecMC"+i]._y =i*25;
this["RecMC"+i].DynTxt2.text=this["phpvar"+i];
this["RecMC"+i].onRelease = function()
{
_root.DisplayMC.DynTxt1.text=this["phpvar"+i];
}
}
_root.MyPane.invalidate();
}

as for the names ... look at this graph http://www.madlena.elsat.net.pl/p/schema.png

as for the source ... http://www.madlena.elsat.net.pl/p/dynvar.zip

line" _root.DisplayMC.DynTxt1.text=this["phpvar"+i]; gives me 'undefined' result, but when i replace this["phpvar"+i] with eg. phpvar3 it shows what it suppose to.i understand why but how to pass this exact i-variable?

anyone?:)
pleaaaase:)

johnnystorm
04-21-2005, 07:02 PM
this.loadVariables ("php.php", "POST");
_root.DisplayMC.DynTxt1.text="empty";
this.onData = function ()
{
for(i=0;i<this.total;i++)
// 'total' is taken from php
{
var mc = duplicateMovieClip(this.RecMC,"RecMC"+i, i);
mc._y =i*25;
mc.DynTxt2.text=this["phpvar"+i];
mc.onRelease = function() {
_root.DisplayMC.DynTxt1.text=this.DynTxt2.text;
}
}
_root.MyPane.invalidate();
}
or

this.loadVariables ("php.php", "POST");
_root.DisplayMC.DynTxt1.text="empty";
this.onData = function ()
{
for(i=0;i<this.total;i++)
// 'total' is taken from php
{
var mc = duplicateMovieClip(this.RecMC,"RecMC"+i, i);
mc._y =i*25;
mc.myVar = this["phpvar"+i];
mc.DynTxt2.text=this["phpvar"+i];
mc.onRelease = function() {
_root.DisplayMC.DynTxt1.text=this.myVar;
}
}
_root.MyPane.invalidate();
}

johnnystorm
04-21-2005, 07:28 PM
I also noticed you use 'total' is taken from php. I used to do it this way but now prefer:
for(i=0; this["phpvar"+i] != null; i++) {
...
}
does the same thing but then you don't have to set up the var total.

crion
04-21-2005, 07:34 PM
you just saved my life:) the easiest solutions are the best huh?:) stupid me. thank you