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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:25:55+00:00 2026-05-13T13:25:55+00:00

EDIT: I just needed to add: import mx.controls.Image; I have an MXML file, and

  • 0

EDIT: I just needed to add: import mx.controls.Image;

I have an MXML file, and when I can add image tags to the XML and it works.

But, I can’t figure out how to create an image and add it to the canvas programatically with AS.

I was hoping this would have worked:

var card:Image = new Image(); //ERRORS ON THIS LINE: call to possibly undefined method Image.
card.width = cardHeight;
card.height = cardWidth;
card.x = xCoord;
card.y = yCoord;          

Thanks for your help!

  • 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-13T13:25:55+00:00Added an answer on May 13, 2026 at 1:25 pm

    You need to call the addChild function on the MXML component you wish to add the Image to. For example:

    MXML:

    <mx:Canvas id="mxmlComponent" />
    

    ActionScript:

    private function some_function() : void 
    {
       var card:Image = new Image();
       card.width = cardHeight;
       card.height = cardWidth;
       card.x = xCoord;
       card.y = yCoord;  
    
       mxmlComponent.addChild(card);
    }
    

    This is a nice example on how to use the addChild function.

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

Sidebar

Related Questions

Whenever I have needed to create a class file from an XML XSD schema,
** EDIT ** Nevermind, just needed to take out the parens... I get this
Edit: just to be clearer on what I am looking to do. I have
I wanted to edit just the first line of a 4 MB file. When
I have to edit my question just to make it clear. What I need
I had a file I needed to edit in my .gitignore file. I edited
I have a WCF Service that works just fine in the VS development server,
I just downloaded Eclipse several hours ago, and needed to add Java3D to the
The title says everything, but just to be clear I'll add some extra words.
I have a document with a dynamic UI--users can add rows to an existing

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.