FORUMS: list search recent posts

gotoAndStop Error

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Aisha Nelson
gotoAndStop Error
on Nov 30, 2009 at 3:35:53 pm

I have created a page navigation for users using labels. When I test the swf, I get the

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at usptatv_11_25_fla::MainTimeline/frame10()
at flash.display::MovieClip/gotoAndStop()
at usptatv_11_25_fla::MainTimeline/usptaNav()

Seeing this message I'm thinking that it has something to do with the "gotoAndStop". I'm just not sure what it should be instead. Can anyone help please? Here is the code below:

////////////////////////// PAGE NAVIGATION /////////////////////////

stop();
function usptaNav(event:MouseEvent):void {
gotoAndStop(event.target.name);//This will go to and stop at the target page desired.

}

videos.addEventListener(MouseEvent.CLICK,usptaNav);
news.addEventListener(MouseEvent.CLICK,usptaNav);
websites.addEventListener(MouseEvent.CLICK,usptaNav);
about.addEventListener(MouseEvent.CLICK,usptaNav);
members.addEventListener(MouseEvent.CLICK,usptaNav);


Return to posts index

Marcus Geduld
Re: gotoAndStop Error
on Nov 30, 2009 at 7:47:05 pm

gotoAndStop() goes to a specific frame and stops there. For instance, if you write gotoAndStop( 15 ), it will go to frame 15 and stop there. If frame 15 has a label, e.g. "end", you can use that as an alias: gotoAndStop( "end" );

But you're trying this gotoAndStop( event.target.name );

What's event.target? It's the item the user clicked on. So it's one of your buttons, e.g. websites. That button is not a frame, so you can't goto it and stop there.

