Jump to content


(Simple?) Actionscript Nav Bar issues


  • You cannot reply to this topic
1 reply to this topic

#1 Van Helsing

    Young Padawan

  • Members
  • Pip
  • 11 posts

Posted 17 July 2007 - 02:50 PM

Hey,

I was wondering if anyone could look at my Actionscript in this FLA for me, tell me what I could do to streamline it, make things work better etc etc

Link: Fuel Site 2 test.fla

Link: Fuel Site 2 test.swf

In this document, the Nav Bar is working alright, it's just that when you drag your mouse very quickly over the Nav Bar - all the buttons show up.

Now, I've put this down to my Actionscript, because I have IF statements controlling the fade away animations of each button.

For instance, when I roll over a button, any other buttons that have the orange square of over a certain alpha value are told to do the disappearing animation sequence. Therefore, any buttons that are under the set alpha value are left alone to finish their animation.

Whilst that works, it's a bit annoying to not be able to drag very fast over the Nav Bar without causing problems.

Then I thought, why not use the _y co-ordinate of the orange squares?
This at the time seemed a good way to go, as it would seem to be less of a pickle to deal with then determining alpha values.

However this did not work at all to my amazement. Flash just doesn't seem to do what I'm sure it's capable of.

Here's the FLA Link: Fuel Site 3 test Y coods instead of alpha.fla

Here's the SWF Link: Fuel Site 3 test Y coods instead of alpha.swf

Admittedly my code is a bit long and daunting (at least to me anyway),
but if anyone could help me with these, that'd be awesome.


And for those who think there's a better way of doing this same Nav bar effect, please do tell!

Thank you,
-Van Helsing

#2 Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 19 July 2007 - 08:48 AM

I was pleasantly surprised when I opened up your code :( Most people who post on here have horrendous coding habits. I'm just going to give you some tips and you can figure out the code, since you seem to have a basic understanding of Actionscript.

1) Use vars for your movie clip references. Makes life easier, and your code easier to read B)
2) To do a button selected state, add each button into an array, then when you click a button. Each button will then have a 'selected' property (name it something else tho, selected is a reserved word). When you click a button, you'll loop through the array (see the help docs for 'for loop') and if a button is selected, you play the out animation, and turn its selected state to false. After the loop, change the selected property of the clicked button to true and play its selected state.

You can do the same thing for a rollover state too. Same logic, but with an over property. When you roll over, it sets it to true, when you roll out it sets it to false.
3) You have alot of repeat code there, try making a function that you can pass a movie clip instance into. IE. write a function that accepts an argument that would be the clicked button. Your function loops through the array, then changes the values of the selected button. If you need each button to then load a unique page, you can pass in a url or frame label to the function as well.

Good luck with it. You've got a good start so far.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users