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

  • Home
  • SEARCH
  • 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 7012953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:19:23+00:00 2026-05-27T22:19:23+00:00

another flashbuilder brainbreaker for me… I have a class with a contstructor that should

  • 0

another flashbuilder brainbreaker for me…

I have a class with a contstructor that should only change the source of an image.

    [Bindable]
    [Embed(source='../pictures/test.jpg')]
    private var _picture:Class; 

    public function Test(newSource:*****)
    {
        _picture.source = newSource;
    }

(the image is not an image, but a class, I am aware of this, it is meant to be so 🙂 )

The problem is that when I call the constructor, let’s say:

var test:Test = new Test(pictureAtStage.source);

Flashbuilder will give an error, becouse I can’t tell the compiler what data type “newSource” at the constructor will have…

*edit:
When i use _picture.source, the embedded source does not seem to be changed…?

Anyone knows an answer?

  • 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-27T22:19:24+00:00Added an answer on May 27, 2026 at 10:19 pm

    Are we talking about mx.controls.Image? if so, then the source of an image can be: a Class, a Bitmap (not a BitmapData), a String (in which case it is assumed that you wanted to load it instead of using an embedded one). If you want to find a common denominator for all these, then Object is that class, however, I would rather limit it to something particular to your use case.

    However, if I may advise anything… don’t use mx.controls.Image, it’s too bloated, even for Flex framework. If it must be a UIComponent – extend UIComponent and let the source be of type BitmapData – this way you will be able to manage resources better – you could reuse the same actual image for example. You could then use graphics property of the control to display the image.

    Another advise, if you are still here 🙂 Don’t use [Bindable], especially the short version of it, especially not on a private variable – you will save yourself the frustration of countless hours of debugging it… Besides, in your case you aren’t going to change the value of that variable anyway…

    Are you still here? Well, don’t use [Embed] on variables, use it on class definition – slightly more work for you, but this will, potentially, make your code more portable. If you embed on class the compiler will not generate a silly “something-something-Asset” class, it will use Bitmap or BitmapData – whichever your class extends. Thus, you will not introduce a dependency on Flex framework, and, in general, you will have more control over your code.

    EDIT: the above was written assuming that _picture (class) variable and _picture (some variable used in a function) are not the same thing. But if they are the same thing, then Class class is dynamic, which means that you can add to it properties at runtime (don’t know why, it’s a design decision by Adobe…), however, the compiler will act as if it’s not possible, so you would work around that by adding the property through reflection:

    var _picture:Class = Sprite;
    _picture["source"] = whatever;
    trace(Sprite["source"]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Another basic Rails question: I have a database table that needs to contain references
Another question related to this one . I have a List<SortableObjects> that is the
Another noob question that seems like it should be simple: Thanks to the help
I'm using Flashbuilder for this. I have a button that changes the id of
Another question by a newbie. I have a php variable that queries the database
Another question by a newbie. I have a php variable that queries the database
Another .net newbie question I created a class that inherits System.Web.UI.Page with the intention
another question of mine. I have created a screen that consists of a Spinner
Another design question for you If I have 5 activities that can result from
Another migration question, I have another chunk of VB6 code that seems to need

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.