Or have you given frames the same names as the buttons? (Which isn't a great idea, because you could get a name conflict)

Author "After Effects Expressions"
Co-author "After Effects For Flash, Flash For After Effects"
Artistic Director, Folding Chair Classical Theatre, Inc
Senior Flash Developer, Zeitbyte.com


Return to posts index

Aisha Nelson
Re: gotoAndStop Error
on Nov 30, 2009 at 10:17:23 pm

I gave the frames the same name as the button... (Guessing that was a bad idea)

(event.target.name) is supposed to go to the item (page) the user clicks on.


Return to posts index



Marcus Geduld
Re: gotoAndStop Error
on Dec 1, 2009 at 12:36:48 am

Your code looks good to me, so it's there's probably something else going on -- maybe an error in the way you set up the file. The problem isn't a name conflict. I just don't think it's the best idea, in general, to give two things the same name.

In any case, I made a little file for you that works. You can check it against your own file. Mine is here: http://www.grumblebee.com/stuff/cow/navToFrames.fla

Here's how I made my file:

1. I put three buttons on the stage in frame one (actually, I used movieclips, but buttons would have worked, too). I gave the buttons instance names red, green and blue.

DID YOU REMEMBER TO GIVE YOUR BUTTONS INSTANCE NAMES? To give something an instance name, select it and type its name in the Properties Panel.

2. I right-clicked on the fourth frame and chose Insert Frame from the menu. This extended the lifespan of the buttons, so that they lasted for four frames. In my example, I want to have three "pages." My first frame is home. The three pages are on frames two, three and four.

3. I made another layer for the "pages." I added keyframes on that layer in frames two, three and four and put something different on each "page," just so you can tell that the navigation is working.

4. I added another layer for frame labels. Technically, labels don't need their own layer, but I think it's more organized to give them one.
I added keyframes in frames two, three and four, and, clicking in each frame and then typing in the Properties Panel, I gave the frames labels of red, green and blue.

5. I added a final layer for actionscript and entered this in frame one:

stop();

//this line makes the hand-cursor show up when you hover
//over the movieclips red, green and blue. If you use
//buttons, you don't need it.
red.buttonMode = green.buttonMode = blue.buttonMode = true;

red.addEventListener( MouseEvent.CLICK, buttonClickHandler );
green.addEventListener( MouseEvent.CLICK, buttonClickHandler );
blue.addEventListener( MouseEvent.CLICK, buttonClickHandler );

function buttonClickHandler( event : MouseEvent ) : void
{
var frameName : String = event.currentTarget.name;
gotoAndStop( frameName );
}

Author "After Effects Expressions"
Co-author "After Effects For Flash, Flash For After Effects"
Artistic Director, Folding Chair Classical Theatre, Inc
Senior Flash Developer, Zeitbyte.com


Return to posts index

Aisha Nelson
Re: gotoAndStop Error
on Dec 1, 2009 at 3:31:20 pm

I just tried your code and I am still getting the same error message. I have no clue to what could be wrong. I keep getting the error at
function buttonClickHandler( event : MouseEvent ) : void
{
var frameName : String = event.currentTarget.name;
gotoAndStop( frameName );
}


TypeError: Error #1009: Cannot access a property or method of a null object reference.
at usptatv_11_30_fla::MainTimeline/frame21()
at flash.display::MovieClip/gotoAndStop()
at usptatv_11_30_fla::MainTimeline/buttonClickHandler()


Return to posts index


Aisha Nelson
Re: gotoAndStop Error
on Dec 1, 2009 at 3:39:17 pm

Ok, it may have something to do with the rest of my code. I tried deleting all of the code except for that one and it works fine with no error.... I guess now is finding the problem in the code. Can you take a look at it?
///////////////VIDEO PLAYLIST CODE//////////////
//////////////////////////////////// IMPORTING CLASSES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
import fl.video.*;
import flash.events.*


//////////////////////////////////// DECLARING VARIABLES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
var vidPlayer:FLVPlayback = new FLVPlayback();
vidPlayer.setSize(557, 316);
vidPlayer.x=224;
vidPlayer.y=215;
vidPlayer.skin="SkinOverPlayStopSeekFullVol.swf";
vidPlayer.skinAutoHide=true;
vidPlayer.skinBackgroundColor = 0x929292;
vidPlayer.source ="Video Page startup video 1.mp4";
addChild(vidPlayer);



// Arrays for movie locations
var videoList1:Array=["TRC Commercial.mp4","OC54-04-Emilio Sanchez-Hand fed-Back and forth drill variations.flv"];
var videoList2:Array=["CRC Commercial.mp4","Tip 45 - Brett Hobden - Play like a Swimming Duck.flv","TRC Tag.mp4"];
var videoList3:Array=["USPTA Tech Video final for cd_2.flv"];
var videoList4:Array=["2009_DVD General Commercial_SD_REVISED_with fades.flv","23_PD_Groppel_Social Environment.flv"];
var videoList5:Array=["Forums Commercial.mp4","s44_Bonus lesson_Rick Macci_The Four Finishes.flv","TRC Tag.mp4"];
var videoList6:Array=["USPTA Vault.mp4","02 - WCT 1974.flv","Get Courtside Commercial.mp4"];
var videoList7:Array=["Why I teach Comm. round 1.mp4"];
var videoList8:Array=["s43_Bonus interview_Brett Hobden_the arc ball.flv","TRC Commercial.mp4"];
var videoList9:Array=["UTTS Commercial.mp4","s33_Bonus tip_Stan Oley_Ball machine Tip.flv","TRC Tag.mp4"];
var videoList10:Array=["Tip 63 - Shirley Mendoza - 5 Minute Warm-up.flv","TRC Tag.mp4"];
var videoList11:Array=["Ep56 Trailer.mp4"];//Change videos
var videoList12:Array=["CRC Commercial.mp4","22_drill_edited_porter_permanent points.flv"];
var videoList13:Array=["USPTA Vault.mp4","05 Jack in the Safari.flv"];//change videos
var videoList14:Array=["USPTA_TV Intro.mp4","NEW_LOGO_Updated USPTA documentary.flv"];//change videos
var videoList15:Array=["Ep56 Trailer.mp4","OC55-01-Townsend Gilbert-Little Tennis.mp4", "TRC Commercial.mp4"];//change videos
// all the way to videoList15

// Number variable to keep track of the currently playing video in the Array
var videoIndex:Number=0;

// Array variable to keep track to the current array
var currentList:Array;

//////////////////////////////////// BUTTONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
vid1_btn.addEventListener(MouseEvent.CLICK, videoGroup1);
vid2_btn.addEventListener(MouseEvent.CLICK, videoGroup2);
vid3_btn.addEventListener(MouseEvent.CLICK, videoGroup3);
vid4_btn.addEventListener(MouseEvent.CLICK, videoGroup4);
vid5_btn.addEventListener(MouseEvent.CLICK, videoGroup5);
vid6_btn.addEventListener(MouseEvent.CLICK, videoGroup6);
vid7_btn.addEventListener(MouseEvent.CLICK, videoGroup7);
vid8_btn.addEventListener(MouseEvent.CLICK, videoGroup8);
vid9_btn.addEventListener(MouseEvent.CLICK, videoGroup9);
vid10_btn.addEventListener(MouseEvent.CLICK, videoGroup10);
vid11_btn.addEventListener(MouseEvent.CLICK, videoGroup11);
vid12_btn.addEventListener(MouseEvent.CLICK, videoGroup12);
vid13_btn.addEventListener(MouseEvent.CLICK, videoGroup13);
vid14_btn.addEventListener(MouseEvent.CLICK, videoGroup14);
vid15_btn.addEventListener(MouseEvent.CLICK, videoGroup15);
// all the way to vid15_btn

//////////////////////////////////// EVENT HANDLERS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
function videoGroup1(Event:MouseEvent):void {
currentList=videoList1;
videoIndex=0;
vidPlayer.source=currentList[videoIndex];
vidPlayer.addEventListener( VideoEvent.COMPLETE, nextMovie );
}

function videoGroup2(Event:MouseEvent):void {
currentList=videoList2;
videoIndex=0;
vidPlayer.source=currentList[videoIndex];
vidPlayer.addEventListener( VideoEvent.COMPLETE, nextMovie );
}

function videoGroup3(Event:MouseEvent):void {
currentList=videoList3;
videoIndex=0;
vidPlayer.source=currentList[videoIndex];
vidPlayer.addEventListener( VideoEvent.COMPLETE, nextMovie );
}

function videoGroup4(Event:MouseEvent):void {
currentList=videoList4;
videoIndex=0;
vidPlayer.source=currentList[videoIndex];
vidPlayer.addEventListener( VideoEvent.COMPLETE, nextMovie );
}

function videoGroup5(Event:MouseEvent):void {
currentList=videoList5;
videoIndex=0;
vidPlayer.source=currentList[videoIndex];
vidPlayer.addEventListener( VideoEvent.COMPLETE, nextMovie );
}

function videoGroup6(Event:MouseEvent):void {
currentList=videoList6;
videoIndex=0;
vidPlayer.source=currentList[videoIndex];
vidPlayer.addEventListener( VideoEvent.COMPLETE, nextMovie );
}

function videoGroup7(Event:MouseEvent):void {
currentList=videoList7;
videoIndex=0;
vidPlayer.source=currentList[videoIndex];
vidPlayer.addEventListener( VideoEvent.COMPLETE, nextMovie );
}


function videoGroup8(Event:MouseEvent):void {
currentList=videoList8;
videoIndex=0;
vidPlayer.source=currentList[videoIndex];
vidPlayer.addEventListener( VideoEvent.COMPLETE, nextMovie );
}


function videoGroup9(Event:MouseEvent):void {
currentList=videoList9;
videoIndex=0;
vidPlayer.source=currentList[videoIndex];
vidPlayer.addEventListener( VideoEvent.COMPLETE, nextMovie );
}

function videoGroup10(Event:MouseEvent):void {
currentList=videoList10;
videoIndex=0;
vidPlayer.source=currentList[videoIndex];
vidPlayer.addEventListener( VideoEvent.COMPLETE, nextMovie );
}

function videoGroup11(Event:MouseEvent):void {
currentList=videoList11;
videoIndex=0;
vidPlayer.source=currentList[videoIndex];
vidPlayer.addEventListener( VideoEvent.COMPLETE, nextMovie );
}

function videoGroup12(Event:MouseEvent):void {
currentList=videoList12;
videoIndex=0;
vidPlayer.source=currentList[videoIndex];
vidPlayer.addEventListener( VideoEvent.COMPLETE, nextMovie );
}

function videoGroup13(Event:MouseEvent):void {
currentList=videoList13;
videoIndex=0;
vidPlayer.source=currentList[videoIndex];
vidPlayer.addEventListener( VideoEvent.COMPLETE, nextMovie );
}

function videoGroup14(Event:MouseEvent):void {
currentList=videoList14;
videoIndex=0;
vidPlayer.source=currentList[videoIndex];
vidPlayer.addEventListener( VideoEvent.COMPLETE, nextMovie );
}


function videoGroup15(Event:MouseEvent):void {
currentList=videoList15;
videoIndex=0;
vidPlayer.source=currentList[videoIndex];
vidPlayer.addEventListener( VideoEvent.COMPLETE, nextMovie );
}
// all the way to videoGroup15


function nextMovie(event:Event):void {
if (vidPlayer.scrubbing==false) {
videoIndex++;
if (videoIndex!=currentList.length) {
vidPlayer.source=currentList[videoIndex];
}
else {
vidPlayer.source = "SelectVideo.mp4";
}
}
}




/////ARRAYS FOR FEATURE VIDEO//////
var videoListFeature1:Array = ["2009 WC Overview.mp4", "Nick Bollietieri ID.mp4", "SelectVideo.mp4"];

var videoPIndex:Number = 0;

var videoList:Array;

vidFeature_btn.addEventListener(MouseEvent.CLICK, videoGroupVidFeature);

function videoGroupVidFeature(Event:MouseEvent):void{
videoList = videoListFeature1;
videoPIndex=0;
vidPlayer.source = videoList[videoPIndex];
vidPlayer.addEventListener (VideoEvent.COMPLETE, nextVideoFeature);
}


///////////PLAYLIST FUNCTION/////////////////
function nextVideoFeature(event:Event):void{
if (vidPlayer.scrubbing == false){
videoPIndex++;
if (videoPIndex == videoList.length){
videoPIndex = 0;
}
vidPlayer.source = videoList[videoPIndex];
}
}




////////////////////Advertisements//////////////////////////////

function goTRCvideo(event:MouseEvent):void
{
var targetURL:URLRequest = new
URLRequest("http://www.tennisresources.com/");
navigateToURL(targetURL);

}
trcBtnvideo.addEventListener(MouseEvent.CLICK, goTRCvideo);


function goTCvideo(event:MouseEvent):void
{
var targetURL:URLRequest = new
URLRequest("http://www.tennischannel.com/programs/SeriesDetail.aspx?id=723");
navigateToURL(targetURL);

}
tcBtnvideo.addEventListener(MouseEvent.CLICK, goTCvideo);


function ocDownload(event:MouseEvent):void
{
var targetURL:URLRequest = new
URLRequest("http://uspta.com/html/Nov%202009%20On%20Court%20Ad%20Full%20Page%20Final.pdf");
navigateToURL(targetURL);

}
ocBtn.addEventListener(MouseEvent.CLICK, ocDownload);

function goDVD1(event:MouseEvent):void
{
var targetURL:URLRequest = new
URLRequest("http://usprotennisshop.com/default.aspx?MenuItemID=1305&MenuSubID=221&MenuGroup=Menu");
navigateToURL(targetURL);

}
dvdAd2_btn.addEventListener(MouseEvent.CLICK, goDVD1)


function goUSPTATV(event:MouseEvent):void
{
var targetURL:URLRequest = new
URLRequest("http://uspta.tv");
navigateToURL(targetURL);

}
logo_btn.addEventListener(MouseEvent.CLICK, goUSPTATV)


function goHighlight(event:MouseEvent):void
{
var targetURL:URLRequest = new
URLRequest("http://www.tennischannel.com/programs/SeriesDetail.aspx?id=723");
navigateToURL(targetURL);

}
highLink_btn.addEventListener(MouseEvent.CLICK, goHighlight);


function adHeader(event:MouseEvent):void
{
var targetURL:URLRequest = new
URLRequest("http://usprotennisshop.com/default.aspx?MenuItemID=1305&MenuSubID=221&MenuGroup=Menu");
navigateToURL(targetURL);

}
dvdproAd_btn.addEventListener(MouseEvent.CLICK, adHeader)


function goUSPTAmain(event:MouseEvent):void
{
var targetURL:URLRequest = new
URLRequest("http://www.uspta.com/");
navigateToURL(targetURL);

}
homeUSPTA_btn.addEventListener(MouseEvent.CLICK, goUSPTAmain)


////////////////////////// PAGE NAVIGATION /////////////////////////

stop();
function usptaNav(event:MouseEvent):void {
gotoAndStop(event.target.name);

}

videos.addEventListener(MouseEvent.CLICK,usptaNav);
{
trace ("video")
};
news.addEventListener(MouseEvent.CLICK,usptaNav);
{
trace ("news")
};
websites.addEventListener(MouseEvent.CLICK,usptaNav);
{
trace ("websites")
};
about.addEventListener(MouseEvent.CLICK,usptaNav);
{
trace ("about")
};
members.addEventListener(MouseEvent.CLICK,usptaNav);
{
trace ("members")
};



memVidplayer.stop()
removeChild(memVidplayer);






Return to posts index

Aisha Nelson
Re: gotoAndStop Error
on Dec 1, 2009 at 5:14:54 pm

Ok, so I think it has something to do with FLVPlayback component. I have two components on the videos page(vidPlayer) and the members page(memVidplayer). when i place the removeChild code on the other pages(news,websites,about us), that's when i start to get the error:
I am no longer getting the #1009 Error, but I am now getting the

TypeError: Error #2007: Parameter child must be non-null.

How can I remove the components from the other pages without
getting an error? This error only appears when I try to remove the components off the stage.


vidplayer.stop();
memVidplayer.stop();
removeChild(vidPlayer);
removeChild(memVidplayer);




Return to posts index

Marcus Geduld
Re: gotoAndStop Error
on Dec 1, 2009 at 6:18:27 pm

Is your code that removes children on the same frame as those children? You can't put code on frame one that affects an object on frame two (unless it's also on frame one).

