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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:45:06+00:00 2026-05-15T15:45:06+00:00

I have a png image on Library that i have declared it via Properties

  • 0

I have a png image on Library that i have declared it via Properties as Background class which extends BitmapData.
When i type:
var BMDClass:Class = getDefinitionByName( "Background" ) as Class;
i get: variable Background is not defined!!
But when i do:
trace( getQualifiedClassName( new Background(0,0) ) );
i get: Background !!
I can’t figure out the cause of the error.

  • 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-15T15:45:07+00:00Added an answer on May 15, 2026 at 3:45 pm

    I believe this is because you need to have a reference to the Background class before you can actually get the definition by name. Simply importing the Background class will not compile the class in to your swf, you need to reference it in some way. Creating an instance of the class is one way, however you can also reference the class after your import.

    try something like…

    import com.somedomain.Background;
    Background;
    

    This should create a reference to you class and ensure it is compiled in to your swf.

    Edit to show multiple class usage.

    If you have multiple background classes, I would recommend trying to make them adhere to an interface. I would then also create a background factory class that would allow you to create background instances from your configuration file. This also means that you would be able to put all your references to your background classes in the factory class. Here is what the factory could look like.

    // let the compiler know we need these background classes
    import com.somedomain.backgrounds.*;
    DarkBackground;
    LightBackground;
    ImageBackground;
    
    class BackgroundFactory
    {
        public function create(type:String):Background
        {
            var bgClass:Class = getDefinitionByName(type) as Class;
            return new bgClass();
        }
    }
    

    Then to get a background instance from your config, you would do something like…

    // parse your config file...not sure what format you've got it in.
    
    // instantiate a background factory and create an instance based on the name from your config. 
    var bgFactory:BackgroundFactory = new BackgroundFactory();
    var bg:Background = bgFactory.create(someStr);
    

    Edit to extend example

    package com.somedomain.background
    {
        interface Background
        {
            function get img():Bitmap;
        }
    }
    
    package com.somedomain.background
    {
        class SomeImageBackground extends Sprite implements Background
        {
            protected var _img:Bitmap;
    
            public function SomeImageBackground():void
            {
                _img = new SomeAssetFromLibrary();
            }
    
            public function get img():Bitmap
            {
                return _img;
            }
        }
    }
    

    Using these external classes would give you a bit more control over where the images come from. You could load them external, embed them using the embed meta data and even load them from the stage.

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

Sidebar

Related Questions

I have a PHP class that creates a PNG image on the fly and
I have a PNG image that has an unsupported bitmap graphics context pixel format.
I have an image (PNG file) that has an alpha channel that is set
I have a UIImageView which has a png image sequence loaded into it. My
I have a PHP script that can encode a PNG image to a Base64
I have a slow connection that I need to send a PNG image over
I have an image (*.png) which contains two blocks of text. I am trying
I have created a PNG image that is 200 DPI, and perfectly sized for
I'm looking for some image library that can work with multiple formats (jpg,gif,png), and
I have several png image files with names like this - house_number_5.png house_number_512.png house_number_52352.png

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.