Freeman
19.09.2015, 02:20
Часто сталкивался с подобной ошибкой, но каким-то образом не запариваясь решал, писал по другому немного. Вот скажите, пожалуйста, как мне действовать таким образом, вызывать настройку окна из майна, через класс. Было бы удобно, но говорит stage не существует. В самом Main, срабатывает любой вызов stage, что мне сделать для подобного подхода?
package
{
import flash.display.Sprite;
import system.Window;
public class Main extends Sprite
{
public function Main()
{
Window.init();
}
}
}
package system
{
import flash.display.Sprite;
public class Window extends Sprite
{
private static var window:Window;
public function Window()
{
}
public function init():void
{
stage.addChild(window);
}
public static function init():void
{
window = new Window();
window.init();
//window.stage.stageWidth = 2000;
}
}
}
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at system::Window/init()[D:\Projects\Programming\AS3 и Flash\Тренировки\FlashED\src\system\Window.as:17]
at system::Window$/init()[D:\Projects\Programming\AS3 и Flash\Тренировки\FlashED\src\system\Window.as:23]
at Main()[D:\Projects\Programming\AS3 и Flash\Тренировки\FlashED\src\Main.as:13]
at runtime::ContentPlayer/loadInitialContent()
at runtime::ContentPlayer/playRawContent()
at runtime::ContentPlayer/playContent()
at runtime::AppRunner/run()
at ADLAppEntry/run()
at global/runtime::ADLEntry()
package
{
import flash.display.Sprite;
import system.Window;
public class Main extends Sprite
{
public function Main()
{
Window.init();
}
}
}
package system
{
import flash.display.Sprite;
public class Window extends Sprite
{
private static var window:Window;
public function Window()
{
}
public function init():void
{
stage.addChild(window);
}
public static function init():void
{
window = new Window();
window.init();
//window.stage.stageWidth = 2000;
}
}
}
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at system::Window/init()[D:\Projects\Programming\AS3 и Flash\Тренировки\FlashED\src\system\Window.as:17]
at system::Window$/init()[D:\Projects\Programming\AS3 и Flash\Тренировки\FlashED\src\system\Window.as:23]
at Main()[D:\Projects\Programming\AS3 и Flash\Тренировки\FlashED\src\Main.as:13]
at runtime::ContentPlayer/loadInitialContent()
at runtime::ContentPlayer/playRawContent()
at runtime::ContentPlayer/playContent()
at runtime::AppRunner/run()
at ADLAppEntry/run()
at global/runtime::ADLEntry()