3 Replies Latest reply on Aug 30, 2010 2:39 PM by thebouv

    StyleManager timing and ImageSnapshot

    thebouv Level 2

      I think I'm being dense on this, but I can't figure it out.

       

      I have a Group with an image, and several TextAreas on top of the image.  The TextAreas have a yellow border.

       

      I want to use ImageSnapshot to a static shot of the image + text areas .. a sort of "Preview" window.

       

      But of course I want to disable the borders on the text areas first.

       

        styleManager.getStyleDeclaration("spark.components.TextArea").setStyle("borderVisible","false");
        var bitmap:BitmapData = ImageSnapshot.captureBitmapData(mainGroup);
      

       

      mainGroup is the s:Group containing the image and text areas.

       

      The image produced shows the text areas with their borders, but the text areas really do lose their borders in the app.

       

      setStyle doesn't seem to fire an event to listen for it to be complete, so how do I do this?  I need ImageSnapshot to wait till setStyle is done.

        • 1. Re: StyleManager timing and ImageSnapshot
          Flex harUI Adobe Employee

          Listen for updateComplete.

          • 2. Re: StyleManager timing and ImageSnapshot
            thebouv Level 2

            showPreview() doesn't fire at all, though the style does change.

             

            ...
              mainGroup.addEventListener(FlexEvent.UPDATE_COMPLETE,showPreview);
              styleManager.getStyleDeclaration("spark.components.TextArea").setStyle("borderVisible","false");
            }
            
            private function showPreview():void {
              
              var bitmap:BitmapData = ImageSnapshot.captureBitmapData(mainGroup);
            ...
            

             

            Unless I should not being looking for updateComplete on the mainGroup (which contains the text areas and image aforementioned).  If not, what should I be listening for updateComplete on?

            • 3. Re: StyleManager timing and ImageSnapshot
              thebouv Level 2

              Ah, it didn't work because I didn't set up showPreview correctly.

               

              This works:

               

                mainGroup.addEventListener(FlexEvent.UPDATE_COMPLETE,showPreview);
                styleManager.getStyleDeclaration("spark.components.TextArea").setStyle("borderVisible","false");
              }
                
                
              private function showPreview(event:FlexEvent):void {
                var bitmap:BitmapData = ImageSnapshot.captureBitmapData(mainGroup);
              

               

              It's because I left off event:FlexEvent as a parameter to showPreview

               

              Thanks for the help!