29 Replies Latest reply on Aug 4, 2012 3:31 PM by HugoKing321

    How to put an MSO inside another MSO

    Laubender Adobe Community Professional & MVP

      Hello all!

      An interesting question came up in the following post by Folobo:

       

      http://forums.adobe.com/message/4572897#4572897

       

      "Is it possible to use a slideshow embedded in a big overlay slideshow?"

       

      I'd like to rephrase this question:

       

      "Is it possible to put a MultiStateObject (MSO) inside another MultiStateObject?"

       

      And further: if the answer is "yes", could we put that to use with the DPS?

       

      @Folobo – this is an interesting question. A quick test is showing that you cannot do it in the UI (correct me if I'm wrong).

       

      Let's try it this way:

      If you have two objects:

      1. an MSO #1 (with two rectangles, rectangle #1, rectangle #2)

      2. Another rectangle on the page: rectangle #3

       

      Now select the two objects and make an MSO out of it (using the "Object States" panel).

      You would think, now I get an MSO with two states, state 1 with rectangle #3 together with state 2 with MSO #1.

       

      But not so:

       

      Result: One new MSO with three states (rectangle #1, rectangle #2, rectangle #3)

       

      Hm. I don't give up on that. Let's try it another way:

      Could we select at least two objects inside a state of an MSO and make that a new MSO?

       

      Sure, We could select two objects inside a state, but since we are *inside* an MSO the "Object States" panel does not show the possibility to make a new MSO. You can only add states or add objects to states…

       

      Frustrating. End of story? Maybe…

       

      Be forewarned. The following is highly experimental!

       

      Let's try it by scripting (ExtendScript/JavaScript).

       

      The scripting reference is showing that an MSO "MultiStateObject" object has an add()-method. And further on, that add()-method could be applied to:

       

      Document

      Spread

      MasterSpread

      Page

      Layer

       

      pageItem

       

      And that is the key to a possible solution. We could add a new MSO to a "pageItem" object.

       

      A simple rectangle should be qualify for a "pageItem" object; and that, of course, could reside in a state of an MSO.

      So, we could add a new MSO to a rectangle inside of a MSO!

       

      How can we access a rectangle inside a MSO? Easy: We could select it and work with that selection.

       

      So let's do that: select the rectangle in the first state of an MSO and run this one-line-script (be sure you did select the rectangle and not the MSO or one of its states:

       

      app.selection[0].multiStateObjects.add();
      

       

      We now have an MSO inside another MSO!

       

       

      Explanation:

       

      A "generic MSO" was added with the add()-function to a selection (the container object: in our case the selected rectangle).

      The "generic MSO" is a two state MSO consisting of one rectangle in each state of a very small size (10px x 10px).

      At first it is invisible, because it is very likely that it is positioned outside the geometric bounds of its container object (the rectangle).

       

      But we can customize this!

      Go to the layers palette and select the new MSO, move it inside the geometric bounds of its container object, readjust its size, add states as you wish, populate the states with images, and other objects etc.pp.

       

       

      So, what can we do with an MSO inside another MSO? (As I already said, this is highly experimental.)

       

      My experiments with that are very fresh. I did not try a lot. But it seems that we could at least autoplay this MSO.

       

      I have to test more thoroughly what is possible and what will work with buttons etc.pp…

      I really like to hear from you what you will find out and if you can put it to any use.

       

      Uwe

       

      Message was edited by: Laubender

        • 1. Re: How to put an MSO inside another MSO
          Folobo Level 1

          @ Laubender

           

          Many thanks, you are a great coder! But i have a problem to try this solution:

           

          How can we access a rectangle inside a MSO? Easy: We could select it and work with that selection. So let's do that: select the rectangle in the first state of an MSO and run this one-line-script (be sure you did select the rectangle and not the MSO or one of its states:

          I have a problem to select the object inside a MSO. I select the state but it's not correct!

          So i think to check the layers pane: but here i see only one layer rectangle (but the rectangle are 3)!

          So: how the select my object to run the script?

           

          Many thanks.

          f

          • 2. Re: How to put an MSO inside another MSO
            Laubender Adobe Community Professional & MVP

            @Folobo – You can select every object of the active state of your MSO in the Layers palette. If the object you want to select is in another state, make that state to the active state and then select the object.

             

            See screen grabs of the MSO on the page and the Layers palette.

             

            1. The MSO selected (active state is "State 1"):

             

            MSO_selected.png

             

             

            2. The rectangle in State 1 selected:

             

            Rectangle_in_state1_selected.png

             

            Hope that helps,
            Uwe

            • 3. Re: How to put an MSO inside another MSO
              Folobo Level 1

              Many thanks Uwe. Now i understand how to do and i'm happy. All work. Yes, it's not easy but it can be very useful!  Really thanks. f

              • 4. Re: How to put an MSO inside another MSO
                Laubender Adobe Community Professional & MVP

                Ok. To ease the use of the script snippet I added two features:

                 

                1. Bounding Box of the new MSO is the same as selection

                2. The new MSO is selected after executing the script

                 

                An orderly error message will pop up, if the script could not create a new MultiStateObject…

                 

                //AddGenericMultiStateObjectToSELECTION.jsx
                //Uwe Laubender
                //DESCRIPTION:Adds a generic MultiStateObject to the selection; new MSO will be selected after running the script.
                /**
                * @@@BUILDINFO@@@ AddGenericMultiStateObjectToSELECTION.jsx !Version! Tue Jul 24 2012 19:24:29 GMT+0200
                */
                
                
                try{
                
                    var sel=app.selection[0];
                    var selGB = sel.geometricBounds;
                    var newMSO = app.selection[0].multiStateObjects.add({
                        geometricBounds:selGB
                        });
                
                    alert("Created a new MSO.");
                
                    app.select(newMSO);
                
                }catch(e){alert("ERROR"+"\r"+e.message+"\r\r"+"No new MultiStateObject was created.")};
                

                 

                 

                Hope, that helps…

                 

                Uwe

                • 5. Re: How to put an MSO inside another MSO
                  Folobo Level 1

                  Great Uwe! I try!  f

                  • 6. Re: How to put an MSO inside another MSO
                    Laubender Adobe Community Professional & MVP

                    Just test the results carefully with the Adobe Content Viewer on your device…
                    There could be bad surprises…

                     

                    Hope to hear from you.

                     

                    Uwe

                    • 7. Re: How to put an MSO inside another MSO
                      Felipe - dualpixel Level 3

                      Hi, Very nice

                      I tried that with buttons inside and outside from nested multistate objetcs and works well.

                      Now I can do 2 levels in slideshow

                      Great

                       

                      __Felipe

                      • 8. Re: How to put an MSO inside another MSO
                        Laubender Adobe Community Professional & MVP

                        Hi, Felipe!

                         

                        Thank you for testing. I'd like to hear more examples of usage…
                        (Before marking my own thread as "Correct" ;-) )

                         

                        Uwe

                        • 9. Re: How to put an MSO inside another MSO
                          mobly Level 3

                          Hi Uwe

                          I've been reading the thread, but still don't understand where the script is attached, I'd love to test this out!

                          cheers

                          Alistair

                          • 10. Re: How to put an MSO inside another MSO
                            Laubender Adobe Community Professional & MVP

                            @Mobly –

                            What you need is a selection of a single "graphic frame" like a rectangle, a oval etc..

                            Even a Group object will qualify as a selection.

                             

                            That selection could be inside a MultiStateObject (MSO).

                             

                            The script is adding a new generic MSO to your selected object.

                            That means the new MSO will be "inside" the selection after executing the script.

                             

                            In case you choose a rectangle inside a MSO as your selection, you'll get an nested MSO: a MSO inside an MSO. Impossible to do in the UI.

                             

                             

                            To access the script snippet, copy the code in answer #4 to your text editor, save it as a plain text file with *,jsx suffix to your scripting folder of your InDesign installation:


                            Example path:

                            Applications/Adobe InDesign CS6/Scripts/Scripts Panel

                             

                            To organize your scripts you can put them into subfolders of the Scripts Panel.

                             

                            You now have immediate access to that script in the Scripts panel of InDesign. No need to quit and restart InDesign.

                             

                             

                            Make your selection and double-click the script in the Scripts panel to fire it up. A new generic MSO will reside inside your selection. The new MSO is now selected and you can customize it: adding states, adding images and other objects to states, etc.pp.

                             

                            If you selected an unappropriate page object for adding a new MSO, you will get a warning message. E.g. if you selected an MultiStateObject instead of a rectangle inside a MultiStateObject or if you selected text or a text frame.

                             

                            If all is well, you'll get an alert message "Created a new MSO." and the new MSO is immediately selected ready for customization.

                             

                            Uwe

                             


                            • 11. Re: How to put an MSO inside another MSO
                              Folobo Level 1

                              Work well for me!

                              Many thanks Uwe!

                              Great job!

                              f

                              • 12. Re: How to put an MSO inside another MSO
                                mobly Level 3

                                Hi Uwe

                                You explained the process very well, and I added the script to the panel etc.

                                However, perhaps I don't have such good foresight as you, as I'm a bit lost what to do next.

                                 

                                I created a basic 2 state object, red square; blue square. I double click the MSO to select my first red square, then double click your script, and a message pops up to tell me I have created a new MSO.

                                But all that has happened is the my 2 squares have lost the colour that I gave them, I can go back in and add the colour again, but what am I supposed to be able to do now?

                                Thank you for your generous time, in sharing this with us, I'm very keen to get some realy sexy buttons working with this.

                                Cheers

                                Alistair

                                • 13. Re: How to put an MSO inside another MSO
                                  Laubender Adobe Community Professional & MVP

                                  @Mobly – Try to select a rectangle in your state 1 like in the screen grab #2 of post #2 of this thread.

                                  And then run the script.

                                   

                                  Just a question: after the alert message that you clicked "ok", did you check the Layers panel?
                                  There should be a new MSO visible and it should also be selected.

                                   

                                  Uwe

                                  • 14. Re: How to put an MSO inside another MSO
                                    Laubender Adobe Community Professional & MVP

                                    @Mobly – in case it did not work out for you, here some screen grabs for the different steps:

                                     

                                    1. Select an MSO:

                                     

                                    01-MSO_selected.png

                                     

                                     

                                    2. Select a "graphic frame" inside the MSO; in this case a "<square>"; you can see the big blue dot in the Layers panel behind the generic name "<square>":

                                     

                                    02-Square in MSO_selected.png

                                     

                                     

                                    3. Open the Scripts Panel and select the script:

                                     

                                    03-Using the script_Before.png

                                     

                                     

                                    4. Run the script by double-clicking the script; the generic name of your selected object has changed to "graphic frame", but trust me, it's still a square…

                                     

                                    04-Using the script_ShowingMessage.png

                                     

                                     

                                    5. Click the "Ok" button of the message and InDesign will select the new MSO ("Multi-state 2") as you can see here. It has two states with one rectangle each,  fill and stroke is "None":

                                     

                                    05-Using the script_AfterMessage.png

                                     

                                     

                                    And: you can see that this new MSO is nested inside the MSO ("Multi-state 1").
                                    What you do with that construct is up to you:

                                     

                                    6. Color the "<square>" of state 1 of "Multi-state 2":

                                     

                                    06-ColorSquareOfState1inMSO2.png

                                     

                                     

                                     

                                    7. Resize and change position of "Multi-state 2":

                                     

                                    07-ChangeSizePositionOfMSO2.png

                                     

                                     

                                    8. But remember: "Multi-state 2" is nested in the graphic frame you selected before running the script:

                                     

                                    08-NestedInGraphicFrame.png

                                     

                                     

                                    I hope you get the picture now…

                                     

                                    Uwe

                                    • 15. Re: How to put an MSO inside another MSO
                                      alidabbs Level 3

                                      Uwe, what a star! I've just tried this and it works exactly as described!

                                       

                                      It means I can now create an MSO that calls up an image gallery that lets a user swipe from image to image inside of tapping on NEXT/BACK buttons, safe in the knowledge that when the user closes the gallery, the active swipe area is no longer on the page (which would otherwise interfere with page-turning).

                                       

                                      Oh joy, I've been looking for a non-Web-view solution to large images in swiping galleries for two years!

                                       

                                      Big beer if we ever meet.

                                       

                                      Ali

                                      • 16. Re: How to put an MSO inside another MSO
                                        BobLevine MVP & Adobe Community Professional

                                        I think using the works “safe in the knowledge” is a bit of a stretch.

                                         

                                         

                                         

                                        While I admit this is seriously cool, I have my doubts about doing anything like this without official suppor