Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Preloader stops buttons from working?!

New Here ,
Jun 07, 2011 Jun 07, 2011

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

TOPICS
ActionScript
2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Jun 07, 2011 Jun 07, 2011

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?

Translate
Guest
Jun 07, 2011 Jun 07, 2011

Are you sure you have an MC named: preloaderMC ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 07, 2011 Jun 07, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jun 07, 2011 Jun 07, 2011

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 07, 2011 Jun 07, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 07, 2011 Jun 07, 2011

can you upload your fla?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 07, 2011 Jun 07, 2011

Upload it to where?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 07, 2011 Jun 07, 2011

rapidshare for example...

or other upload sites...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 07, 2011 Jun 07, 2011

https://rapidshare.com/files/1725748419/doret3.fla

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 07, 2011 Jun 07, 2011

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();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 07, 2011 Jun 07, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 07, 2011 Jun 07, 2011

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?

@Hakan KIRIK

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()

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 07, 2011 Jun 07, 2011

Read the last paragraph of my previous posting,  Based on the error message you just showed you did not follow what I offered.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 07, 2011 Jun 07, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 07, 2011 Jun 07, 2011

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 07, 2011 Jun 07, 2011

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!?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 07, 2011 Jun 07, 2011

Sorry for wasting everyone's time with this - I feel like a dumbass!

Am upgrading to CS5 pronto.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jun 07, 2011 Jun 07, 2011
LATEST

Your attached file is working fine!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines