Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Flash Actionscript / July 2008



Tip: Looking for answers? Try searching our database.

array and gotoAndStop() issue

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ibrubru - 17 Jul 2008 08:51 GMT
Hi I am try to assign each menu btns to go to designated frames but it doesn't
work.
any idea would be greatly appreciated. thanks.

var menus = [aboutus, cd, awards, cl, news, contactus];
var frames = [2,3,4,5,11,12];
for(var j=0; j<menus.length; j++) {
    menus[j].onRelease = function() {gotoAndStop(frames[j]);};
}
DMennenoh **AdobeCommunityExpert** - 17 Jul 2008 12:20 GMT
It doesn't work because of this:
gotoAndStop(frames[j]);};

frames[j] is not a local variable in the button clip. All buttons should go
to frame 12 the way you have it.

You can do like so to make a local var within each button:

var menus = [aboutus, cd, awards, cl, news, contactus];
var frames = [2, 3, 4, 5, 11, 12];
for(var j = 0; j < menus.length; j++) {
 menus[j].myFrame = frames[j];
 menus[j].onRelease = function() {gotoAndStop(this.myFrame);};
}

Signature

Dave -
www.offroadfire.com
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/

ibrubru - 17 Jul 2008 15:31 GMT
Actually it didn't even go to frame 12 the way I had it
but I'm glad it's all working fine now.

thank you, Dave.
DMennenoh **AdobeCommunityExpert** - 17 Jul 2008 19:13 GMT
>>Actually it didn't even go to frame 12 the way I had it

Ah, right - because when the loop ends j is equal to the length of the menus
array - 6. So frames[6] would be undefined...

Signature

Dave -
www.offroadfire.com
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.