PDA

View Full Version : flex to flash and some more...



flesh
June 25th, 2007, 08:00 AM
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:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main$iinit()

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 (A.swf) :

import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.net;
var ldr:Loader = new Loader();
var urlReq:URLRequest = new URLRequest("B.swf");
ldr.load(urlReq);
ldr.contentLoaderInfo.addEventListener(Event.COMPL ETE, loaded);

function loaded(event:Event):void
{
trace("LOADED")
addChild(ldr);

// also tried : addchild(ldr.content)

}


I've verified that the above script loads any other AS 3.0 based swf
But not this one.

Below is the script from B.swf in a simplified form :

// MAIN.AS

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")
}
}
}


Well , that's it. I surely hope that someone can lead me to a solution to this problem.

Dazzer
June 25th, 2007, 08:09 AM
might be easier to just errr.... zip up and attach?

flesh
June 25th, 2007, 09:59 AM
Forget the whole thread

the problem I've got is beeing adressed here:
http://www.kirupa.com/forum/showthread.php?t=266248