views:

251

answers:

2

Hello! I'm building a website in Flash CS3 and I'm having a problem. Yo give you a basic idea, the website itself is static, and when you click a button the only thing that changes is the content in the box. The first problem I'm having is that I can't stop the content from looping. Its set up so that a short animation plays and then the content shows, however, there are 7 different instances of the content that should appear on click. The buttons aren't working and the content just keeps looping. This is the code I have currently:

ContactUs.addEventListener(MouseEvent.CLICK, clickContactUs);
function clickContactUs(event:Event):void 
{ 
  trace("Contacting!!");
  gotoAndStop("ContactUs");
}

(Sorry ahead of time, I can't get the code to display correctly) There is a similar one for each content "page", 7 all together. In the first keyframe, there is a stop(), yet it's not stopping, and the buttons aren't working. Any advice or suggestions would be great, this is getting frustrating!

+1  A: 

Ok so it sounds like you have various buttons (contact us for example) and when you click that button you want to go to a certain frame in a content MovieClip for the relevant click.

Double check that you have all your instances named correctly. It is handy to have some sort of naming convention. Instead of your button being called ContactUs, call it btnContactUs or contactUs_btn, which ever you prefer.

Next thing is to change;

function clickContactUs(event:Event):void

to

function clickContactUs(event:MouseEvent):void

for best practise.

Now we get to where I think your problem might be :P.

It seems as though you have spread your animation on the timeline (as you are calling gotoAndStop on the timeline and not on any MovieClip, unless this is your mistake).

You are much much better off to put your animation in a MovieClip then put that MovieClip on frame 1 of the timeline, and have no more frames. Inside your MovieClip have keyframes at the various sections and place a stop() just for safe keeping and make sure you have relevant frame label names.

Then in your function handling the clicks you can refer to the instance of this content box, mcContent.gotoAndStop("ContactUs");

PS: Also I had a thought, make sure you are compiling with no errors otherwise nothing will respond and animation will keep looping.

Allan
Thanks a ton for your help! I really appreciate it. However, before I read your answer I was messing around with something and realized I had a period of extreme blonde-ness and did not rename one of the buttons -.- It works perfectly now! :)
jxd215
haha it happens :), my pet mistake is doing = when I mean to do ==
Allan
A: 

I am having the same problem in flash 8...Any ideas? I have designed a full website in flash 8, for some reason when I test the movie it gets a mind of its own and plays the whole website in a snap even though I have stops in the right places, the pages have Frame names and each button,movie and graphic have their own layers. Any advice would be appreciated because its drinving me nuts!! Thanks

elless27