Copy link to clipboard
Copied
Hi ,
I am trying to create this Slide show and I am getting this Error when I test the Movie
ERROR ////////////////////////////////////////
Error #1009: Cannot access a property or method of a null object reference.
at PortOnlineInduction_2_fla::MainTimeline/frame2()
at flash.display::MovieClip/gotoAndStop()
at PortOnlineInduction_2_fla::MainTimeline/preload()
////////////////////////////////////////////////////
Here is the Code on Frame 2 , whereas Frame 1 only Contains the Preloader for the whole Movie , I am not sure what I am doing wrong here ?
CODE ON FRAME 2 /////////////////////////////////////////////////////////////
stop();
slidecounter.text = String(this.currentFrame - 1 + "/" + indexframe);
mc_prog.width = 0;
/////////////////////////////////////////////////////////////////////////////////
//LIBRARIES TO BE IMPORTED ///////////////////////////////////////////////////////////
import flash.events.MouseEvent;
//VARIALBLES INITIATED
var score:Number = 0;
var questions:Number = 0;
var qtotal:Number = 11;
var attempt:Number = 0;
var indexframe:int;
indexframe = this.totalFrames - 1;
var notes:Array = new Array();
var count:int;
count = 0;
var backcounter:int;
backcounter = 0;
var count2:int;
count2 = 0;
var backcounter2:int;
backcounter2 = 0;
var count3:int;
count3 = 0;
var backcounter3:int;
backcounter3 = 0;
var count4:int;
count4 = 0;
var backcounter4:int;
backcounter4 = 0;
////////////////////////////////// MOVIE CLIPS INITITATED ////////////////////////////////////////////////////////////////
var volbutton1:volcontrol;//VOLUME BUTTON ROLLOVER MOVIE CLIP
volbutton1 = new volcontrol();
var clist:courselist;//VOLUME COURSE LIST ROLLOVER MOVIE CLIP
clist = new courselist();
var pop1:Mc_slide9 = new Mc_slide9;
pop1 = new Mc_slide9;
var pop2:Mc_slide13 = new Mc_slide13;
pop2 = new Mc_slide13;
var pop3:Mc_slide17 = new Mc_slide17;
pop3 = new Mc_slide17;
var pop4:Mc_slide21 = new Mc_slide21;
pop4 = new Mc_slide21;
//BUTTONS INITIATED
btn_nxt.addEventListener(MouseEvent.CLICK, fl_ClickToGoToNextFrame);//NEXT SLIDE BUTTON
btn_bck.addEventListener(MouseEvent.CLICK, backbtn);//BACK BUTTON
btn_loc.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage); //LIST OF COURSES BUTTON
btn_notice1.addEventListener(MouseEvent.CLICK, loadnotice1);
pop1.closebtn.addEventListener(MouseEvent.CLICK, unloadbtn1);
btn_notice2.addEventListener(MouseEvent.CLICK, loadnotice2);
pop2.closebtn.addEventListener(MouseEvent.CLICK, unloadbtn2);
btn_notice3.addEventListener(MouseEvent.CLICK, loadnotice3);
pop3.closebtn.addEventListener(MouseEvent.CLICK, unloadbtn3);
btn_notice4.addEventListener(MouseEvent.CLICK, loadnotice4);
pop4.closebtn.addEventListener(MouseEvent.CLICK, unloadbtn4);
//VOLUME BUTTON ROLL OVER FUNCTION EVENT LISTENERS ///////////////////////////////////////
btn_vol.addEventListener(MouseEvent.ROLL_OVER,vol);
btn_vol.addEventListener(MouseEvent.ROLL_OUT,volout);
btn_loc.addEventListener(MouseEvent.ROLL_OVER,coursel);
btn_loc.addEventListener(MouseEvent.ROLL_OUT,corlist);
// FUNCTIONS INITIATED /////////////////////////////////////////////////////////////////
function fl_ClickToGoToNextFrame(event: MouseEvent): void
{
nextFrame();
}
function backbtn(event:MouseEvent):void{
prevFrame();
}
function fl_ClickToGoToWebPage(event: MouseEvent): void {
navigateToURL(new URLRequest("https://www.onlineinduction.com/fmgl/courselist.php?ist=2&type=Vendor Employee Inductions"), "_self");
}
/////////////////////////////////////////////////////////////////////
//VOLUME BUTTON ROLLOVER EFFECT FUNCTION
function vol(e:MouseEvent):void
{
addChild(volbutton1);
//popup_instance.width = 675;
//popup_instance.height = 300;
if(this.currentFrame == 2)
{
volbutton1.x = 150;
volbutton1.y = 528;
}
else{
volbutton1.x = 278;
volbutton1.y = 528;
}
}
function volout (e:MouseEvent):void {
removeChild(volbutton1);
}
function coursel(e:MouseEvent):void {
addChild(clist);
if(this.currentFrame == 2)
{
clist.x = 85;
clist.y = 532;
}
else if(this.currentFrame == 5){
clist.x = 115;
clist.y = 325;
}
else{
clist.x = 175;
clist.y = 532;
}
}
function corlist (e:MouseEvent):void {
removeChild(clist);
}
////////////////////////////////////////////////////////////////////////////////////
function loadnotice1(Event:MouseEvent):void//FRAME 9 FUNCTION FOR IMPORTANT NOTICE
{
if ( count == 1 && stage.contains(pop1))
{
removeChild(pop1);
}
if(count == 1)
{
nextFrame();
}
else
{
addChild(pop1);
pop1.x = 40;
pop1.y = 120;
count = 1;
}
trace("Counter Value:" + count);
}
function loadnotice2(Event:MouseEvent):void//FRAME 9 FUNCTION FOR IMPORTANT NOTICE
{
if ( count2 == 1 && stage.contains(pop2))
{
removeChild(pop2);
}
if(count == 2)
{
nextFrame();
}
else
{
addChild(pop2);
pop2.x = 40;
pop2.y = 120;
count2 = 1;
}
trace("Counter Value:" + count);
}
//////////////////////////////////////////////////
function loadnotice3(Event:MouseEvent):void//FRAME 9 FUNCTION FOR IMPORTANT NOTICE
{
if ( count3 == 1 && stage.contains(pop3))
{
removeChild(pop3);
}
if(count == 3)
{
nextFrame();
}
else
{
addChild(pop3);
pop3.x = 40;
pop3.y = 120;
count3 = 1;
}
trace("Counter Value:" + count);
}
///////////////////////////////////////////////////////
//////////////////////////////////////////////////
function loadnotice4(Event:MouseEvent):void//FRAME 9 FUNCTION FOR IMPORTANT NOTICE
{
if ( count4 == 1 && stage.contains(pop4))
{
removeChild(pop4);
}
if(count == 3)
{
nextFrame();
}
else
{
addChild(pop4);
pop4.x = 40;
pop4.y = 120;
count4 = 1;
}
trace("Counter Value:" + count);
}
///////////////////////////////////////////////////////
function nextframe9(event: MouseEvent): void
{
if(count == 1 && stage.contains(pop1) )
{
removeChild(pop1);
}
if(count == 1)
{
nextFrame();
}
else
{
addChild(pop1);
pop1.x = 40;
pop1.y = 120;
count = 1;
}
}
///////////////////////////////////////////////////////////////////////////////////////
function nextframe13(event: MouseEvent): void
{
if(count2 == 1 && stage.contains(pop2) )
{
removeChild(pop2);
}
if(count2 == 1)
{
nextFrame();
}
else
{
addChild(pop2);
pop2.x = 40;
pop2.y = 120;
count2 = 1;
}
}
///////////////////////////////////////////////////////
function nextframe17(event: MouseEvent): void
{
if(count3 == 1 && stage.contains(pop3) )
{
removeChild(pop3);
}
if(count3 == 1)
{
nextFrame();
}
else
{
addChild(pop3);
pop3.x = 40;
pop3.y = 120;
count3 = 1;
}
}
//////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////
function nextframe21(event: MouseEvent): void
{
if(count4 == 1 && stage.contains(pop4) )
{
removeChild(pop4);
}
if(count4 == 1)
{
nextFrame();
}
else
{
addChild(pop4);
pop4.x = 40;
pop4.y = 120;
count4 = 1;
}
}
//////////////////////////////////////////////////////////////////////////////////
function backbtnscript1(event:MouseEvent):void
{
if(stage.contains(pop1) )
{
removeChild(pop1);
backcounter = 1;
trace("back" + backcounter);
}
prevFrame();
}
function unloadbtn1 (e:MouseEvent):void {
removeChild(pop1);
}
////////////////////////////////////////////////////////////////////////////////
function backbtnscript2(event:MouseEvent):void
{
if(stage.contains(pop2) )
{
removeChild(pop2);
backcounter2 = 1;
trace("back" + backcounter2);
}
prevFrame();
}
function unloadbtn2 (e:MouseEvent):void {
removeChild(pop2);
}
////////////////////////////////////////////////////////////////////////////////
function backbtnscript3(event:MouseEvent):void
{
if(stage.contains(pop3) )
{
removeChild(pop3);
backcounter3 = 1;
trace("back" + backcounter3);
}
prevFrame();
}
function unloadbtn3 (e:MouseEvent):void {
removeChild(pop3);
}
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
function backbtnscript4(event:MouseEvent):void
{
if(stage.contains(pop4) )
{
removeChild(pop4);
backcounter4 = 1;
trace("back" + backcounter4);
}
prevFrame();
}
function unloadbtn4 (e:MouseEvent):void {
removeChild(pop4);
}
//SLIDE COUNTER
///////////////////////////////////////////////////////////////////////////////////////////////
PRELOADER CODE ///////////////////////////////// FRAME 1
addEventListener (Event.ENTER_FRAME,preload);
function preload(e:Event):void
{
var toload:Number = loaderInfo.bytesTotal;
var loaded:Number = loaderInfo.bytesLoaded;
var total:Number = toload/loaded;
if(loaded == toload)
{
removeEventListener(Event.ENTER_FRAME,preload);
gotoAndStop(2);
}
else
{
preloader.pre_fill.scaleX = total;
preloader.percent.text = Math.floor(total*100);
}
}
What can be going wrong here ?
Copy link to clipboard
Copied
That error is telling you that you are referencing an object before it exists. It appears that something in the function named "preload" is at fault. My first guess is that "loaderInfo" is not properly defined or does not exist when the function is called, but it could be anything.
Copy link to clipboard
Copied
If you go into your Flash Publish Settings and choose the option to Permit Debugging it should help by adding a line number of the offending code just after the frame number.
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 declared but not instantiated
- 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).
Copy link to clipboard
Copied
Thanks a lot Ned for the guidance.I applied the Publish setting and here is what I get :
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at PortOnlineInduction_2_fla::MainTimeline/frame2()[PortOnlineInduction_2_fla.MainTimeline::frame2:72]
at flash.display::MovieClip/gotoAndStop()
at PortOnlineInduction_2_fla::MainTimeline/preload()[PortOnlineInduction_2_fla.MainTimeline::frame1:12]
Now on Frame 12 , I can only see following Code :
gotoAndStop(2);
Here is the Full Code of Frame 1 which is a Preloader :
stop();
addEventListener (Event.ENTER_FRAME,preload);
function preload(e:Event):void
{
var toload:Number = loaderInfo.bytesTotal;
var loaded:Number = loaderInfo.bytesLoaded;
var total:Number = toload/loaded;
if(loaded == toload)
{
removeEventListener(Event.ENTER_FRAME,preload);
gotoAndStop(2);
}
else
{
preloader.pre_fill.scaleX = total;
preloader.percent.text = Math.floor(total*100);
}
}
//////////////////////////////////////////////////////////////////////
Also , I wanted to know if this is just a Warning sign ? I mean will that affect the Running of my Movie online ?
Copy link to clipboard
Copied
A 1009 error is usually a show stopper that will prevent you from compiling the swf.
Error chains are normally reported closest-to-furthest from the error source. The error is going to be found on Frame 2 line 72. Whatever object is being targeted on that line does not exist as far as the compiler is concerned.
Copy link to clipboard
Copied
Perfecto!!!!!! Man you are Great , Thanks a lot for the help , I disabled the buttons on that frame and it all went fine now as those buttons didn't exist there on stage at that frame , thanks a lot.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now