Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 12-20-2004, 10:29 PM   #1
Registered User
3dmacguy's Avatar
Join Date: Apr 2004
Location: Savannah, GA
Posts: 79
Arrow Problem with function call.... need help

Hi all,

I have 4 'button' movieclips and 4 other movieclips, all within the same parent movieclip.

The buttons are:


The movieclips are:

subnav1 (associated with home_btn)
subnav2 (associated with service_btn)
subnav3 (associated with company_btn)
subnav4 (associated with contact_btn)

What I want to do is to show the appropriate associated subnav movieclip when the related 'button' movieclip is clicked. However, every other subnav moviecclip must be hidden and only the correct one shown. This is the script I have so far... which works to some extent, but more on that in a min.

This code is on frame 1 of a layer.

ActionScript Code:
home_btn.onRollOver = function() {     home_btn.gotoAndPlay(1); } home_btn.onRollOut = function() {     home_btn.gotoAndPlay(7); } home_btn.onMouseDown = function() {     changeNav("subnav1"); } //this is for service button service_btn.onRollOver = function() {     service_btn.gotoAndPlay(1); } service_btn.onRollOut = function() {     service_btn.gotoAndPlay(7); } service_btn.onMouseDown = function() {     changeNav("subnav2"); } //this is for company button company_btn.onRollOver = function() {     company_btn.gotoAndPlay(1); } company_btn.onRollOut = function() {     company_btn.gotoAndPlay(7); } company_btn.onMouseDown = function() {     changeNav("subnav3"); } //this is for contact button contact_btn.onRollOver = function() {     contact_btn.gotoAndPlay(1); } contact_btn.onRollOut = function() {     contact_btn.gotoAndPlay(7); } contact_btn.onMouseDown = function() {     changeNav("subnav4"); }

This code is on frame 1 of a different layer.

ActionScript Code:
#include "lmc_tween.as" subnav1._visible = false; subnav1._alpha = 0; subnav2._visible = true; subnav2._alpha = 100; subnav3._visible = false; subnav3._alpha = 0; subnav4._visible = false; subnav4._alpha = 0; //set initial variables _global.oldpage = "subnav2"; /*************** PAGE CHANGE FUNCTIONS *******************/ //set page change function _global.changeNav = function(newpage) {     if (newpage != oldpage) {             _global.pagetochange = newpage;         trace("The oldpage is: " + oldpage);         trace("The newpage is: " + newpage);                 _root.navBar[oldpage].alphaTo(0, 1.5, "easeInOutQuad");         /*_root.navBar[oldpage]._visible = false;*/             _root.navBar[pagetochange]._alpha=0;         _root.navBar[pagetochange]._visible = true;         _root.navBar[pagetochange].alphaTo(100, 1.5, "easeInOutQuad");             oldpage = newpage;     } else if (newpage == oldpage) {         stop();         trace("page already selected!");         trace("-----------");     }    }

Now, the problem is that whenever I click on any one 'button' movieclip, the function seems to run for every button. The traced output looks like this:

The oldpage is: subnav2
The newpage is: subnav4
The oldpage is: subnav4
The newpage is: subnav3
The oldpage is: subnav3
The newpage is: subnav2
The oldpage is: subnav2
The newpage is: subnav1

However, if I delete the code for all but one 'button' movieclip, it works as it should. But with the code there for each button in the first code block above, I get the wrong result. Anyone know why this is happening?

Thanks for the help in advance!

3dmacguy is offline   Reply With Quote
Old 12-21-2004, 01:15 AM   #2
Registered User
3dmacguy's Avatar
Join Date: Apr 2004
Location: Savannah, GA
Posts: 79

Hey guys,

Well, I seemed to have stumbled across the solution. I was using:

movieclip.onMouseDown to call the function. This was causing the problem. Instead, I used movieclip.onRelease. This fixed it. Is there any particular reason this works and the other doesn't?

Consider this problem solved.

Thanks for all those who looked

3dmacguy is offline   Reply With Quote
Old 12-21-2004, 09:55 AM   #3
The Black Prince
Join Date: Nov 2004
Location: Pasig City, Philippines
Posts: 235
Send a message via Yahoo to redruby

onMouseDown is for the Mouse Class, not for the MovieClip. It catches all mouse presses anywhere in the movie.
redruby is offline   Reply With Quote

Thread Tools
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

All times are GMT. The time now is 06:56 PM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.