17 Replies Latest reply on Nov 15, 2009 9:29 PM by kglad

    change dynamic text of loaded MC problem

    Tal770

      I have an empty MC on stage it's named: picture

      I have swf file , loadMC made of 2 dynamic text named: m_text and ref_text the loadMC has linkage named: mcDef

      I load the movie

      picture.loadMovie( ~/images/loadMC.swf);

      then I try to change the text:

       

      _root.picture.mcDef.m_text.text = "my new text";

      _root.picture.mcDef.ref_text.text = "my ref text";

       

      nothing is changed

      seeing the veriable list how picture is decleared:

       

      Movie Clip: Target="_level0.picture.instance9"
      Edit Text: Target="_level0.picture.instance9.m_text"
          variable = null,
          text = "old text", etc...

      how can i access this text

       

      10X

      Tal

        • 1. Re: change dynamic text of loaded MC problem
          kglad Adobe Community Professional & MVP

          after loading is complete you can use:

           

          _level0.picture.instance9.m_text.text="my new text";

          • 2. Re: change dynamic text of loaded MC problem
            Enfors

            Sorry, wrongly posted.

            • 3. Re: change dynamic text of loaded MC problem
              Tal770 Level 1

              I tried your solution but it dosn't work

              trace(_level0.picture.instance9.m_text.test);  ==> undifend

              i tried as well

              trace(_level0.picture.instance9.m_text.text);  ==>undefined
              trace(_level0.picture.instance9);  ==>undefined
              trace(_level0.picture);  ==>_level0.picture

              • 4. Re: change dynamic text of loaded MC problem
                kglad Adobe Community Professional & MVP

                then your previous message is incorrect or you didn't execute that code AFTER loading was complete.  to determine which is the problem start with the timing of that code.  what code did you use to delay code execution until after loading completed?

                • 5. Re: change dynamic text of loaded MC problem
                  Tal770 Level 1

                  I converted the code to use movieClipLoader()

                   

                  function loadpicture(p) { //loadpicture is called when ever the picture needs to be loaded
                  plistener = new Object();
                  picture_mcl = new MovieClipLoader();
                  picture_mcl.addListener(plistener);
                  plistener.onLoadInit = function(target_mc) {
                    if (isdef[p]) { //if isDef then needs to add text to the clip
                     target_mc.instance9.m_text.text = descriptioN[p];
                     target_mc.instance9.ref_text.text = descriptioN[p];
                     trace(target_mc);
                     trace(target_mc.instance9.m_text.text);
                    }
                  };
                  plistener.onLoadProgress = function(_mc:MovieClip, loaded:Number, filesize:Number) {
                    preloader._visible = true;
                    if (loaded != filesize) {
                     preloader.preload_bar._xscale = 100*loaded/filesize;
                    } else {
                     preloader._visible = false;
                    }
                  };
                  picture_mcl.loadClip(image[p], picture);
                  }

                  only the first time the text changes but the rest of the time it dosnt, whants wrong?

                  THE OUTPUT

                  ==========

                  _level0.picture
                  NEW-TEXT
                  _level0.picture
                  undefined

                  _level0.picture
                  undefined

                  • 6. Re: change dynamic text of loaded MC problem
                    kglad Adobe Community Professional & MVP

                    i assume you're now loading different swfs.  and, only the first has a movieclip named instance9 on its main timeline with instance9 containing those 2 textfields.

                     

                    this would probably be a good time to assign an instance name to your movieclips in the swfs you want to load.  then use that name instead of instance9 in your main swf's code.

                    • 7. Re: change dynamic text of loaded MC problem
                      Tal770 Level 1

                      My problem is when loading picture I know throu the XML file that there is no picture there for load swf file and change text.

                       

                      so I tried either

                      picture_mcl.loadClip(image[p], picture["mc"+p]); or

                      picture_mcl.loadClip(image[p], "picture.mc"+p);

                       

                      and to access the text

                      target_pic["mc"+p].m_text.text = descriptioN[p];

                      none work and no load is done

                      but when I try the old way

                      picture_mcl.loadClip(image[p], picture);

                      it loads every thing correct but I dont have access to the text

                      how should I declear?

                       

                      the code is:

                      function loadpicture(p) {
                      //loadpicture is called when ever the picture needs to be loaded
                        plistener = new Object();
                      picture_mcl = new MovieClipLoader();
                      picture_mcl.addListener(plistener);
                      plistener.onLoadInit = function(target_pic) {
                        if (isdef[p]) {
                         //if isDef then needs to add text to the clip
                         target_pic["mc"+p].m_text.text = descriptioN[p];
                         target_pic["mc"+p].ref_text.text = descriptioN[p];
                         trace(target_pic);
                         trace(target_pic.m_text.text);
                        }
                        target_pic._alpha = 100;
                        preloader._visible = false;
                      };
                      plistener.onLoadProgress = function(target_pic:MovieClip, hadLoaded:Number, total:Number) {
                        preloader._visible = true;
                        if (hadLoaded != total) {
                         preloader.preload_bar._xscale = 100*hadLoaded/total;
                        } else {
                         preloader._visible = false;
                        }
                        trace(hadLoaded+" != "+total);
                      };
                      //if (isdef[p]) {
                        picture_mcl.loadClip(image[p], picture["mc"+p]);
                      //} else {
                        //picture_mcl.loadClip(image[p], picture);
                      //}
                      }

                      and one more thing wen running with picture the old way onLoadProgress() dosnt work at all.

                      • 8. Re: change dynamic text of loaded MC problem
                        Tal770 Level 1

                        when tring "picture.mc"+p or picture["mc"+p]  should I change its alpha like this

                        picture["mc"+p]._alpha = 0;

                        or just picture._alpha =0;

                        also this as well:

                        picture.pictureValue = p;

                        how should I save thouse values.

                        • 9. Re: change dynamic text of loaded MC problem
                          kglad Adobe Community Professional & MVP

                          did you assign an instance name to the movieclip in your external swfs that contains those textfields?  if so, what is the instance name?

                          • 10. Re: change dynamic text of loaded MC problem
                            Tal770 Level 1

                            The linkage name is defMC how should I use it?

                            thanks for the replay

                            • 11. Re: change dynamic text of loaded MC problem
                              kglad Adobe Community Professional & MVP

                              linkage name is irrelevant.  if you open your swfs that you're loading and click on the movieclip that contains those two textfields, what instance name is shown in the properties panel?

                              • 12. Re: change dynamic text of loaded MC problem
                                Tal770 Level 1

                                im using MX2004 if I open the swf file it loads it as movie and I cannot see the properties on this.

                                I must be missing some thing? how can I see the properties. If I drop the symbol on the stage it helds the dynamic text as mobieClipe with no insance name. so I dont thing I andwerstand what you wrote.

                                • 13. Re: change dynamic text of loaded MC problem
                                  kglad Adobe Community Professional & MVP

                                  click window/properties/properties to see the properties panel.

                                  • 14. Re: change dynamic text of loaded MC problem
                                    Tal770 Level 1

                                    I have an empty movie clip instance name "picture" thats on the properties panel

                                    on run it usually loads jpg's with no problem

                                    when there is no jpg to load then it loads swf file defMC.swf

                                    the swf is build of 2 dynamic text each with instance name m_text, ref_text - they are not packed into one movie clip with instance

                                    I also tried

                                      picture_mcl.loadClip(image[p], "picture.picdef"+p);
                                    it doesnt enter the onLoadInit() t all and the output is only

                                    also this way too

                                    picture_mcl.loadClip(image[p], picture["picdef"+p]);
                                    just the same

                                    the output is:

                                    Movie Clip: Target="_level0.picture"
                                    Variable _level0.picture.onRelease = [function 'onRelease']
                                    Variable _level0.picture.pictureValue = 2

                                     

                                    then I tried diffrent way

                                    picture.attachMovie("symbol4","picdef"+p,1000) from library

                                    and accessing the text as:

                                    picture["picdef"+p].m_text.text = "bla_bla"

                                    it dosnt work and there is on out put print

                                    _level10.picture.picdef0

                                    _level10.picture.picdef3

                                    _level10.picture.picdef5

                                    for every time I tried diffrent p value but there should be only one picture at a time so this dos'nt work either

                                     

                                    back to movieClipLoader() should I join both dynamic text under 1 movieclip with enstance name?

                                    • 15. Re: change dynamic text of loaded MC problem
                                      kglad Adobe Community Professional & MVP

                                      if you're still loading your swf into the movieclip with instance name picture, AFTER loading is complete

                                       

                                      picture.m_text and picture.ref_text

                                       

                                      would reference textfields with instance names m_text and ref_text that are on the first frame of your loaded swf.

                                      • 16. Re: change dynamic text of loaded MC problem
                                        Tal770 Level 1

                                        picture_mcl(image[p],picture)

                                        and in the

                                        onLoadInit = function(target_pic) {
                                          //trace(target_pic);
                                          if (isdef[p]) {
                                           //if isDef then needs to add text to the clip
                                           target_pic.instance10.m_text.text = descriptioN[p];
                                           target_pic.instance10.ref_text.text = descriptioN[p];

                                        it works for only the first time

                                        it creats as follows

                                        first time

                                        level10.picture.instance10.m_text = the wanted text

                                        next time

                                        level10.picture.instance11.m_text

                                        next time

                                        level10.picture.instance12.m_text

                                        and so on

                                        • 17. Re: change dynamic text of loaded MC problem
                                          kglad Adobe Community Professional & MVP
                                          var instanceNum:Number=10;

                                          onLoadInit = function(target_pic) {
                                            //trace(target_pic);
                                            if (isdef[p]) {
                                             //if isDef then needs to add text to the clip
                                             target_pic["instance"+instanceNum].m_text.text = descriptioN[p];
                                             target_pic["instance"+instanceNum].ref_text.text = descriptioN[p];

                                          instanceNum++;
                                          1 person found this helpful