-
Better way to code this?
I want to be able to re-size my newly loaded image proportioned to my windows size ,
but I hate how the code would be organized.
Instead of putting my imageloaded function inside my resizeListener function
is there a better way?
I wrote this before on layer 1
Actionscript Code:
stage.addEventListener(Event.RESIZE, resizeListener);
function resizeListener (e:Event):void {
// I would just put function imageLoaded(e:Event) here but better way?
}
I wrote this after on layer 2
Actionscript Code:
// Set properties on my Loader object var imageLoader:Loader = new Loader(); imageLoader.load(new URLRequest('http://localhost/images/baby.png')); imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
function imageLoaded(e:Event):void {
// Load Image addChild(imageLoader); }
Last edited by onenonly; 05-01-2012 at 12:17 AM.
-
Why would you think defining imageLoaded within resizeListener would help at all? It would then not be available to use as a listener where you're already using it.
And since all it does is call addChild, calling it from resizeListener won't do anything useful either.
What are you trying to accomplish? If you are trying to resize your loader or loaded content when the window resizes, then write code that actually does that.
-
Originally Posted by 5TonsOfFlax
Why would you think defining imageLoaded within resizeListener would help at all? It would then not be available to use as a listener where you're already using it.
And since all it does is call addChild, calling it from resizeListener won't do anything useful either.
What are you trying to accomplish? If you are trying to resize your loader or loaded content when the window resizes, then write code that actually does that.
Im making a photography gallery website basically.
Im trying to resize the imageLoader:Loader when Event.RESIZE listener is triggered.
-
Yes, I see. So why don't you write code that actually does that?
Code:
function resizeListener (e:Event):void {
//don't define imageLoaded here. It won't work where you want it.
//and don't call it either, it doesn't do any resizing.
imageLoader.width = stage.stageWidth;
imageLoader.height = stage.stageHeight;
//might need to size imageLoader.content as well.
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|