2 Replies Latest reply on Mar 7, 2012 12:13 AM by colgakn

    The function breakApart() is currently unavailable!?

    pauldecoursey Level 1
      I have a JSFL command that I'm working on. On occassion I get this error

      The function breakApart() is currently unavailable.

      When I use this, fl.getDocumentDOM().breakApart();

      Two issues I see. First, it shouldn't be unavailable, I have selected all already and it should be able to breakApart something. Secondly, I can't test if it is available. I guess there are three things, third, I can't recover from the error, try/catch does nothing.

      Is there a way around this? I've already spent 3 hours trying to figure this out. It does seem to only happen when breaking apart text. But has also occurred with just shape objects. what's odd is I can perform the operations in flash when not scripting it without any problems.
        • 1. Re: The function breakApart() is currently unavailable!?
          tomhenry687

          I'm having a similar problem when it comes to breakApart(), except in my case its for bitmaps that have already been broken by hand. I've been attempting to use a try catch statement and have also found that it does not work. Doesn't seem like anyone knows the answers to the problem. Guess I'm doomed.

          • 2. Re: The function breakApart() is currently unavailable!?
            colgakn

            I found a solution to the 'breakApart() not available'. You have to explicitly lock all other layers other than the one you want, and explicitly select the frame:

             

            use a utility function like 'lockAllLayers' to lock all layers

             

            var tl = fl.getDocumentDOM().getTimeline();

            function lockAllLayers(isLocked)

            {

                for(var i=0;i<tl.layerCount;i++)

                {

                    tl.layers[i].locked = isLocked;

                }

            }

             

            unlock the one you need

                 tl.layers[i].locked = false;

             

            explicilty select the layer and frame you want:

             

            timeline.currentLayer = 2;

            timeline.currentFrame = 3;

             

            only THEN can you actual set the element you want to select, or use document.selectAll()

             

            You can check if breakApart() is available by using an if statement like

             

            if(document.selection && document.selection.elementType == "<whatever you're looking for here>")

                  document.breakApart();

             

             

            Hope you managed to understand that!