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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:43:13+00:00 2026-06-07T01:43:13+00:00

I made a test by adding a MovieClip to a Canvas in Flex. private

  • 0

I made a test by adding a MovieClip to a Canvas in Flex.

private function onInit():void {
    var mc:MovieClip = new MovieClip();
    mc.graphics.clear();
    mc.graphics.lineStyle(2, 0, 1);
    mc.graphics.beginFill(0xFF0000, 0.5);
    mc.graphics.drawRect(0, 0, 400, 300);
    mc.graphics.endFill();
    mainCanvas.rawChildren.addChild(mc);
}

private function onMouseMove():void {
    var child:DisplayObject = mainCanvas.rawChildren.getChildAt(i);
    trace("MovieClip size:", (child as MovieClip).width, (child as MovieClip).height);
}

mainCanvas is declared and instanciated in MXML:

<Canvas id="mainCanvas" width="400" height="300" />

This first attempt works fine and the console displays the following output when I move the mouse over the stage:

MovieClip size: 402 302

But when I want to explicitly set the size of the movie clip I don’t see in anymore and the ouptut display a wrong size.

Here is the update init method:

private function onInit():void {
    var mc:MovieClip = new MovieClip();
    mc.width = 400;
    mc.height = 300;
    mc.graphics.clear();
    mc.graphics.lineStyle(2, 0, 1);
    mc.graphics.beginFill(0xFF0000, 0.5);
    mc.graphics.drawRect(0, 0, 400, 300);
    mc.graphics.endFill();
    mainCanvas.rawChildren.addChild(mc);
}

And the corresponding output:

MovieClip size: 0 0

Does someone have any explanation for this strange behavior?

  • 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-07T01:43:15+00:00Added an answer on June 7, 2026 at 1:43 am

    Initially, you set the size of a empty MovieClip:

    var mc:MovieClip = new MovieClip();
    mc.width = 400;
    mc.height = 300;
    

    You are attempting to size a clip with no content.

    Set you size after there is content in the clip:

    var mc:MovieClip = new MovieClip();
    mc.graphics.lineStyle(2, 0, 1);
    mc.graphics.beginFill(0xFF0000, 0.5);
    mc.graphics.drawRect(0, 0, 400, 300);
    mc.graphics.endFill();
    
    mc.width = 400;
    mc.height = 300;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using java and made a small test server to log incoming user connections. Adding
I'm working with a class for which the new operator has been made private,
I'm putting together a simple test made up of two tutorials available online for
I have a problem, and I made this test code to show you my
I made a stress test on Google App Engine and now: Logs Stored Data
I have made a simple test application for the issue, two winforms each containing
I've made a simple test with a MemoryMappedFile as msdn says : 2 processes,
I have Ripple which im using to test app made for android. App is
I made quite a few easy OSGi test projects in Eclipse RCP. My typical
I made a 64-bit WPF test app. With my app running and with Task

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.