Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 629675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:46:20+00:00 2026-05-13T19:46:20+00:00

package { import flash.display.*; import flash.events.*; import flash.net.URLRequest; public class Main extends MovieClip {

  • 0
package
{
    import flash.display.*;
    import flash.events.*;
    import flash.net.URLRequest;

    public class Main extends MovieClip
    {
        // state
        private var iname:String = "image.gif";
        private var w:int;
        private var h:int;
        private var loader:Loader;

        // constructor
        public function Main():void
        {
            loadImage( iname ); 
            trace( w + " " + h );

        }

        // methods
        private function loadImage( filename:String ):void
        {
            loader = new Loader();
            loader.contentLoaderInfo.addEventListener( Event.COMPLETE, completeHandler );
            loader.contentLoaderInfo.addEventListener( Event.COMPLETE, someHandler );
            var request:URLRequest = new URLRequest( filename );
            loader.load( request );
            this.addChild( loader );        
        }



        // event handlers
        private function completeHandler( event:Event ):void
        {           
            trace( "image loaded\n" + event.target.url );
            trace( event.target );
        }           

        private function someHandler( event:Event ):void
        {
            w = loader.contentLoaderInfo.width;
            h = loader.contentLoaderInfo.height;            
        }
    }
}

But when i ran i get 0 0 for width and height. How can i get the correct values ?
Also if the picture is loaded correctly and after i attach it to a movieclip why i cannot take the width and height from movieclip object?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:46:20+00:00Added an answer on May 13, 2026 at 7:46 pm

    Is it just me or are you asking for the width and height before the Complete event fires? What results do you get if you move your w and h trace into the “someHandler” function, after you set them?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

package { import flash.display.MovieClip; import flash.events.Event; public class Bullet extends MovieClip { private var
package { import flash.display. ; import flash.events. ; import flash.net.*; public class exp1 extends
Consider this simple AS3 class. package { import flash.display.Sprite; import flash.display.MovieClip; public class MySprite
I have as3 class like this package { import Global; import flash.display.MovieClip; import flash.events.*;
package { import mx.controls.LinkButton; import flash.text.TextLineMetrics; public class multiLineLinkButton extends LinkButton { override protected
I have the following custom event: package com.un.photoManager.events { import flash.events.Event; import mx.collections.ArrayCollection; public
This piece of code is from Adobe docs : package { import flash.display.Loader; import
I can I get the XML data from 3rd function? package { import flash.display.*;
This program returns: package main import ( flag fmt ) func main() { num_agents
Having a simple Akka HTTP server: package org.package.some import akka.actor.{IOManager, IO, Actor} import java.net.InetSocketAddress

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.