Adding external content to new NativeWindow in Adobe Air


I'm working on an Air application that I am building using flash professional CS5.  I have a new native window and am able to add some content (e.g. a text field) to it, but cannot add loaded files.  I have testetd the loader with the default window and its content is added as expected, but using the same method (addChild) with the new native window does not add the loaded content.

I'd appreciate any ideas you may have on how to resolve this.


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

medxmediaAuthor Commented:
Hi dgofman,

Thanks for your reply.  The link you provided references flash builder.  In Flash, "addElelment" throws an error.
Can you attach some sample of your project I would like to run locally on my machine?
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

medxmediaAuthor Commented:
Hi dgofman,

I stumbled onto the answer quite by accident and still don't fully understand it.  When adding a jpg if scaleMode isn't set to "noScale", it doesn't appear. but as soon as it is set to "noScale" it appears.  Here's the code from the test  I was doing, but at this point my question has been answered.

import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;

var screenBounds:Rectangle = Screen.mainScreen.bounds;
var screenWidth:Number = screenBounds.width
var screenHeight:Number = screenBounds.height

stage.nativeWindow.x = Math.floor((screenBounds.width - stage.nativeWindow.width)/2);
stage.nativeWindow.y = Math.floor((screenBounds.height - stage.nativeWindow.height)/2);

var AppLoader:Loader = new Loader();
AppLoader.load(new URLRequest("test.jpg"));
AppLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, reportComplete);

var holderMC:MovieClip;

function reportComplete(event:Event) {
      holderMC = new MovieClip;
      //addChild(holderMC) // works as does adding AppLoader or AppLoader.content

function openWindow():void {
      var initOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
      initOptions.systemChrome = NativeWindowSystemChrome.NONE;
      var newWindow:NativeWindow = new NativeWindow( initOptions );  
      newWindow.width = screenWidth-100;
      newWindow.height = screenHeight-100;
      newWindow.x = 50
      newWindow.y = 50
      newWindow.stage.align = "TL";

      newWindow.stage.scaleMode = "noScale"; //if commented out the jpg does not appear



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ok, now is clear for me.
Yes you have to use code bellow

newWindow.stage.scaleMode = StageScaleMode.NO_SCALE;
newWindow.stage.align = StageAlign.TOP_LEFT;

var bitmap:Bitmap = AppLoader.content as Bitmap;

for AIR application the NativeWindow class represent as popup window and you cannot apply scaling (like Alert dialogs)
I think  
But you can listening resize event and scale your image
In the precending code, you've also avoided the deformation of the objects on the stage by setting the scaleMode property to StageScaleMode.NO_SCALE.
medxmediaAuthor Commented:
I stumbled on to my own solution.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.