5 Replies Latest reply on Apr 21, 2012 1:46 AM by Petteri_Paananen

    relinking?

    Petteri_Paananen Level 4

      I have a slight problem (still with SWF poster images)...

      I´m trying new approach. I have noticed that when SWF file is placed to InDesign, it creates a StandardSwfPoster.jpg file to Links panel.

      It seems to be possible to relink that file with Link Panel´s relink button (new relinked image will show up very small so it has to be fitted with With Content to Frame command as well).

       

      Now I wonder if those both things would be possible to make with javascript command? Any help will be highly appreciated...=)

        • 1. Re: relinking?
          Laubender Adobe Community Professional & MVP

          @Petteri – it seems that the standard poster image is placed immediately after placing the swf file.
          So to reach it you could do it by index or by name.

           

          I make an assumption here:  to reach it by name could be a little bit uncertain, if the user did tricks with the original image sitting in a subfolder of the InDesign installation (but I did not test, if it's possible not only to alter its contents but also it's file path and name).

           

          So let's play save and assume it's the last link that came to the links collection immediately after placing the SWF:

           

          var mySWFPosterImageLink = app.documents[0].links[-1];
          

           

          Links can be relinked, so:

           

          var myNewSWFPosterImageFile = File("fullImageFilePathHere");
          mySWFPosterImageLink.relink(myNewSWFPosterImageFile);
          

           

          should do the job.

           

          If you seek for a relationship between the placed SWF ([object Movie]) and the standard poster image, look for:

           

          var myPlacedSWFLink = app.documents[0].links[-2];
          

           

          immediately after placing the SWF.

           

          Uwe

          1 person found this helpful
          • 2. Re: relinking?
            Laubender Adobe Community Professional & MVP

            @Petteri – Oh, I forgot, the second part of the question was how we could fit the poster image to its frame.
            To get that we have to do look at the geometricBounds of the frame that holds the swf and apply that to the image inside the frame, which actually sits inside the placed SWF object:

             

            var myPlacedSWFContainer = myPlacedSWFLink.parent.parent;
            
            myPlacedSWFContainer.pageItems[0].graphics[0].geometricBounds = myPlacedSWFContainer.geometricBounds;
            

             

             

            My testing showed that would do the job.

             

            Have a nice weekend!

            Uwe

            • 3. Re: relinking?
              Laubender Adobe Community Professional & MVP

              @Petteri – instead of:

               

              myPlacedSWFContainer.pageItems[0].graphics[0].geometricBounds =
              

               

              you could also write:

               

              myPlacedSWFContainer.movies[0].graphics[0].geometricBounds = 
              

               

              Since we know that a placed SWF is of object type [object Movie].

               

              Uwe

              • 4. Re: relinking?
                Petteri_Paananen Level 4

                Hey that´s amazing... it works!!! Million thanks to you...

                Could you say how i can make it run inside the loop. All the new link names are named as running numbers starting from 1.jpg, 2.jpg and so on...

                 

                The line you suggested

                var myNewSWFPosterImageFile = File("/Users/user/Desktop/dumpster/poster 2/1.jpg");

                produces naturally same poster image 1.jpg to every SWF-instance.

                 

                I tried to change it to

                for (myCounter = 0; myCounter < myNumberOfFrames; myCounter++){ 

                var mySWFPosterImageLink = app.documents[0].links[-1];

                var myNewSWFPosterImageFile = File("/Users/petteripaananen/Desktop/dumpster/poster 2/" + myCounter + ".jpg");

                 

                But it didn´t work, I got the following warning:

                 

                Kuvankaappaus 2012-4-21 kello 11.41.09.png

                • 5. Re: relinking?
                  Petteri_Paananen Level 4

                  ..forget the last one... I just realized that loop starts from 0.jpg instead of 1.jpg and since there´s not file named 0.jpg, it gives me that erros. If I start images from 0.jpg, everything works perfectly... thanks again...=)