Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 20th, 2011, 02:35 PM
a_young240 a_young240 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2011
Posts: 3 a_young240 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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();
		}
		
	}
}

Reply With Quote
  #2  
Old April 21st, 2011, 03:01 AM
Tann San Tann San is offline
Gotta get to the next screen..
Dev Shed God 4th Plane (6500 - 6999 posts)
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 6,663 Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)  Folding Points: 14767 Folding Title: Novice Folder
Time spent in forums: 1 Month 1 Week 3 Days 20 h 10 m
Reputation Power: 3163
Facebook MySpace
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?

Reply With Quote
  #3  
Old April 21st, 2011, 02:36 PM
a_young240 a_young240 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2011
Posts: 3 a_young240 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #4  
Old April 22nd, 2011, 05:00 AM
Tann San Tann San is offline
Gotta get to the next screen..
Dev Shed God 4th Plane (6500 - 6999 posts)
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 6,663 Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)  Folding Points: 14767 Folding Title: Novice Folder
Time spent in forums: 1 Month 1 Week 3 Days 20 h 10 m
Reputation Power: 3163
Facebook MySpace
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.

Reply With Quote
  #5  
Old April 22nd, 2011, 12:16 PM
a_young240 a_young240 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2011
Posts: 3 a_young240 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 40 m 55 sec
Reputation Power: 0
Thank you, I will try those suggestions today. I really appreciate the feedback.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignFlash Help > ActionScript 3 - Menu Navigation AS3 - Class Document

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap