FORUMS: list search recent posts

Help with Error #1009?

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Clint Milner
Help with Error #1009?
on Apr 21, 2009 at 1:16:58 pm

I've done a simple tutorial from gotoandlearn.com about preloading with AS3. http://www.gotoandlearn.com/play?id=85

It has you create a preloader.swf in the same directory as your main swf.

I'm getting this in my output window:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at gallery_fla::MainTimeline/frame1()


Code for preloader.fla

var myLoader:Loader = new Loader();
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, done);

myLoader.load(new URLRequest("gallery.swf"));//My main SWF

//Preloader Code (dynamic text field percent_txt)
function loop(e:ProgressEvent):void
{
var perc:Number = e.bytesLoaded / e.bytesTotal;
percent_txt.text = Math.ceil(perc*100).toString();
}

function done(e:Event):void
{
removeChildAt(0);
percent_txt = null;
addChild(myLoader);
}


The only thing in my gallery.fla that may be causing problems is a UILoader, but it's just loading pictures.

If anyone could help I'd be greatful and if you need me to post some more code or the fla's I can do that as well.

Kind Regards,
Clint

Adobe CS4 Master Suite
Vista Ultimate 64 SP1
Intel Core i7 920 @ 3.60GHz
12 GB DDR3 RAM
NVidia Quadro FX 3700
Matrox RT.X2 LE Capture Card
4 TB RAID 5


Return to posts index

Pieter Helsen
Re: Help with Error #1009?
on Apr 21, 2009 at 1:19:53 pm

Comment out:
percent_txt.text = Math.ceil(perc*100).toString();
If that solves the problem, you didn't give percent_txt the correct instance name, or it just isn't on the first frame.

Kind regards,
Pieter

General notice: from now on, I would like to ask everyone to put [AS2] or [AS3] (corresponding to the version of actionscript you are using on your project) in front of their post titles when the question is actionscript related! Please help us help you faster. Thank you.


Return to posts index

Clint Milner
Re: Help with Error #1009?
on Apr 21, 2009 at 1:36:08 pm

Hi Pieter,

That unfortunately didn't help. Everything on both fla's is in the first frame.

http://www.alpha-duplication.com/JMWebsite/flash.zip

If you could have a look that'd be a huge help.

Many thanks,
Clint

Adobe CS4 Master Suite
Vista Ultimate 64 SP1
Intel Core i7 920 @ 3.60GHz
12 GB DDR3 RAM
NVidia Quadro FX 3700
Matrox RT.X2 LE Capture Card
4 TB RAID 5


Return to posts index


Pieter Helsen
Re: Help with Error #1009?
on Apr 21, 2009 at 7:35:52 pm

I don't have my own webserver anymore, so I can't upload the changes I made... However, this should do the trick:

All changes are made in the gallery.fla file.

- On the bottom layer (where you have your text) create a simple black square the size of your fla (376x420), then, transform it into a movieclip. This is done so you do not need to attach an event listener to the stage but simply to the movie (see step 2)

- Remove all references to stage. The stage doesn't exist in the gallery movie when you load it into another movieclip. This is what your code should look like:


var sWidth:Number = 378;
var sHeight:Number = 420;

//--- START ---------moving thumbnails code
this.addEventListener(MouseEvent.MOUSE_MOVE, slide);
var travel:Number = (theStrip_mc.width - sWidth) / sWidth;

There's a few more references to stage.stageWidth that you should replace with sWidth.

That should do the trick.

Kind regards,
Pieter

General notice: from now on, I would like to ask everyone to put [AS2] or [AS3] (corresponding to the version of actionscript you are using on your project) in front of their post titles when the question is actionscript related! Please help us help you faster. Thank you.


Return to posts index

Clint Milner
Re: Help with Error #1009?
on Apr 22, 2009 at 9:42:20 am

Hi Pieter,

That did it, you are good, thank you very much. I didn't realise that I'll lose my stage reference when being loaded into another swf, but I guess looking back at it, it does make sense.

I think I'll start making an invisible MC the base of all my swfs now because this method of preloading is fairly simple and I know I use stage.stageWidth and stage.stageHeight + others quite a bit.


Thanks again,
Clint


Adobe CS4 Master Suite
Vista Ultimate 64 SP1
Intel Core i7 920 @ 3.60GHz
12 GB DDR3 RAM
NVidia Quadro FX 3700
Matrox RT.X2 LE Capture Card
4 TB RAID 5


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]