1

I'm trying to do the following:

I have an empty movieClip in my stage called zonaCentral_mc. I use a function that has this code:

zonaCentral_DescripcionProceso = new zonaCentral_DescripcionProceso_mc();
zonaCentral_mc.addChild(zonaCentral_DescripcionProceso);

It loads the MovieClip zonaCentral_DescripcionProceso from the library into the empty movieclip zonaCentral_mc. The loaded MC has a dynamic textfield called titulo_text inside. How can I change that text? I'm trying:

this["zonaCentral_mc"].getChildByName("zonaCentral_DescripcionProceso").getChildByName("titulo_text").text = "hello";

but I get the error: #1010: One term is not defined and has no properties

I've also tried the dot notation this["zonaCentral_mc"].zonaCentral_DescripcionProceso.titulo_text.text with the same result.

Am I accessing it the wrong way? Why isn't it defined, I believe that they're all defined and in the stage when I call the above statement.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Albert R
  • 125
  • 5
  • 19
  • I'm not familiar with `this["zonaCentral_mc"]` style of noting the movieclip. Have you tried just using `zonaCentral_mc`? I would try tracing out your line one item at a time. First `zonaCentral_mc`, the `zonaCentral_mc.getChildByName("zonaCentral_DescripcionProceso")`, etc, and see where the problem is. – Sam Apr 07 '11 at 22:19
  • Hi Sam, thank you for your reply, the problem was that the loaded MC didn't have an instance name – Albert R Apr 08 '11 at 00:04

1 Answers1

1

the MovieClip you instantiate doesn't have an instance name, that's why you can't access it through "getChildByName".

Try this:

zonaCentral_DescripcionProceso.name = "zonaCentralChildClip";
...
this["zonaCentral_mc"].getChildByName("zonaCentralChildClip").titulo_text.text = "hello";

But also, I am pretty sure you can access the text field as well:

zonaCentral_DescripcionProceso.titulo_text.text = "hello";

Please note, if you're zonaCentral_DescripcionProceso is a MovieClip, you can access the text field without the "getChildByName" method.

Cheers, Rob

robertp
  • 3,557
  • 1
  • 20
  • 13
  • Thank you so much! I tried the second option and it works. I thought that since **zonaCentral_DescripcionProceso** was a child of **zonaCentral_mc**, I had to access the child through the parent when using the dot notation. I also didn't know that I had to specify the instance name, I assumed that I would take the variable name used when created. Well, I learned something more today :) – Albert R Apr 07 '11 at 23:53
  • Well, if you have nested clips the instance name is very useful. In this case you can leave it as you can access your instance through the zonaCentral_DescripcionProceso variable. – robertp Apr 08 '11 at 08:11
  • what if in 1st solution zonaCentral_mc is in inside a movieClip instance-named mcA?? then this["mcA.zonaCentral_mc"].getChild doesn't work! any ideas? – Milad Jul 20 '14 at 08:29