Creating the Layout |
For the first part, we're going to create the basic layout. |
Step 1. |
To start off, create a new Flash document with the following settings. |
|
|
Step 2. |
Double click on the rounded rectangle and set the corner radius to 15 |
|
|
Step 3. |
Create a greay (#E4E4E4) rounded rectangle, using the settings shown below. I've zoomed out to 50% here. |
Enlarge |
|
|
Step 4. |
Convert the rectangle into an MC (Movie Clip Symbol) called main. This is where we'll be creating the site. |
|
|
Step 5. |
Go into the 'main' MC and convert the rectangle into another MC, this time calling it 'bg' |
|
|
Step 6 |
Open up the 'bg' mc, create a 2nd layer and a grey/green (#839597) rectangle, without rounded corners |
Enlarge |
|
|
Step 7 |
Create a 3rd, darker (#B4B4B4) rectangle on another new layer. |
Enlarge |
|
|
Step 8 |
Make a 4th lighter grey rectangle |
Enlarge |
|
|
Step 9. |
Go back to the 'main' MC, and import the header image onto the stage. |
|
|
Step 10 |
Convert the header image into an MC (Movieclip) called 'header' |
|
| | ||||||||||||||||||||||||||||
|
| ||||
Step 36. | ||||
Now that we've created all the assets for the website, it's now time to start writing the actionscript, to make the website functional. So, in the 'main' MC, create a new layer called 'script' and open up the Actions Panel (F9) | ||||
| ||||
|
Step 37. |
|
Line 1 - On the first line, enter the code shown above. The 'menu' array is created to hold each menu button name. We'll be writing the actionscript so that menu buttons can be added by simply add and subtracting names from the menu array. |
|
Step 38. |
|
Line 2 - An empty MC is created, called 'content' which will later be used to attach each section onto. The content MC can then be scrolled along the X axis, rather than moving each individually section. Line 3 - The 'sectionBackground' MC is attched and given the instance name 'mask'. The mask MC will be used to mask the content MC. Line 4 - The mask and content MC's are placed at the Y position where we want the content to appear. Line 5 - The mask and a variable called target are placed at an X position of where we want the content to appear. When the website loads, to make it more interesting, the first section will be displayed off screen and then scroll to the 'target' position. The target value will later be used to hold a value that the content must scroll to, each time it's associated menu button is pressed. Line 6 - The content MC is set to be masked by the mask MC. Line 7 - The content MC is set to start at -1000 X position. We'll later write some Actionscript to scroll the content MC from this value to the target value. |
|
Step 39. |
|
Line 8 - A speed is set for how fast the section MC will scroll at. |
|
Step 40. |
|
Line 9 - xStart is the X position where the 1st drop down button will appear. Line 10 - yStart is the Y position where the 1st drop down button will appear. Line 11 - bWidth is the width of the button. Since the button has a hairline border (stroke), the thickness of it won't change as the width and heigh of the button are changed. Line 12 - bHeight is the height of the button. This value will be used to place each button vertically. |
|
Step 41. |
|
Line 13 - A 0.05 second insterval is stored in this variable, which will be used inbetween scrolling down each menu button. The higher this number, the longer it will take for each button to move down after the previous one. Line 14 - This variable holds number of items in the menu array. It'll be used when attaching the menu buttons - More will be explaing later. Line 15 - A variable to hold a boolean value for the menu being open or closed. Line 16 - A time stamp will be held in this variable. |
|
Step 42. |
|
Line 17 - The speed at which the buttons will scroll. |
|
Step 43. |
|
Line 18 - A for loop is created to loop through the items in the menu array. The "i" in the loop will start off at 0 and increment by 1 (i++), while i is below the menu's length. Line 19 - Using the loop, each menu item is attached the empty 'content' MC, by referencing the identifier ('section_photoshp' etc) that we gave each section MC earlier. Each section is assigned to a temporary variable called "section", that we can use to set its properties. |
|
Step 44. |
|
Line 20 - The section's X position is set using it's width and multiplying it by the incrementing "i" in the loop. So since the each section is 588 in width, the 1st section, from the menu array, will be placed at 0 (0x588) X position in the "content" empty MC. The 2nd section will be placed 588 (1X588), and so on until "i" has reached the menu array length. Line 21- Each sub button MC is attached, by referencing the identifier ('subButton') that we gave the button earlier. The subButton is then assigned to 'b', which we can then use to reference it. Line 22- When the buttons scroll down, each will appear from behind the previous one, so when they're created they need to be attached on a level below the preious button. So, the countDown variable is used on line 21 to give the subButtons a level, and then decreased by 1, for the next button appears to appear on a level below. |
|
Step 45. |
|
Line 23 - 'b' (The current subButton MC) is told to stop since it has 2 frames. Line 24- 25 - The subButtons are positioned at xStart and yStart, which were decalred at the top earlier. |
|
Step 46. |
|
Line 26 - A interval' property is then given to the 'b'. The interval, which was created earlier, is multiplied by 'i', so the buttons descend sequentially. Line 26 - When the 'mainButton' is pressed, each subButton needs a target Y position to scroll down to. So the subButton height is multiplied by 'i' and then added on to the star position of the sub buttons. This valued is assigned to the target property. |
|
Step 47. |
|
Line 28 - Remember when the subButton dynamic text was created, a var (txt) was given to it? Now this can be used to display the sub button text, using the text stored in the menu array. Line 29 - The content MC, containing each section, also needs a target each time a subButton is pressed, so this is stored in the 'pos' property of each subButton. The target of the 1st section was set at the start, so it's now added to i - the section width. |
|
Step 48. |
|
Line 30 - An onPress function is given to 'b' Line 31 - When the sub button is pressed the target variable will be set as the pos property Line 32 - The closeMenu function, which is about to be created, is called. Line 33 - A function is going to be created to tell the sub button to go to it's roll over state (frame 2) whenever it's rolled over. When the sub button is pressed, the buttons's state must change back to the default (frame 1). |
|
Step 49. |
|
Line 35 - 40 - The roll over and out functions are created. Line 41 - Each sub button is set to be insible when they are first created. |
|
Step 50. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
And this is the Actionscript so far: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
0 nhận xét:
Post a Comment