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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:32:04+00:00 2026-05-13T15:32:04+00:00

is it possible to embed sources dynamically. instead of doing this [Embed(source = ‘../../../../assets/levels/test.xml’)]

  • 0

is it possible to embed sources dynamically. instead of doing this

[Embed(source = '../../../../assets/levels/test.xml')]

I could probably do something like this

var src = '../../../../assets/levels/test.xml'
[Embed(source = src )]
  • 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-13T15:32:04+00:00Added an answer on May 13, 2026 at 3:32 pm

    It’s not possible for anything within metadata annotations to be dynamic :/. That is, you can’t place variables into metadata annotations. If that was possible, there would be SO many cool possibilities. So your first option is the only way to directly embed xml.

    You could, however, write a custom metadata parser that figured out how to load (not embed) your xml file. Something like:

    [LoadFile]
    public var source:String = "../../../../assets/levels/test.xml";
    

    I would implement that like the code below (just wrote this right now, haven’t tested it). And then you’d “process” your class via something like MyMetadataUtil.process(this). Lots of ways to do that.

    public function extractMetadata(target:Object):void
    {
        var description:XML = flash.utils.describeType(target);
        var tag:String = "LoadFile"
        var metadata:XMLList = description.accessor.metadata.(@name == tag);
        metadata += description.variable.metadata.(@name == tag);
        var i:int = 0;
        var n:int = metadata.length();
        // usually called a 'directive'
        // holds values from metadata annotation
        var token:Object = {};
        for (i; i < n; i++)
        {
            metadataXML = metadata[i];
            token.property = metadataXML.parent().@name;
            // token.source = myClass.source;
            token.source = target[token.property];
            var request:URLRequest = new URLRequest(token.source);
            var loader:URLLoader = new URLLoader();
            loader.addEventListener(Event.COMPLETE, loader_completeHandler);
            loader.addEventListener(IOErrorEvent.IO_ERROR, loader_ioErrorHandler);
            loader.load(request);
        }
    }
    
    protected function loader_completeHandler(event:Event):void
    {
        event.currentTarget.removeEventListener(event.type, loader_completeHandler);
        trace("SUCCESSFULLY LOADED FILE!");
    }
    
    protected function loader_ioErrorHandler(event:Event):void
    {
        event.currentTarget.removeEventListener(event.type, loader_ioErrorHandler);
    }
    

    That stuff would go into some util/manager/processor class. Then anywhere in your code, you could use this:

    [LoadFile]
    public var source:String = "myFile.xml";
    

    And that could be dynamic. Check out the Swiz Framework for some example source code on how to implement custom metadata processors. Or even better, Openflux’s MetaUtil. Once you set that up once, you can do some hardcore stuff in your code. Makes coding fun and fast.

    Hope that helps,
    Lance

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

Sidebar

Ask A Question

Stats

  • Questions 314k
  • Answers 314k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Following on from Remus' theoretical answer... you need to generate… May 13, 2026 at 11:00 pm
  • Editorial Team
    Editorial Team added an answer An index in mysql is a mapping from each value… May 13, 2026 at 11:00 pm
  • Editorial Team
    Editorial Team added an answer All variables die with the script, global or local, they… May 13, 2026 at 11:00 pm

Related Questions

I have an application that I would like to embed inside our companies CMS.
Reading MSDN (and other sources) about custom report items (CRI) for reporting services 2005.
I have been struggling to get Maven2 to cooperate with me, and was wondering
Is it possible to embed images an email being sent from my app? Can
Suppose there is a Silverlight streaming video player on a random web site. How

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.