Coding in Flash
Normal and Expert mode
During basic Flash course you used Normal mode of Action sPanel. It meant that if you needed to enter the script you simply double clicked or dragged the action from the Action Tool panel.
From now on you will mainly use Expert mode of Actions Panel. Expert mode allows you to type and change code directly in the Code Window. Still it’s possible to double click or drag code fragments from the left, but it will be less help to you. It is advisable to do even though it will take a bit more time and lead you to errors sometimes. In exchange you will have an opportunity to master your code writing skills and learn more about ActionScript syntax.
Find a button with Arrow pictogram at the right side of Actions Panel. Using it you may switch from Normal to Expert mode. Type something in the code window and try to return back into Normal mode – it will be not possible – only valid programming code may appear in Normal mode and if you typed something meaningless from ActionScript point of view – you need to delete it or fix in Expert mode.
Now let’s do a small exercise.
- Add 6-10 frames to the Timeline
- Add two more layers. Call first layer ACTIONS, second lrNumbers, third lrButton .Make sure that your button is in appropriate layer. Add keyframes in all frames of layer lrNumbers
- Type sequential numbers (1, 2, 3) in each keyframe of lrNumbers
- Test your movie it should look like that
- Highlight the button and delete all the code in the Actions Panel which you’ve done before
- Manually enter the following script
on(release) { stop(); } - Test your movie. On the button click it must stop.
- Now insert a keyframe into first frame of layer ACTIONS
- Place your cursor at the first frame of the Actions and manually enter stop(); in the code window. You should notice the difference – button code may appear only inside event handler (in our example on release). Frame code doesn’t require event handler.
- Again highlight the button, delete stoping script and manually enter
on (release) { nextFrame(); } - The last option goes one frame forward on each button click. Numbers change accordingly
- Experiment with this script. You may add more buttons and frame content. Enter all the code manually.
By working on this module you found that when you type the code in the Expert mode matching options are displayed for you. For example when you typed on ( , after the parenthesis had been typed Actions Panel displayed tips with a set of possible events for the button. In other cases (for example after getURL list of necessary parameters is shown. Those “tips” may help you a lot with manual coding.