Yes, embeding can be done in that way too. You could use it like
var test:Bitmap = new_up
No, I was asking if I can embed in another way then the one I wrote.
If I can somehow concatenate embedded vars somehow.
Asset embedding is performed at compile time. The assets are added into the compiled swf. So there is no way to programmatically embed content in Flex. Instead, you'd have to do some preprocessing on your .mxml and .as files before they get compiled.
Or just load them dynamically into an Image component.
I thought that might be the case, thank you!
About my second question, I want to concatenate embedded vars like this:
_image is an Embded image.
The code above throws an error. How can I do this please?
What error are you seeing?
This works for me:
<?xml version="1.0" encoding="utf-8"?>
<!-- Place non-visual elements (e.g., services, value objects) here -->
public var afImage:Class;
public function loadImage():void
var c:Class = this["afImage"];
img.source = c;
<s:Button label="Load" click="loadImage()"/>
Well, for starters I am using Flex 3, not 4.
The error is at compile time and the first line is:
ReferenceError: Error #1069: Property _close not found on MyClass and there is no default value.
I test this by setting it as icon for an Alert window.
If I put _close it works.
If I put this["_close"], Flex Builder doesn't throw an error but the compiler does, the one above.