Link to home
Start Free TrialLog in
Avatar of Karl01
Karl01

asked on

How to create a simple static menu in flash

Hi,

I am working with sixth form students and have been asked to cover Flash at laste notice and I have never used this program/environment myself and have found many tutorial useful for the basics like tweening and simple movements however I am having trouble adding the interactivity, such as buttons to click that will load a different layer/time/flash file. I have manage to draw a button and have some code that on click it will jump to frame x (100 etc). Anything more complex seams to just fail for me.

What I need now is a static menu i.e. 5 buttons on the left and different ‘pages’ to load when they are clicked and through an intensive search and many tutorials I still cant get any to work. Basically  I am needed to create a small ‘website’ of five pages of information and due to the course we have to use flash not Dreamweaver. Please can I ask that the solution is as simple as possible 1 for me and 2 for my students as they have never used Flash either. Is there anyway for this to be done without action script or with as little as possible?

Also I don’t know how to keep the buttons or information on screen indefinitely - until the user clicks another button.

Any further information/clarification needed please don’t hesitate to ask.

Many thanks for any help you can provide it will be much appreciated by me and the students.
ASKER CERTIFIED SOLUTION
Avatar of AreDubya
AreDubya
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Karl01
Karl01

ASKER

AreDubya,

That’s a great clear example for me to use. However I have just tried to figure out how it all works, so if I could ask a few follow up questions if you don’t mind that would be great.

I have tried to step through and recreate your example to learn but have already encountered a problem. The text buttons are static on screen by using the convert to ‘movie clip’ option rather than the button option as I had been trying, but when I add the pages and run the clip they just cycle through really fast as if they are still part of the normal timeline, I have drawn them on the content layer and selected F8 to convert them to a movie clip on each keyframe on frame 1-5 am I missing a step?

Also I have changed some of the code to suit my variable names (I think) and I have been given and error for each button here are the details:

1120: Access of undefined property Btn1.  
Btn1.addEventListener(MouseEvent.MOUSE_DOWN, getPage1);

Also what is meant by the word ‘void’ at the end of each function?  I am going through tutorials and book but due to the time constraints and specific criteria I have to work to, its a frustratingly slow process.

Thank you very much for your help. I will of course award the points for the initial answer but not sure if I do that now will that stop us being able to discuss this further?

Best regards
Karl
Karl01,

Glad it's helpful. I am not sure what you mean by "static on screen", I am assuming just that they don't disappear. This is the sequence to create the buttons:

Make a text box w/ text.
Convert that to a MovieClip.
Add it to the stage on frame one.
On the same layer, insert a frame at the end of the movie - not a key frame.
The button will now be on stage for the entire time.

To get rid of cycling:

Make sure you have stop(); at the top of the first frame, it will hold the playhead there.

The 1120 Error:
Not sure without a file. You are trying to get to something with an instance name Btn1 inside of something named Btn1? If you just changed the name(maybe a bad call for the students, sorry ; )), then you should use:

Btn1.addEventLIstener(MouseEvent.MOUSE_DOWN, getPage1);

Also, you have to change the instance names - select the button and make sure the name is Btn1 on the properties panel.

Void at the end of a function means the function won't return anything. If the function returned something you would change that to Number, String, whatever the function returns.

Paste the code below into a new fla, when you click the stage it traces a random # bet 0 - 10. You can see how the return is used.

Good Luck,

AreDubya
import flash.events.MouseEvent;

var test:Number;

test = getNumber();

function getNumber():Number
{
	return(Math.random() * 10);
}

function traceTest(e:MouseEvent):void
{
	test = getNumber();
	trace(test);
}
stage.addEventListener(MouseEvent.MOUSE_DOWN, traceTest);

Open in new window

Also, check out tv.adobe.com - really good tutorials on both the Flash IDE and ActionScript.

AreDubya
Karl01,

One other great site for tutorials - gotoandlearn.com . Can you close this thread if I have answered your question? Thanks,

AreDubya
Avatar of Karl01

ASKER

Hi AreDubya,

It was the instance name that was missing from the button text and that stopped the ‘page’ boxed cycling through like a rave light.

Great spot on the reason for the name change; although a bit of humour could help them remember the procedure better I won’t risk it with a new class just yet.

I will check out the two reference sites you have provided however I think I will be back here before long.

Thank you for your effort and the work you put in, it is greatly appreciated.

Karl
Avatar of Karl01

ASKER

Very helpful.
Glad to help, I will keep an eye out for you!

AreDubya