Copy link to clipboard
Copied
Hi,
I made a flash file with buttons that go here and there and everything was fine
except it takes a while to load so i added a preloader and suddenly the compiler
is throwing the following error:
Error #1009: Cannot access a property or method of a null object reference.
... and the buttons have ceased to function.
Here is my code:
preloader:
import flash.events.ProgressEvent;
function update(e:ProgressEvent):void
{
var percent:Number = Math.floor( (e.bytesLoaded*100)/e.bytesTotal );
if(preloaderMC is MovieClip){
preloaderMC.gotoAndStop(percent);
}
if(percent == 100){
play();
}
}
loaderInfo.addEventListener(ProgressEvent.PROGRESS, update);
// Extra test for IE
var percent:Number = Math.floor( (this.loaderInfo.bytesLoaded*100)/this.loaderInfo.bytesTotal );
if(percent == 100){
nextFrame();
}
stop();
scene 1:
stop();
import flash.events.MouseEvent;
//---Hair Button---\\
hair_btn.addEventListener(MouseEvent.CLICK, hairClick);
function hairClick(event:MouseEvent):void{
gotoAndStop("4");
}
//---Home Button---\\
home_btn.addEventListener(MouseEvent.CLICK, homeClick);
function homeClick(event:MouseEvent):void{
gotoAndStop("1");
}
//---Contact Button---\\
weddings_btn.addEventListener(MouseEvent.CLICK, weddingsClick);
function weddingsClick(event:MouseEvent):void{
gotoAndStop("3");
}
//---Products Button---\\
products_btn.addEventListener(MouseEvent.CLICK, productsClick);
function productsClick(event:MouseEvent):void{
gotoAndStop("2");
}
//---Gallery Button---\\
gallery_btn.addEventListener(MouseEvent.CLICK, galleryClick);
function galleryClick(event:MouseEvent):void{
gotoAndStop("5");
}
//---Contact Button---\\
contact_btn.addEventListener(MouseEvent.CLICK, contactClick);
function contactClick(event:MouseEvent):void{
gotoAndStop("6");
}
Please help me sort this out!
Thanks
There is no error with the fla and the code you uploaded to rapidshare.
I don't get any errors... Maybe your Flash isn't working right.
Are you sure you have uploaded the right fla file you are working on?
Copy link to clipboard
Copied
Are you sure you have an MC named: preloaderMC ?
Copy link to clipboard
Copied
Yes I do have an MC called preloaderMC, and the preloader part works fine,
its just the error comes up and the buttons in the next scene dont work.
Copy link to clipboard
Copied
Check whether you have extend the buttons for the next frame and check all the instance names that you have used on the stage
hair_btn
home_btn
weddings_btn
products_btn
gallery_btn
contact_btn
Copy link to clipboard
Copied
yup I have all those buttons and their instance names.
When I remove the preloader, the buttons work with no
error coming up. I've even tried renaming the destination
frames to words but that didn't help.
Copy link to clipboard
Copied
can you upload your fla?
Copy link to clipboard
Copied
Upload it to where?
Copy link to clipboard
Copied
rapidshare for example...
or other upload sites...
Copy link to clipboard
Copied
https://rapidshare.com/files/1725748419/doret3.fla
Copy link to clipboard
Copied
I don't get any errors.
All buttons work fine.
Just you should change loader script to:
import flash.events.ProgressEvent;
function update(e:ProgressEvent):void
{
var percent:Number = Math.floor( (e.bytesLoaded*100)/e.bytesTotal );
gotoAndStop(percent);
if (percent == 100)
{
gotoAndStop(1,"Scene 1");
}
}
loaderInfo.addEventListener(ProgressEvent.PROGRESS, update);
stop();
Copy link to clipboard
Copied
If you are getting a 1009 error, the file will not work, so the buttons might not be the problem.
The 1009 error indicates that one of the objects being targeted by your code is out of scope. This could mean that the object....
- is not in the display list
- doesn't have an instance name (or the instance name is mispelled)
- does not exist in the frame where that code is trying to talk to it
- is animated into place but is not assigned instance names in every keyframe for it
- is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).
If you go into your Publish Settings Flash section and select the option to Permit debugging, your error message should have a line number following the frame number which will help you isolate which object is involved.
Copy link to clipboard
Copied
ok,
I just did a test movie where I simply added the preload scene without anything in it. no code, movie clips etc.
and it comes up with the error. So I went back to the file with the coded preloader and tested each scene,
no errors! but when I test movie... the error is back.
so im guessing its how the two scenes are connected or interact with each other?
how do I check what is in the diplay list?
I tried your code but it came up with the same error x3
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at doret3_fla::MainTimeline/frame101()
at flash.display::MovieClip/gotoAndStop()
at doret3_fla::MainTimeline/update()
Copy link to clipboard
Copied
Read the last paragraph of my previous posting, Based on the error message you just showed you did not follow what I offered.
Copy link to clipboard
Copied
I did the debugging option and it added 6 after the frame, so i went and removed the paragraph of code that used line 6 as well as the button refered to and the next try just came up with the same error but now on line 7 which was the next button's first line.
I tried going to the properties of each button and checking the export for actionscript box for each button but that just resulted in the same error but with the following added:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::SimpleButton@24e0a821 to hairdrier.
Copy link to clipboard
Copied
There is no error with the fla and the code you uploaded to rapidshare.
I don't get any errors... Maybe your Flash isn't working right.
Are you sure you have uploaded the right fla file you are working on?
Copy link to clipboard
Copied
Woah man ur right when i publish it and open it with my browser it works no problem.
Thats weird! Then why is it bugging in flash (cs4) i wonder!?
Copy link to clipboard
Copied
Sorry for wasting everyone's time with this - I feel like a dumbass!
Am upgrading to CS5 pronto.
Copy link to clipboard
Copied
Your attached file is working fine!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more