2 Replies Latest reply on Feb 24, 2016 2:40 PM by benm1123748

    SWF panel listener for changed selection


      In short, my question is as follows. Is it possible to create a listener which

      detects when the current selection in the Flash authoring tool has changed,

      and informs my SWF panel? This does not have to be a listener per se,

      it can be some hand-crafted process which consumes some reasonable amount of processor time.


      I describe my question more precisely below.


      Suppose that I want to create an SWF extension panel for Flash (in Flash or Flex),

      and I would like the panel to display a property of the object currently selected on scene

      in the Flash IDE -- like the instance name of the object (if it exists).


      I can use JSFL to detect the instance name of the selected object, and pass the string to the

      SWF panel using call(), for instance. The problem is that I don't know how

      to detect that the user has selected the object, or that the selection has changed.


      Ideally, I would like to add an event listener that listens for such an action in the flash authoring tool.

      However, using JSFL, this does not seem to be possible (I can only listen to events such as frame changed

      or layer changed, but not selection changed).


      I tried the following solutions:


      1. Periodically check in JSFL whether the current selection has changed.

      The problem is that in JSFL, there is no sleep function, or anything alike. The javascript

      methods setInterval and setTimeout do not work in JSFL. Therefore, in order to periodically check for changes,

      one must actively loop. This is extremely resource-consuming -- in fact, it hangs the flash IDE.


      2. The periodic check can be triggered by the SWF panel itself. In actionscript, I can use setInterval to periodically

      invoke the selection update function via JSFL. I have set the interval to 400 milliseconds, which gives a reasonably quick

      reaction to changes. However, the functionality I want to implement is in fact more complicated than just retrieving the

      instance name of the selected object. As a consequence, performing this operation every 400 milliseconds still consumes

      too much processor time (the flash IDE consumes 30% of my processor time, even if the user doesn't do anything).


      Therefore, I still would like to find a solution which does not use the processor when the user does not do anything in the Flash IDE.