The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Design
> Flash Help
|
ActionScript 3 - Menu Navigation AS3 - Class Document
Discuss Menu Navigation AS3 - Class Document in the Flash Help forum on Dev Shed. Menu Navigation AS3 - Class Document Flash Help forum discussing all products originally created by Macromedia including DreamWeaver, Contribute, Flash, Fireworks, Freehand, Director, Authorware and HomeSite. Adobe bought Macromedia in 2005.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

April 20th, 2011, 02:35 PM
|
|
Registered User
|
|
Join Date: Apr 2011
Posts: 3
Time spent in forums: 40 m 55 sec
Reputation Power: 0
|
|
|
ActionScript 3 - Menu Navigation AS3 - Class Document
I am making a flash website for my girlfriend's art projects, and I have become a bit stumped. I've researched for a while and can't find the source of my problem. The website is all contained in a single flash file, each page is not it's own *.swf, and there are no compiler errors being displayed when tested.
I'm trying to use an external *.as file to control all menu navigation, and when the movie is tested the first menu button clicked always works, however, once you try and go back to the original page or another new page it only works sometimes - it's like the buttons have lost their event listeners. Maybe someone with a bit more AS3 experience can tell me what is going on?
Thank you.
Code:
package {
import flash.display.MovieClip;
import flash.events.MouseEvent
public class WebSite extends MovieClip {
public function WebSite() {
stop();
home_btn.addEventListener(MouseEvent.CLICK, GoToAndStop_home);
function GoToAndStop_home(event:MouseEvent):void
{
gotoAndStop("home");
}
works_btn.addEventListener(MouseEvent.CLICK, GoToAndStop_works);
function GoToAndStop_works(event:MouseEvent):void
{
gotoAndStop("painting");
}
bio_btn.addEventListener(MouseEvent.CLICK, GoToAndStop_bio);
function GoToAndStop_bio(event:MouseEvent):void
{
gotoAndStop("bio");
}
contact_btn.addEventListener(MouseEvent.CLICK, GoToAndStop_contact);
function GoToAndStop_contact(event:MouseEvent):void
{
gotoAndStop("contact");
}
init();
}
}
}
|

April 21st, 2011, 03:01 AM
|
|
Gotta get to the next screen..
|
|
Join Date: Nov 2003
Location: Legion of Dynamic Discord
|
|
You should create the event handler functions outside of the WebSite function:
Code:
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent
public class WebSite extends MovieClip
{
public function WebSite()
{
stop();
home_btn.addEventListener(MouseEvent.CLICK, GoToAndStop_home);
// Other listeners go here.
init();
}
function GoToAndStop_home(event:MouseEvent):void
{
gotoAndStop("home");
}
// Other event handler functions go here.
}
}
__________________
Quis custodiet ipsos custodes?
|

April 21st, 2011, 02:36 PM
|
|
Registered User
|
|
Join Date: Apr 2011
Posts: 3
Time spent in forums: 40 m 55 sec
Reputation Power: 0
|
|
|
Thanks for the response
That makes sense. However, when I try that the same problem exists. When I test the site with cmd + enter, the first button I click works fine and takes me to any page. After that it's spotty at best - most of the time none work after the first click, yet sometimes it will work once more but then stop working again.
I did the first version with all timeline coding and no external .as file, and it works on 95% of computers, but it has the same problem of losing button functionality on others. The timeline coded site is uploaded to flythekite.com
I was hoping it would solve the problem to have one external master code for the menu buttons, instead of coded in every page in the timeline which is messy - but my AS3 knowledge is fairly basic and I'm getting the same result.
|

April 22nd, 2011, 05:00 AM
|
|
Gotta get to the next screen..
|
|
Join Date: Nov 2003
Location: Legion of Dynamic Discord
|
|
Hi again, that seems to work for me in IE9. The HTML you're embedding it with is another story. Try using swfobject2 instead. They have full examples on their page. You could definitely be causing problems with that since the current code you're using is well outdated. One thing that jumps out at me straight away is that you're telling the Flash player that your content is meant for Flash Player 6 which is from years ago. I know for a fact that can't be correct since you are using AS3 which didn't exist back then.
|

April 22nd, 2011, 12:16 PM
|
|
Registered User
|
|
Join Date: Apr 2011
Posts: 3
Time spent in forums: 40 m 55 sec
Reputation Power: 0
|
|
|
Thank you, I will try those suggestions today. I really appreciate the feedback.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|