2 Replies Latest reply on Feb 2, 2009 7:41 AM by ia2

    States and Bitmap.Draw

    ia2
      I'm attempting to use states to reformat a canvas for printing/exporting.
      The idea is to be able to export an image of the canvas as below
      c:Canvas has 2 states - null (base) and "Print".

      c.currentState = "Print";
      save(c);
      c.currentState = "";

      Where saveim is a custom function that takes care of all the saving details, but essentially takes a snapshot with Bitmap.draw .
      --

      The problem is that some state change elements don't seem to change fast enough.

      Changing the visibility of a child of 'c' in the state definition works fine, but changing "includeInLayout" doesn't appear to get called at the same time.

      1. I've ensured that the desired state is reached (by not restoring the state afterwards).
      2. I've tried moving the save comment into a StateChangeEvent.CURRENT_STATE_CHANGE event listener, but that still seems to be too early.

      I'm guessing the page actually needs to be rendered before the layout is updated. If that's so, how can I ensure this happens before save is called? If not, then what triggers the layout update and can I listen for it?