Adding external content to new NativeWindow in Adobe Air

Hi,

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.

Best,

C.S.
medxmediaAsked:
Who is Participating?

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

x
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.

dgofmanCommented:
0
medxmediaAuthor Commented:
Hi dgofman,

Thanks for your reply.  The link you provided references flash builder.  In Flash, "addElelment" throws an error.
0
dgofmanCommented:
Can you attach some sample of your project I would like to run locally on my machine?
0
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.events.MouseEvent;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.events.Event;
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) {
      trace("COMPLETE")
      holderMC = new MovieClip;
      //holderMC.addChild(AppLoader.content)
      //addChild(holderMC) // works as does adding AppLoader or AppLoader.content
      openWindow()
}

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

      newWindow.stage.addChild(AppLoader.content);

      newWindow.activate();
}
0

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
dgofmanCommented:
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;
newWindow.stage.addChild(bitmap);  
newWindow.activate();

for AIR application the NativeWindow class represent as popup window and you cannot apply scaling (like Alert dialogs)
I think  
0
dgofmanCommented:
But you can listening resize event and scale your image

http://www.ben-morris.com/howto-add-flex-mx-controls-to-a-nativewindow-for-adobe-air
0
dgofmanCommented:
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.
0
medxmediaAuthor Commented:
I stumbled on to my own solution.
0
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.