A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Put a bitmap in the middle of the screen

  1. #1
    Junior Member
    Join Date
    Dec 2009
    Posts
    26

    Put a bitmap in the middle of the screen

    Hello

    I am trying to put a bitmap in the middle of the screen - and despite much googling I can not find out how (I am a rubbish googler)

    I have a jpg in the library with the class name bedroomBg

    I have this code:
    var bedroomBgBM:bedroomBg = new bedroomBg(1152, 768);
    var bg:Bitmap = new Bitmap(bedroomBgBM);
    addChildAt(bg,0);

    this is all in a class that has been added to the main movie.

    back in the day I would have done some jiggery pockery with stage.width.
    but here
    "trace(stage.stageWidth)"
    results in
    "TypeError: Error #1009: Cannot access a property or method of a null object reference."

    Any help very much appreciated

    thanks

  2. #2
    Junior Member
    Join Date
    Dec 2009
    Posts
    26
    Hello again,

    I've worked out that it is nothing to do with bitmaps etc. My problem is how to access the properties of the stage in an object that is added using addChild.

    stageW = stage.stageWidth;
    stageH = stage.stageHeight;
    bedroomScene = new BedroomScene(stageW,stageH);
    ta da...

    good lord - I am talking to myself .. I guess I don't really understand the hierarchy.

  3. #3
    Junior Member
    Join Date
    Feb 2008
    Posts
    12
    use Event.ADDED_TO_STAGE so you dont have to pass the stage width and height.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center