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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:23:40+00:00 2026-06-15T11:23:40+00:00

consider the code below: package { import flash.display.Sprite; import flash.display.BitmapData; import flash.display.Bitmap; import flash.events.Event;

  • 0

consider the code below:

                package 
                {

                import flash.display.Sprite;
                import flash.display.BitmapData;
                import flash.display.Bitmap;
                import flash.events.Event; 

                public class SampleBitmap extends Sprite
                {
                public function SampleBitmap() {
                //生成两个BitmapData对象dataA, dataB
                //dataA是100×100的深绿色矩形
                var dataA:BitmapData = new BitmapData(100,100,true, 0xff669900);
                //dataB是100×100的橙黄色矩形
                var dataB:BitmapData = new BitmapData(100,100,true, 0xffFF9900);
                //分别生成三个位图显示对象
                var bitmapA:Bitmap = new Bitmap(dataA); 
                var bitmapB:Bitmap = new Bitmap(dataB);
                var bitmapC:Bitmap = new Bitmap(dataB.clone()); //将dataB复制了一份
                bitmapA.bitmapData = dataB; 
                //bitmapA:将dataB替换了dataA,此时bitmapA和bitmapB持有的都是dataB
                bitmapB.x = 200;
                bitmapC.x = 400;
                bitmapA.x = 500;
                bitmapA.y = 500;
                //加入显示列表 
                addChild(bitmapA); 
                addChild(bitmapB); 
                addChild(bitmapC); 

                trace(stage.width);
                //改变dataB的像素信息,把它中心20×20的像素都改成了红色 
                for (var i:int = 40; i<60; i++) {
                for (var j:int = 40; j<60; j++) {
                dataB.setPixel(i,j,0xFF0000);
                }
                } 
                trace(this.width);  //the output is 600
                trace(this.height);//the output is 600
                this.graphics.beginFill(0x00ff00);
                this.graphics.drawRect(0,0,this.width,this.height); //trace了一下,this.width,this.height都为600px
                this.graphics.endFill();
                }
                }
                }

the result is:
enter image description here

and: my question is: why the green don’t cover all the three yellow rect??

  • 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-15T11:23:40+00:00Added an answer on June 15, 2026 at 11:23 am

    Problem lies in this line :

    this.graphics.drawRect(0,0,this.width,this.height)
    

    Here, this actually refers to the container (instance of SampleBitmap Class) whose width is determined by the three boxes you added into it.

    What you were perhaps looking for (assuming you wished cover full stage) was :

    this.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight)
    

    enter image description here


    EDIT

    Just compiled your code and your claim :

                trace(this.width);  //the output is 600
                trace(this.height); //the output is 600
    

    is false as the output is 400 & 600

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

Sidebar

Related Questions

Consider code sniper below: package sync; public class LockQuestion { private String mutable; public
Consider the code below. package require Itcl ::itcl::class A \ { private { constructor
Consider the Go code below.. package main import go/token import python/token func main() {
Consider the code below: #!/usr/bin/env python from PyQt4 import QtCore, QtGui import os,sys class
Consider the code below: public class Analyzer { protected Func f,fd; public delegate double
Consider the code below: <?php class Base { protected $name = Base; public function
Consider the sample code below: #include <iostream> using namespace std; class core { public:
Consider the code below. I do not want to create multiple instances of class
Consider the code below (which has been simplified). I have a service class that
Consider the code below class Pin { string Name; //can be either Numerical or

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.