3 Replies Latest reply on Dec 29, 2010 7:49 AM by Nick.20

    Prevent s:Label scaling with NativeWindow

    Nick.20

      Hello,

       

      I've set the fontSize of a Spark Label, and added it as the child object of a NativeWindow I create at runtime. For some reason, resizing the NativeWindow proportionally increases the size of the label, despite the fontSize styling.

       

      If this isn't clear I can post my code, but does anyone know how to prevent this?

       

      Thanks,

       

      Nick

        • 1. Re: Prevent s:Label scaling with NativeWindow
          John Hall Level 4

          Some code might well help.

          • 2. Re: Prevent s:Label scaling with NativeWindow
            Nick.20 Level 1

            Here is a video demonstrating the issue: http://www.youtube.com/watch?v=JbFUWrL04l8

             

            I plan to release this GPL, so I'll post the whole mxml code:

             

            <?xml version="1.0" encoding="utf-8"?>
            <s:WindowedApplication
              xmlns:fx="http://ns.adobe.com/mxml/2009"
              xmlns:s="library://ns.adobe.com/flex/spark"
              xmlns:mx="library://ns.adobe.com/flex/mx"
              
              
              backgroundAlpha="0.0"
              showStatusBar="false"
              applicationComplete="init()">
              
              <s:Label id="lbl_Time"
                fontFamily="Aller" fontSize="120"
                height="100" width="500"
                text="12:34:56" />
              <fx:Script>
                <![CDATA[
                  import flash.events.TimerEvent;
                  import flash.utils.Timer;
                  
                  import mx.controls.Alert;
                  import mx.events.DragEvent;
                  
                  private var t:Timer;
                  private function init():void
                  {
                   this.stage.nativeWindow.close();
                   this.createWindow();
                  
                   t = new Timer(1000, 0);
                   t.addEventListener(TimerEvent.TIMER, updateTime);
                   t.start();
                  }
                  
                  private var o:NativeWindowInitOptions;
                  private var w:NativeWindow;
                  private function createWindow():void
                  {
                   var screen:Rectangle = Screen.mainScreen.bounds;
                  
                   o = new NativeWindowInitOptions();
                   o.type = NativeWindowType.UTILITY;
                   //o.systemChrome = "none";
                   //o.transparent = true;
                  
                   w = new NativeWindow(o);
                   w.height = 200;
                   w.width = 600;
                   
                   w.x = 0;
                   w.y = 0;
                  
                   w.stage.addChild(lbl_Time);
                   w.stage.align = StageAlign.TOP_LEFT;
                  
                   w.activate();
                  }
                  
                  private function updateTime(evt:TimerEvent):void
                  {
                   var HR_MASK:String = "00";
                   var MIN_MASK:String = "00";
                   var SEC_MASK:String = "00";
                   
                   var d:Date = new Date();
                   var hr:String = (HR_MASK + d.hours).substr(-HR_MASK.length);
                   var min:String = (MIN_MASK + d.minutes).substr(-MIN_MASK.length);
                   var sec:String = (SEC_MASK + d.seconds).substr(-SEC_MASK.length);
                  
                   lbl_Time.text = String(hr + ":" + min + ":" + sec);
                  }
                ]]>
              </fx:Script>
            </s:WindowedApplication>
            
            • 3. Re: Prevent s:Label scaling with NativeWindow
              Nick.20 Level 1

              Bump, just to see if my above post was missed.