Creative COW SIGN IN :: SPONSORS :: ADVERTISING :: ABOUT US :: CONTACT US
Creative COW's LinkedIn GroupCreative COW's Facebook PageCreative COW on TwitterCreative COW's Google+ PageCreative COW on YouTube
ADOBE FLASH:HomeFlash ForumFlash TutorialsFlash Video TutorialsWeb Streaming ForumAdobe FlashPodcast

Problems scripting button links in Flash CS4/AS3.0

COW Forums : Adobe Flash

FAQ   •   VIEW ALL   •   ADD A NEW POST   •   PRINT
Share on Facebook
Respond to this post   •   Return to posts index   •   Read entire thread


Megan KenalProblems scripting button links in Flash CS4/AS3.0
by on Jul 3, 2012 at 9:36:34 pm

Hi all. First let me just get this out there: I'm new to Flash, and to scripting in general (my programming language knowledge extends as far as HTML and some CSS, and that's about it...if you can even call that programming). I'm redoing my website in Flash in an effort to teach myself Flash/ActionScript, since I learn best by doing. Four days and countless tutorial videos later, I think I have the basic hang of it...except now I've hit a major roadblock that I can't find.

A little background about my .fla: my movie comprises a single scene, with a total of six "pages" that folks can visit by clicking buttons; each button is a single line of text that I converted to a symbol of the "button" type. Each "page" has a frame label: "retHome" (for the main page), "retProse" (for my short stories), "retPoetry" (for my poems), "retEssays" (self-explanatory), "retArtwork" (photography), and "retContact" (self-explanatory). Each button instance has been appropriately labeled; for example, on the main "page" the buttons are labeled proseBtn, poetryBtn, essaysBtn, artworkBtn, and contactBtn (there actually is a 6th called designBtn that will link to an external website of mine, but I'm focusing just on internal links right now).

What I want to have happen is this: visitor opens website. Movie starts playing, then stops upon reaching final frame for main "page." Visitor clicks a button, movie moves to appropriate frame, and begins playing again from that frame on until final frame of ~that~ "page," etc. Back buttons on each "page" allow user to return to main "page" to visit another section.

The final frame of the main section is 168, so I've inserted the following code there:


stop();

//---home page buttons---

proseBtn.addEventListener(MouseEvent.CLICK, goProse);

function goProse(event:MouseEvent):void{
gotoAndPlay("retProse");
}

poetryBtn.addEventListener(MouseEvent.CLICK, goPoetry);

function goPoetry(event:MouseEvent):void{
gotoAndPlay("retPoetry");
}

essaysBtn.addEventListener(MouseEvent.CLICK, goEssays);

function goEssays(event:MouseEvent):void{
gotoAndPlay("retEssays");
}

artworkBtn.addEventListener(MouseEvent.CLICK, goArtwork);

function goArtwork(event:MouseEvent):void{
gotoAndPlay("retArtwork");
}

contactBtn.addEventListener(MouseEvent.CLICK, goContact);

function goContact(event:MouseEvent):void{
gotoAndPlay("retContact");
}



The stop(); works perfectly. The goProse function works beautifully. However, absolutely nothing after that works at all. I've tried rearranging the code bits (proseBtn/goProse is the only one that works, and only if it's first), I've tried grouping all the event listeners together and then doing the functions (same problem - the prose link is the only working one)... I don't know what's going on. I've verified I can't even count how many times now that the button instance names are spelled correctly both in the script and in their properties, that the frame labels are spelled correctly both on the timeline and in the script, etc. I've tried rewriting the code chunks by hand instead of copy/paste/change names like I did originally after writing the script for the prose link.

Debug mode shows the error tied to line 11, where the poetryBtn event listener is; that's where it hangs up, it won't progress past that even when I click "continue," and it doesn't throw any other errors. Again it doesn't matter which button is there, that's where it throws the error, unless I move proseBtn so it isn't first, in which case the error then throws at line 5. Here is the error when I test the movie:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at main_fla::MainTimeline/frame168()


And here it is when I run it in Debug mode:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at main_fla::MainTimeline/frame168()[main_fla.MainTimeline::frame168:11]


I'm tearing my hair out here folks!! Where have I gone wrong?!! Is there some limitation with links/buttons that I'm just missing here??


Posts IndexRead Thread
Reply   Like  
Share on Facebook


Current Message Thread:




LOGIN TO REPLY



FORUMSTUTORIALSMAGAZINESTOCKYARDVIDEOSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

Creative COW LinkedIn Group Creative COW Facebook Page Creative COW on Twitter
© 2013 CreativeCOW.net All rights are reserved. - Privacy Policy

[Top]