Skip navigation
afxgroup1976
Currently Being Moderated

Resize a native window content mantain the aspect ratio..

Jul 26, 2012 1:01 AM

Hello,

I'm using this code top open a native window and load an external SWF into it.

 

var tableWindow:NativeWindow;
var options:NativeWindowInitOptions = new NativeWindowInitOptions();
options.systemChrome = NativeWindowSystemChrome.STANDARD;
options.type = NativeWindowType.UTILITY;
tableWindow = new NativeWindow(options);
tableWindow.title = 'MyWin';
tableWindow.width = 600;
tableWindow.height = 500;
tableWindow.stage.color = 0x000000;
tableWindow.stage.scaleMode = StageScaleMode.NO_SCALE;
tableWindow.stage.align = StageAlign.TOP_LEFT;
tableWindow.addEventListener(NativeWindowBoundsEvent.RESIZING, resizeDisplay, false, 0, true);
tableWindow.addEventListener(Event.CLOSE, closeWin);
tableWindow.activate();

 

after opening a window i load the swf into it:

 

var loader:Loader = new Loader();
var context:LoaderContext;
context = new LoaderContext();
context.allowCodeImport = true;
context.applicationDomain = new ApplicationDomain();
loader.load(new URLRequest("app:/myswf.swf"), context);
loader.contentLoaderInfo.addEventListener(Event.INIT, loadFlash);

 

I have several problems.. if i use a ScaleMode different than NO_SCALE in main swf and/or in the loaded SWF the file is shown wrong. I have a correct window but the swf is displayed HUGE into the window.. so i've decided to use NO_SCALE as ScaleMode

Is there a way to mantain the aspect ratio of the window AND (more important) resize ALSO the swf loaded into it?

 

Thank you

 
Replies
  • Currently Being Moderated
    Aug 1, 2012 8:28 AM   in reply to afxgroup1976

    I rarely do Flex but I've done a lot of AIR for AS projects and I find their windows to have this bizarre behavior as well.

     

    I think 2 things are important in my limited experience. To keep aspect ratio I set it to NO_BORDER. This maintains the aspect ratio but also allows resizing.

     

    Second on my main class I explicitly set the main SWF to a height and width:

     

    e.g.

    package yada {

     

         [SWF(width=xxx,height=xxx)]

         public class MyApp extends.....

     

    If I didn't set that in the AS3 code explicitly (the XML didn't matter at all) the SWF would be the original size. Now your content should be at the size you specify in your window and allow resize.

     

    Lastly, you're already paying attention to resizing:

     

    tableWindow.addEventListener(NativeWindowBoundsEvent.RESIZING, resizeDisplay, false, 0, true);

     

    I think you need to handle that manually. As the user intends to grow or shrink the window you need to override their resize and set the height and width explicitly based on what they try to do, forcing the outer windows size to always be a proper aspect ratio.

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 1, 2012 8:42 AM   in reply to afxgroup1976

    That metadata is for the SWF you're loading in there. You'd just set it to the correct initial size so it shows up how you expect it. After that as you resize its container it should respond appropriately.

     

    So when you resize the window using code it sounds like the SWF isn't getting a container resize event because the StageScaleMode would dutifully resize itself. That's the only lead I see.

     

    This threads last few posts might help:

     

    http://forums.adobe.com/thread/430250

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points