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 6367583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:34:00+00:00 2026-05-25T00:34:00+00:00

I am having an issue with a class I’m working on. I currently load

  • 0

I am having an issue with a class I’m working on. I currently load an image as a bitmap and store its data into regState:BitmapData so that I may make new instances of that image later on. When I test if I can use the loaded data at a later time with my newBitmapIntance() function, it says that regState is null. I’m lost as to why this is the case, since it works flawlessly to create an instance of itself in my loadContent() function. Any way I can successfully hold on to my loaded bitmapdata for later use?

Class so far For reference:

package  {

    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.net.URLRequest;
    import flash.display.Loader;
    import flash.display.Bitmap;
    import flash.display.BitmapData;

    public class MyObj extends MovieClip
    {
        private var regState:BitmapData;

        public function MyObj() 
        {

        }
        public function loadImage(url:String):void
        {
            var urlRequest:URLRequest = new URLRequest(url);
            var imgLdr:Loader = new Loader();
            imgLdr.load(urlRequest);
            imgLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, loadContent);
        }

        private function setRegState(temp:BitmapData):void
        {
            this.regState = temp.clone();
        }
        public function getRegState():BitmapData
        {
            return this.regState;
        }

        private function loadContent(event:Event)
        {
            var temp:Bitmap = event.target.content as Bitmap;
            this.setRegState(temp.bitmapData);

            this.addChild(newBitmapIntance());
        }

        public function newBitmapIntance():Bitmap
        {
            var temp:Bitmap = new Bitmap(this.getRegState());

            return temp;
        }
}
  • 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-25T00:34:00+00:00Added an answer on May 25, 2026 at 12:34 am

    Refactored MyObj:

    package
    {
        import flash.display.Bitmap;
        import flash.display.BitmapData;
        import flash.display.Loader;
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.net.URLRequest;
    
        public class MyObj extends MovieClip
        {
            private var _bitmapData:BitmapData;
    
            public function loadImage(url:String):void
            {
                var urlRequest:URLRequest = new URLRequest(url);
                var imgLdr:Loader = new Loader();
                imgLdr.load(urlRequest);
                imgLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, loadContent);
            }
    
            public function clone():MovieClip
            {
                var newClip:MovieClip = new MovieClip();
                newClip.addChild( new Bitmap( _bitmapData.clone() ) );
                return newClip;
            }
    
            public function MyObj() 
            {
    
            }
    
            private function loadContent(event:Event):void
            {
                this._bitmapData = Bitmap(event.target.content).bitmapData;
                this.dispatchEvent( new Event( "imageLoaded" ) );
            }
        }
    }
    

    Use it from another class:

    package
    {
        import flash.display.MovieClip;
        import flash.display.Sprite;
        import flash.events.Event;
    
        public class Test extends Sprite
        {
            private var _factory:MyObj;
    
            public function Test()
            {
                _factory = new MyObj();
                _factory.loadImage( "test.jpg" );
                _factory.addEventListener( "imageLoaded", imageLoaderHandler );
            }
    
            private function imageLoaderHandler( e:Event ):void
            {
                var one:MovieClip = _factory.clone();
    
                this.addChild( one );
    
                var two:MovieClip = _factory.clone();
                two.x = 100;
                two.y = 100;
    
                this.addChild( two );
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having an issue using the Cookie class of the Servlet API 2.5 on
I can't get past this issue I am having. Here's a simple example: class
I'm having issues getting Firefox to update a webpage when its class is changed
I'm having an issue with a query that currently uses LEFT JOIN weblog_data AS
I am having in issue with IE passing a string back into an swf
I am having an issue trying to save into an intermediate table. I am
I keep running into this issue: class CCreateShortcutTask : public CTask { public: CCreateShortcutTask(
I am having issue with memory after running many times my app. java.lang.OutOfMemoryError: bitmap
I am having an issue with namespaces in Rails 3.1. I have a class,
I am having an issue serializing a c# class to an XML file that

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.