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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:52:26+00:00 2026-06-13T03:52:26+00:00

running this code var sp:Sprite = new Sprite(); sp.graphics.beginFill(0xff); sp.graphics.drawRect(0,0,400,400); sp.graphics.endFill(); sp.scrollRect = new

  • 0

running this code

        var sp:Sprite = new Sprite();
        sp.graphics.beginFill(0xff);
        sp.graphics.drawRect(0,0,400,400);
        sp.graphics.endFill();
        sp.scrollRect = new Rectangle(0,0,350,350);
        addChild(sp);

        var count:int = 0;
        var f:Function = function(...args):void{
            trace(count++,sp.width,sp.height);
            if(count>5){
                removeEventListener(Event.ENTER_FRAME,f);
            }
        }
        addEventListener(Event.ENTER_FRAME,f);

get

0 400 400
1 350 350
2 350 350
3 350 350
4 350 350
5 350 350

is there anyway i can made the scrollRect work at the first frame?

  • 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-13T03:52:27+00:00Added an answer on June 13, 2026 at 3:52 am

    I just checked, and its probably because of some internal rendering stuff in Flash Player (it actually takes two frames to get the real dimensions, the current one, and the one after). Visually the rectangle doesn’t change sizes, so it’s only the values of the object’s bounds that are updated two frames later (you can easily prove this by setting a very low framerate, like 1 FPS).

    One workaround is to force a “hard” rendering pass by drawing the stage to a 1×1 BitmapData… this will effectively update the entire display list, and those values should be correct immediately after the draw() call. So your code would look like this:

    var sp:Sprite = new Sprite();
    sp.graphics.beginFill(0xff);
    sp.graphics.drawRect(0,0,400,400);
    sp.graphics.endFill();
    sp.scrollRect = new Rectangle(0,0,350,350);
    addChild(sp);
    
    var count:int = 0;
    function f(event:Event = null):void{
        new BitmapData(1,1).draw(stage);
        trace(count++,sp.width,sp.height);
        if(count>5){
            removeEventListener(Event.ENTER_FRAME,f);
        }
    }
    addEventListener(Event.ENTER_FRAME,f);
    f();
    

    (Note that I changed the way you declared the function, as this is the preferred way among most (if not all) Flash developers.)

    You could do the draw call only once after adding the object to the stage, but I don’t know how safe it would be if the object changes.

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

Sidebar

Related Questions

After running this code: var input = new List<T>( ... ); var result =
Today i saw this code, that was running in node.js environment. (>node.exe test.js) var
I have this code: using ( var site = new SPSite( myUrl ) )
running this code: public bool CheckTime(DateTime date, int UserID, int TotalTimeMin) { using (var
I have this simple code: public void Run() { var invokerThread = new Thread(new
I am running this code snippet in LINQPad. DateTime dt = new DateTime(2011, 2,
Try running this code: var oObject = {COL_SEQ:16,SERVICE_CD:0.000000,SERVICE_ID:0.000000,COL_NAME:,COL_OPTION:nosort nofilter,COL_CLASS:REMOVE_PATIENT,COL_TYPE:,COL_LABEL:,COL_OPTION:}; alert(oObject.COL_SEQ); alert(oObject.COL_OPTION); alert(oObject.COL_CLASS); I would
I am running this code: #include <iostream> #include <cstddef> int main(int argc, char *argv[]){
I am running this code and it is using a fair amount of CPU
While I am running this code it showing me a following error:- Column 'virtuemart_product_id'

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.