22 Replies Latest reply on Oct 11, 2009 7:46 PM by kglad

    attachMovie is shown on debugger but not on play

    Tal770 Level 1

      I'm using the tutorial XML photo gallery with thumbnail from http://www.kirupa.com/developer/mx2004/thumbnails.htm

      I'v added code to deal when the image is not aviliable I attach a symbol with Text instead to the thumbnail and to the photo as well

      the problem is when I have an image as photo and I press a symbol thumbnail it dosent attach the symbol instead of the Image.

      it doesnt work at all.

      my solution for that was to unloadMovie and it solved partly

      thumbNail onRelease activation

        target_mc.onRelease = function() {
         if (!isdef[p] && isdef[this.pictureValue]) {
         //if the old MC is image and the wanted new MC is a symbol
          picture.unloadMovie();
         }
         p = this.pictureValue-1;
         nextImage();

      The nextimage function does the load of the picture or attachMovie for the symbol

      function nextImage() {
      if (p<(total-1)) {
        p++;
        if (loaded == filesize) {
         picture._alpha = 0;
         if (isdef[p]) { //use defualt symbol instead of a photo
          picture.attachMovie("mcDef", "mcDef"+p, 1000);
          picture["mcDef"+p].m_text.text = reverseString(description[p]);
          picture["mcDef"+p].ref_text.text = reverseString(description[p]);
         } else {
          picture.loadMovie(image[p], 1);
         }
         picture.pictureValue = p;
         desc_txt.text = description[p];
         picture_num();
        }
      }
      }

      Nothing is show and no instance was made of the symbol and when pressing again on symbol thumbnail it then works and all is well

      BUT on debugging it does work on the first time and I dont have to press twice on the symbol!

      it probably caused that there was no load when attaching so veriables  loaded and filesize has no maning in the logice .

      doing unload is a work around the problem does any body has an idea how to deal with this ether with the unload or better off without.

      i'v attached the fla file so you can see the code

      10X

       

        • 1. Re: attachMovie is shown on debugger but not on play
          kglad Adobe Community Professional & MVP

          your using the same depth repeatedly and the loadMovie() method accepts one parameter only.  use the help files to learn how use use loadMovie() and attachMovie().

          • 2. Re: attachMovie is shown on debugger but not on play
            Tal770 Level 1

            thats not a problem becuse if I wouldnt use my work around the image is still showing after I have clicked the thumbnail to attach a symbol and when looking on the veriable list I can see that picture (the movieclip) has no symbol attached to it

            and if I first unload the image and then attach the symbol - in debbug mode it works nicly and in test movie mode I need to click twice. 

            • 3. Re: attachMovie is shown on debugger but not on play
              Tal770 Level 1

              I tried what you wrote and it did not change any thing

                 if (isdef[p]) {
                  picture.attachMovie("mcDef", "mcDef"+p, 1000+p);
                  picture["mcDef"+p].m_text.text = reverseString(description[p]);
                  picture["mcDef"+p].ref_text.text = reverseString(description[p]);
                 } else {
                  picture.loadMovie(image[p]);
                 }

              • 4. Re: attachMovie is shown on debugger but not on play
                kglad Adobe Community Professional & MVP

                is your movieclip attached?  (use the trace() function).  are you changing the parent's _alpha at some point so you can see the attached movieclip?

                • 5. Re: attachMovie is shown on debugger but not on play
                  Tal770 Level 1

                  the alpha is returen to 100% late on in a loop:

                  this.onEnterFrame = function() {
                  filesize = picture.getBytesTotal();
                  loaded = picture.getBytesLoaded();
                  preloader._visible = true;
                  if (loaded != filesize) {
                    preloader.preload_bar._xscale = 100*loaded/filesize;
                  } else {
                    preloader._visible = false;
                    if (picture._alpha<100) {
                     picture._alpha += 10;
                    }

                  I'v printed out the alpha and on every click on thumbnail it increments by 10 untill more then 100% thats OK

                   

                  this ia the print out of list veriables:

                  1. the image is selected

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

                  2.pressing on symbol thumbnail clears the screen after unloading the image but symbol doesn show and picture._alpha=107.999

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

                  3.pressing on the thumbnail of the symbol the second time and it shows

                  Movie Clip: Target="_level0.picture"
                  Variable _level0.picture.onRelease = [function 'onRelease']
                  Variable _level0.picture.pictureValue = 2
                  Movie Clip: Target="_level0.picture.mcDef2"
                  Edit Text: Target="_level0.picture.mcDef2.m_text"
                      variable = null,
                      text = "ןיינב",
                      htmlText = "ןיינב",
                      html = false, textWidth = 114, textHeight = 73, maxChars = null,  etc...........

                  so it looks like that it didn't load the symbol on the first click even though it goes through the code that attachMovie()????

                  But if I run this in debbug mode codeline by codeline it loads the symbol and shows it on the first tril.

                   

                  here is the printout of the run test mode:

                  picture.loadMovie(image[p]); <==  loading the image after clicking the image thumbnail
                  picture._alpha=0
                  picture._alpha=9.765625
                  picture._alpha=19.53125
                  picture._alpha=29.296875
                  picture._alpha=39.0625
                  picture._alpha=48.828125
                  picture._alpha=58.59375
                  picture._alpha=68.359375
                  picture._alpha=78.125
                  picture._alpha=87.890625
                  picture._alpha=97.65625
                  picture._alpha=107.421875
                  picture.attachMovie('mcDef', 'mcDef'+p, this.getNextHighestDepth()); <== performing the code but no symbol shows and on list veriabls it shows there is no symbol attached!!!!!!!!!!!!!!!!!
                  picture._alpha=0
                  picture._alpha=9.765625
                  picture._alpha=19.53125
                  picture._alpha=29.296875
                  picture._alpha=39.0625
                  picture._alpha=48.828125
                  picture._alpha=58.59375
                  picture._alpha=68.359375
                  picture._alpha=78.125
                  picture._alpha=87.890625
                  picture._alpha=97.65625
                  picture._alpha=107.421875
                  picture.attachMovie('mcDef', 'mcDef'+p, this.getNextHighestDepth()); <== pressing the second time the symbol is attached and shows
                  picture._alpha=0
                  picture._alpha=9.765625
                  picture._alpha=19.53125
                  picture._alpha=29.296875
                  picture._alpha=39.0625
                  picture._alpha=48.828125
                  picture._alpha=58.59375
                  picture._alpha=68.359375
                  picture._alpha=78.125
                  picture._alpha=87.890625
                  picture._alpha=97.65625
                  picture._alpha=107.421875

                   

                  on debugger mode it attache's the symbol to the movie on the first click!!! and no problem

                  why isnt it doing the attachMovie after unloadMovie??????

                  the unloadMove is performed right after clicking the thumbnail before sending to function that does the loadMovie or attachMovie

                  I tried updateAfterEvent(); after unloadMovie() and it didnt help!!

                  running on MX2004

                  10X

                  • 6. Re: attachMovie is shown on debugger but not on play
                    Tal770 Level 1

                    Now Im not sure it works on debugge mode I must have change somthing Now it only shows after clicking twise.

                    • 7. Re: attachMovie is shown on debugger but not on play
                      kglad Adobe Community Professional & MVP

                      what's the following show:

                       


                        target_mc.onRelease = function() {
                         if (!isdef[p] && isdef[this.pictureValue]) {
                         //if the old MC is image and the wanted new MC is a symbol
                          picture.unloadMovie();
                         }
                         p = this.pictureValue-1;
                         nextImage();


                      function nextImage() {
                      if (p<(total-1)) {
                        p++;
                        if (loaded == filesize) {
                         picture._alpha = 0;
                         if (isdef[p]) { //use defualt symbol instead of a photo
                          mc=picture.attachMovie("mcDef", "mcDef"+p, 1000+p);

                      trace("mc= "+mc);

                          picture["mcDef"+p].m_text.text = reverseString(description[p]);
                          picture["mcDef"+p].ref_text.text = reverseString(description[p]);
                         } else {
                          picture.loadMovie(image[p], 1);
                         }
                         picture.pictureValue = p;
                         desc_txt.text = description[p];
                         picture_num();
                        }
                      }
                      }


                       

                      • 8. Re: attachMovie is shown on debugger but not on play
                        Tal770 Level 1

                        picture.attachMovie('mcDef', 'mcDef'+p, this.getNextHighestDepth());//click #1 on symbol
                        mc=_level0.picture.mcDef3
                        picture.loadMovie(image[p]);  //click #2 on image
                        picture.attachMovie('mcDef', 'mcDef'+p, this.getNextHighestDepth());//click #3 on symbol

                        mc=undefined
                        picture.attachMovie('mcDef', 'mcDef'+p, this.getNextHighestDepth());//click #4 on symbol

                        mc=_level0.picture.mcDef2

                        • 9. Re: attachMovie is shown on debugger but not on play
                          kglad Adobe Community Professional & MVP

                          the traces appear in that order??

                          • 10. Re: attachMovie is shown on debugger but not on play
                            Tal770 Level 1

                            yes

                            click 1 on symbol

                            click 2 on image

                            click 3 on symbol = undifined

                            click 4 on any symbol = ok

                            • 11. Re: attachMovie is shown on debugger but not on play
                              kglad Adobe Community Professional & MVP

                              then p is being changed somewhere outside the code you showed.  use trace(p) just above or below the previous trace() function, retest, copy and paste the results.

                              • 12. Re: attachMovie is shown on debugger but not on play
                                Tal770 Level 1

                                p seems to be ok here is the printout:

                                onRelease activates the process p=0 //pressing on thumb#1
                                picture.loadMovie(image[p]);
                                at end of process p=1
                                onRelease activates the process p=1
                                //pressing on thumb#4

                                picture.attachMovie('mcDef', 'mcDef'+p, this.getNextHighestDepth());
                                mc=undefined
                                at end of process p=4
                                onRelease activates the process p=4
                                //pressing on thumb#4

                                picture.attachMovie('mcDef', 'mcDef'+p, this.getNextHighestDepth());
                                mc=_level0.picture.mcDef4
                                at end of process p=4

                                 

                                here is the code onRelease that starts the process:

                                  target_mc.onRelease = function() {
                                   trace("onRelease activates the process p="+p);
                                   if (!isdef[p] && isdef[this.pictureValue]) {
                                    //if the old MC is image and the new  wanted MC is symbol then..(the workAround to solve problem)
                                    picture.unloadMovie();
                                   }
                                   p = this.pictureValue-1; //this=the thumbNail and notice reducing by 1
                                   nextImage();
                                   trace("at end of process p="+p);
                                  };

                                function nextImage() {
                                if (p<(total-1)) {
                                  p++;
                                //this is needed the function is uesed for scrolling thumbNails
                                  if (loaded == filesize) {
                                   picture._alpha = 0;
                                   if (isdef[p]) {
                                    trace("picture.attachMovie('mcDef', 'mcDef'+p, this.getNextHighestDepth());");
                                    mc=picture.attachMovie("mcDef", "mcDef"+p, this.getNextHighestDepth());
                                    trace("mc="+mc);
                                    picture["mcDef"+p].m_text.text = reverseString(description[p]);
                                    picture["mcDef"+p].ref_text.text = reverseString(description[p]);
                                   } else {
                                    trace("picture.loadMovie(image[p]);");
                                    picture.loadMovie(image[p]);
                                   }
                                   picture.pictureValue = p;
                                   desc_txt.text = description[p];
                                   picture_num();
                                  }
                                }
                                }

                                function picture_num() {
                                current_pos = p+1;
                                pos_txt.text = current_pos+" / "+total;
                                }

                                thats all code is done except the this.onEnterFrame = function() { that deals with alpha as I had already posted

                                to conclude:

                                1. if image is loaded and trying to attach movie it doesnt work at all and all time the image is left on stage.

                                2. My work around was to unload the image but the attach still doesnt work the first time.

                                3. only on the second tril the symbol attaches.

                                how can I reset somthing in "picture" that it will attach to it a symbol?

                                10X

                                • 13. Re: attachMovie is shown on debugger but not on play
                                  kglad Adobe Community Professional & MVP

                                  again,  use trace(p) just above or below the previous trace("mc= "+mc) function, retest, copy and paste the results.

                                  • 14. Re: attachMovie is shown on debugger but not on play
                                    Tal770 Level 1

                                    picture.loadMovie(image[p]);
                                    picture.attachMovie('mcDef', 'mcDef'+p, this.getNextHighestDepth());
                                    p=2
                                    mc=undefined
                                    p=2
                                    picture.attachMovie('mcDef', 'mcDef'+p, this.getNextHighestDepth());
                                    p=2
                                    mc=_level0.picture.mcDef2
                                    p=2

                                    • 15. Re: attachMovie is shown on debugger but not on play
                                      kglad Adobe Community Professional & MVP

                                      there's no way those loadMovie() and attachMovie() methods would be in the output panel unless you're doing something other than described.

                                      • 16. Re: attachMovie is shown on debugger but not on play
                                        Tal770 Level 1

                                        fla file and xml (the list of images) on mx2004

                                        • 17. Re: attachMovie is shown on debugger but not on play
                                          kglad Adobe Community Professional & MVP

                                          i usually do not download and correct files unless i'm hired.

                                          • 18. Re: attachMovie is shown on debugger but not on play
                                            Tal770 Level 1

                                            I added try/catch to the section of attachMovie() and when running in debbug mode it works fine

                                            running on test mode it doesnt work for the first time.

                                            I dont think there is a logice problem

                                            TESTING IN DEBBUG MODE

                                            >>clicking on image thumbnail

                                            picture.loadMovie(image[p]);
                                            after loadMovie(image[p]) picture._url= file:///C|/Intepub/webroot/kenli%5Fv1/natav.swf
                                            remark>> notice the url doesnt change until the code is copmlit

                                             

                                            >>clicking on symbol thumbnail to use attachMovie section
                                            picture._url= file:///C|/Intepub/webroot/kenli%5Fv1/natav.swf

                                            remark>> after unloadMovie url was reset to the file and not the image

                                            picture.attachMovie('mcDef', 'mcDef'+p, this.getNextHighestDepth());
                                            mc=_level0.picture.mcDef2

                                            remark>> as you can see it works excelent in debbug mode


                                            l

                                            TESTING IN TEST MODE

                                            >>clicking on image thumbnail

                                            picture.loadMovie(image[p]);
                                            after loadMovie(image[p]) picture._url= file:///C|/Intepub/webroot/kenli%5Fv1/natav.swf


                                            >>clicking on symbol thumbnail to use attachMovie section

                                            picture._url= file:///C|/Intepub/webroot/kenli%5Fv1/images/רכב מכירות.jpg

                                            remark>> notice the url was not reset to the file
                                            picture.attachMovie('mcDef', 'mcDef'+p, this.getNextHighestDepth());
                                            mc=undefined
                                            after the attachMovie the picture._url = file:///C|/Intepub/webroot/kenli%5Fv1/images/רכב מכירות.jpg
                                            testing = attach clip to _root
                                            mc=attachMovie('mcDef', 'mcDef'+p, this.getNextHighestDepth());
                                            mc=_level0.mcDef2

                                            remark>> the attach works fine but doesnt work with picture the MC

                                            >>clicking on symbol thumbnail once again

                                            picture._url= file:///C|/Intepub/webroot/kenli%5Fv1/natav.swf

                                            remark>> picture.unloadMovie() cleared the image url to file
                                            picture.attachMovie('mcDef', 'mcDef'+p, this.getNextHighestDepth());
                                            mc=_level0.picture.mcDef2

                                            remark>> as you can see it works on the second time

                                             

                                            its possible to solve this by deleting picture and creating the empty clip and reassigment its onRelese() but that can happend 100 times so its no way to solve this

                                            • 19. Re: attachMovie is shown on debugger but not on play
                                              Tal770 Level 1

                                              is it possible to attach it to a temporary movieclip and then let picture inhert properties from it or copy it and then delete the temporary moviclip

                                              level0.mctest.mcdef02

                                              level0.picture

                                              to set it as

                                              level0.picture.mcdef02

                                              and removeMovieClip(mctest)

                                              • 20. Re: attachMovie is shown on debugger but not on play
                                                kglad Adobe Community Professional & MVP

                                                1. you can load into a temp mc

                                                 

                                                2. you can create a new movieclip and iterate through most of the properties of the loaded mcdef02 (after loading is complete) and assign those properties to your new movieclip

                                                 

                                                3. you can load into your new movieclip

                                                 

                                                4. you can remove the temp mc

                                                • 21. Re: attachMovie is shown on debugger but not on play
                                                  Tal770 Level 1

                                                  the logic behind all this is when an image is not aviliable use symbol instead therefor I created picture an empt Movie clip and use that for both image or attach to it a symbol from library so i'm trying to baypass the problem by connecting the attached symbol from tempmc to picture I tried duplicateMovieClip but I didnt get it to work any idea on this

                                                  10X

                                                  • 22. Re: attachMovie is shown on debugger but not on play
                                                    kglad Adobe Community Professional & MVP

                                                    to detect a load-error you should use the moviecliploader class which has an onLoadError() method.  you can apply the attachMovie() method to the load-target in your onLoadError method.