A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Better way to code this?

Threaded View

  1. #1
    Member
    Join Date
    Sep 2010
    Posts
    32

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center