Good afternoon fellow flashers!
I’ve got this rather annoying problem that I hope someone can help me with.
I’ve slightly modified a flex script from Andre Michele to run in flash. I just removed some parts from the original flex script related to the flex document information. No biggie. It runs fine. Hurrah!
The problem occurs when I try to load this particular swf (B.swf) into
A.swf. Then, surprisingly the compiler start complaining:
[SIZE=1]TypeError: Error #1009: Cannot access a property or method of a null object reference.[/SIZE]
[SIZE=1]at Main$iinit()[/SIZE]
It has been suggested to me that this error stems from the fact that the object has not been added to the display list. But I believe I have tried to do so after the swf has been loaded, with no luck.
Well heres the timeline script that generates the error ([COLOR=red]A.swf[/COLOR]) :
[SIZE=1]import flash.display.Loader;[/SIZE]
[SIZE=1]import flash.display.Sprite;[/SIZE]
[SIZE=1]import flash.events.Event;[/SIZE]
[SIZE=1]import flash.net;[/SIZE]
[SIZE=1]var ldr:Loader = new Loader();[/SIZE]
[SIZE=1]var urlReq:URLRequest = new URLRequest(“B.swf”);[/SIZE]
[SIZE=1]ldr.load(urlReq);[/SIZE]
[SIZE=1]ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);[/SIZE]
[SIZE=1]function loaded(event:Event):void[/SIZE]
[SIZE=1]{[/SIZE]
[SIZE=1]trace(“LOADED”)[/SIZE]
[SIZE=1]addChild(ldr);[/SIZE]
[SIZE=1]// also tried : addchild(ldr.content)[/SIZE]
[SIZE=1]} [/SIZE]
I’ve verified that the above script loads any other AS 3.0 based swf
But not this one.
Below is the script from [COLOR=red]B.swf[/COLOR] in a simplified form :
[COLOR=red][COLOR=black]// [/COLOR]MAIN.AS[/COLOR]
[SIZE=1] package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.*;
import flash.filters.BlurFilter;
import flash.geom.Matrix;
import flash.geom.Point;
public class Main extends Sprite
{
private var output: BitmapData;
public function Main()
{
output = new BitmapData( 100, 100, true, 0 );
stage.addChild( new Bitmap( output ) );
stage.addEventListener( MouseEvent.MOUSE_DOWN, createExplosion );
stage.addEventListener( Event.ENTER_FRAME, render );
}
private function createExplosion( event: Event ): void
{
trace(“createExplosion”) ;
}
private function render( event: Event ): void
{
trace(“render”)
}
}
}
[/SIZE]
Well , that’s it. I surely hope that someone can lead me to a solution to this problem.