-
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
-
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.
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|