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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:03:53+00:00 2026-06-02T21:03:53+00:00

I am using flash.utils.getDefinitionByName in an attempt to grab an art asset. I use

  • 0

I am using flash.utils.getDefinitionByName in an attempt to grab an art asset. I use this function quite a bit and haven’t had trouble until now. Check it:

assetName = Assets.MegaBerry; // works
assetName = getDefinitionByName("Assets.MegaBerry") as Class; // doesn't work

What the heck?? Error response for the second line is “Variable not found.“

If it matters: Assets is a file in my root source directory (it has no package; Assets is the fully qualified name) and I’ve tried putting:

import Assets;

at the top with no luck.

For reference, in Assets.as I have:

    [Embed(source = "../art/Inventory/MegaBerry.png")]
    public static var MegaBerry:Class;
  • 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-06-02T21:03:54+00:00Added an answer on June 2, 2026 at 9:03 pm

    Your problem is that embedding the resource into the Assets class will create a static variable of type Class that belongs to that class – which is what you are referencing when you use Assets.MegaBerry: A variable(!) of type Class.

    It does not, however, register the MegaBerry class to a fully qualified class name. To do this, you have to use – who would have guessed it – registerClassAlias at some point in your application:

    registerClassAlias("Assets.MegaBerry", Assets.MegaBerry);
    

    After that, it will be available everywhere else when calling getDefinitionByName.

    ** EDIT **

    Well that’s some unexpected behavior… It turns out, the class that was embedded is in fact automatically registered, but under {className}_{variableName}, instead of the notation you would expect. So using:

    getDefinitionByName("Assets_MegaBerry") as Class;
    

    should to the trick.

    registerClassAlias also works, but then you need to call getClassByAliasinstead of getDefinitionByName. Sorry for the mix-up.

    ** END EDIT **

    You can also use the Embed tag to inject the resource into a separate class file, which you can then reference as expected by using getDefinitionByName, or simply using an import:

    package assets {
    
        [Embed(source="../art/Inventory/MegaBerry.png"]
        public class MegaBerry extends BitmapData {
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using: import flash.utils.ByteArray; import mx.utils.Base64Encoder; import mx.utils.Base64Decoder; . . . public static function
Hello the problem i'm experiencing is when I attempt to call javascript function. Using
This question is specific to Adobe AIR ActionScript/Flash applications. I've spend quite some time
Here is the code I am using: import flash.utils.Timer; import flash.events.TimerEvent; //Pausing the timeline
I'm using Flash Builder to build an AIR android app. To prevent the app
I'm using Flash Builder 4.6 to make an iOS app.. It's going fairly well,
I'm using Flash builder 4.6 for mobile applications. I need to drag an image
Is there a way using Flash (CS3+AS3) to determine if the published swf is
I'm using Flash Builder 4 (the version after Flex Builder 3, so very similar
I'm using Flash Builder 4 Beta 2. I have it connecting to a PHP

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.