Copy link to clipboard
Copied
Hello, everyone I've got problem with this code.
I need stage size in const or variable because of some resize reasons.
ok so, code below works but it's static and I need dynamicaly get stage size.
private const LIST_HEIGHT :uint = 800;
private const LIST_WIDTH :uint = 1200;
with(_mask)
{
graphics.beginFill(0);
graphics.drawrect(0, 0, LIST_WIDTH, LIST_HEIGHT);
graphics.endFill();
}
and if I change constants to this:
private const LIST_HEIGHT :uint = stage.stageHeight;
private const LIST_WIDTH :uint = stage.stageWidth;
it's not work
also this not work
private var _listH :uint = stage.stageHeight;
private var _listW :uint = stage.stageWidth;
and this:
private var _listH :String = stage.stageHeight;
private var _listW :String = stage.stageWidth;
not work means that I get this error
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.filebrowser::FilesList()[/Users/Peter/Desktop/projectfl/projectfl beta 0.6/as3/com/filebrowser/FilesList.as:14]
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at com.filebrowser::FileBrowser()[/Users/Peter/Desktop/projectfl/projectfl beta 0.6/as3/com/filebrowser/FileBrowser.as:51]
Thanks in advance for all replies, all help is very appreciated.
Copy link to clipboard
Copied
Line 14 of your FileList.as file is where the error occurs. What is that line?
Copy link to clipboard
Copied
hi, it's line with this variable
private var _listH :String = stage.stageHeight;
Copy link to clipboard
Copied
Try tracing the stage just before that line and see if it is coming up null.
If it is, then you need to hold off executing the code until after things have settled following setup. You can use an ADDED_TO_STAGE listener to call a function that executes the code that needs to wait for the stage to exist.
Copy link to clipboard
Copied
ps. I should add this information.
this is code for external swf.
if it's alone it works but if I load it to main swf it's not working.
and my only problem is this:
this is working
private const STAGE_HEIGHT:uint = 800;
and this not
private const STAGE_HEIGHT:uint = stage.stageHeight;
Find more inspiration, events, and resources on the new Adobe Community
Explore Now