I am using FlashDevelop 3 for my project, and I am trying to load an swf (created in Flash CS3 and with timeline code). What does it mean?
[Fault] exception, information=TypeError: Error #1009: Cannot access a property or method of a null object reference.
Execution halted in 'spontaneousBox.swf' ffffffffat 0xExecution halted in 'spontaneousBox.swf' ffffffff (-1)
PS: i can load images fine, and other swfs built with FlashDevelop.
EDIT: it seems that i only get the error the first time I load the swf, after trying to load again, it loads ok.
You’re probably trying to access the stage before the loader has been added to the display swf. It’s impossible to tell without seeing your code.
ah yes, in my loaded swf i set stage.scale and stage.align… i should remove those?
and while on the topic of stages and loading swfs, is there an easy way to set a loaded swf’s size through a Loader or something.
say I load an swf, and I resize a box containing the swf, how do i make the swf resize too?
You don’t need to remove them, you just need to wait to run that code until the loader object has been added to the display list - otherwise it doesn’t have access to the stage yet.
Take all of the code out of your constructor, and put it into a function called init():
private function init():void
{
// all of the code that is currently in your constructor
}
… and then in your constructor, add the following line:
public function MyClass()
{
addEventListener(Event.ADDED_TO_STAGE, init);
}
This should fix your issue - it makes sure that you actually have access to the stage before trying to access its properties. :thumb:
As far as the loader size, the swf contents will not be sized away from their defaults as you’ve defined them, but you’re totally able to resize them as you like. The swf will not be masked or rescaled in any way when you load it into a parent swf.