Author "After Effects Expressions"
Co-author "After Effects For Flash, Flash For After Effects"
Artistic Director, Folding Chair Classical Theatre, Inc
Senior Flash Developer, Zeitbyte.com


Return to posts index


Aisha Nelson
Re: gotoAndStop Error
on Dec 1, 2009 at 7:03:46 pm

I have this code for the video page:

//////////////////////////////////// IMPORTING CLASSES
import fl.video.*;
import flash.events.*;


//////////////////////////////////// DECLARING VARIABLES
var vidPlayer:FLVPlayback = new FLVPlayback();
vidPlayer.setSize(557, 316);
vidPlayer.x=224;
vidPlayer.y=215;
vidPlayer.skin="SkinOverPlayStopSeekFullVol.swf";
vidPlayer.skinAutoHide=true;
vidPlayer.skinBackgroundColor = 0x929292;
vidPlayer.source ="Video Page startup video 1.mp4";
addChild(vidPlayer);


And I have thise code on the members page:

var memVidplayer:FLVPlayback = new FLVPlayback();
var currentVid:String;
currentVid = "Membership intro 1.mp4"
memVidplayer.source = currentVid;
memVidplayer.setSize(557,316);
memVidplayer.x = 224
memVidplayer.y = 215
memVidplayer.skin = "SkinOverPlayStopSeekFullVol.swf";
memVidplayer.skinBackgroundColor = 0x929292;
memVidplayer.skinAutoHide = true;
addChild(memVidplayer);



On the other pages, I just have this code to remove the players:

///////////////REMOVE FLV PLAYERS////////////////////////
vidPlayer.stop();
memVidplayer.stop();
removeChild(memVidplayer);
removeChild(vidPlayer);



Should addChild to each of the pages and then removeChild?


Return to posts index

Marcus Geduld
Re: gotoAndStop Error
on Dec 1, 2009 at 10:01:03 pm

Can you explain why you're adding and removing video players instead of just reusing the same one?

Author "After Effects Expressions"
Co-author "After Effects For Flash, Flash For After Effects"
Artistic Director, Folding Chair Classical Theatre, Inc
Senior Flash Developer, Zeitbyte.com


Return to posts index

Aisha Nelson
Re: gotoAndStop Error
on Dec 7, 2009 at 10:23:30 pm

I don't know how to only use one player to play different things on different pages...


Return to posts index

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