Welcome to the Flash Tutorial. This tutorial was written by Star_Cleaver and PikaExploder as a reference for all flash users who have a question. If you find errors in a script or in logic that you see on this page then report it to Star_Cleaver and it will be fixed as soon as possible.(Please don't e-mail me asking for help with Flash, ask in the Flash forum). Also, most of these codes are written by users of Flash MX so they might not be compatible with Flash 5. If one of these scripts doesn't work for your specific situation then visit the Flash Forum and i'm sure that one of the regulars would be glad to help you build your script. Thank you. |
SectionsWhere to get FlashMacromedia Studio MX Free Trial DownloadsMacromedia Educational Store - cheaper versions of the product for those who qualify (Thanks to Newgrundling for all of that) -Back to
Top- Property Inspector: this is your most valued menu. You can access it by pressing ctrl+F3 or by going to window->properties. This menu will show you all of the options available for each tool when selected and give you the details of objects you have selected at the time. Also if you just click on the blank stage the property inspector will allow you to change the background color or you movie and the size of your movie(these options are also available by pressing ctrl+J or through modify->document. Actions Panel: This menu is where you place all of your ActionScript(AS). You can acces it by pressing F9 or throught window->action. Click on the item you can to add actions too and then open it to add actions to that object. If open this panel you will see that there a list of all of the scripts available for flash, located in the sidebar. The buttons on the top allow you to do different things. They are pretty much self-explanatory in their purpose. If you go to the "view options" button you can change from "Normal Mode" to "Advanced Mode" and vice versa. Normal Mode is where you select your scripts and flash "helps" you build them by giving you the options for that script. Advanced Mode allows you to free-style your script. This is good if you are copying and pasting scripts into your movie from outside sources. But when building in Advance Mode, always make sure to use the "Check Syntax" button to check for errors in your script. Timeline:Your timeline is another important menu in Flash. It shows you what information you have where in your flash movie. If you right-click a frame you will all of the options you can select for that frame. Keyframes are "markers" on the timeline that tells flash that something changes on the frame. For Example: if you are trying to make an animation of a man walking, you will need to insert a new keyframe for each change in his stance. If not flash will change the content of the precious frame and you will have just a still image. Blank Keyframes are frames that have no content in them. The rest of the options are self-explanatory and the "Create Motion Tween" option will be covered later. Transform: This menu is accessed through window->transform or by hitting ctrl+t. This menu allows you to rotate, streatch and skew items on the stage. Just select the item you want to transform and change its values in this menu. Color Mixer and Color Swatches: Available through Shift+F9 and Ctrl+F9(and through window->color mixer/color swatches),these menus help you to select colors you want to use. They should look familiar if you've ever used Paint before. Just select the color you want. You can also change the Alpha value of an item through this menu. The alpha is the transparency of the color. 100 is opaque and 0 is not visible at all. Library: Windows->library or F11. This is where all of your assets are stored. Just drag your assets on to the stage to add them. Scenes: Windows->Scenes or Shift+F2. This is where all of your scenes are listed. You can add them, delete them, and move them from this menu. What are symbols Symbols are your best friend in Flash. They are drawings that you have made that can be used over and over again without having to redraw them. They are found in the library. As a rule of thumb, if you use a picture more than once in a movie, like a background, then make it a symbol. It will help reduce your filesizes in the end. Types of Symbols Graphic: These are the basic symbols. They are
static images of your drawing.
-Back to
Top- Now say you want to alter the shape of your gradient. This is when its time for the "fill transform tool." You'll see three "handles" that allow you to alter the fill. One let's you rotate, one let's you stretch the fill, and another let's you move the fill altogether. -Back to
Top-
Importing them: If you want to bring sounds and pictures into your flash movie then this is how to do it. Just go to file->import or file->import to library(i'll explain the difference later) then select your file that you want to import. Not that hard, right? Now if you choose "import" then your item that you imported will appear on the stage, unless it a sound, then it will appear in the library. If you choose "import to library" then the items will appear in the library. This is good if you are importing a bunch of pictures at one time adn you don't want them to appear on the stage. Adding them:pictures:To add pictures just open the library and
it should be there ready to drag onto the stage. Then place them where you want.
-Back to
Top- break apart: The first one is a little more tedious but it will give you a better look in the end. It uses the Break Apart command. Just select your sprite and then hit ctrl+b or modify->break apart. This will make your picture editable. Just use the eraser tool and zoom in real close and erase that white box! Trace Bitmap: This method might degrade your image quality a bit and
its its not good for complex pictures because it will take up a lot of space,
but it sure is a whole lot easier. What it does is turns the bitmap into vector
art, the native art of flash. Okay what you want to do is select your image and
goto modify->trace bitmap. Then you will see a little box with some options
in it. After you select you options you can select portions of the picture to
edit, just like a piece of art you created in Flash. -Back to
Top-
Methods:Well we got some requests for this and i'm not much of an
artist but i'll still explain the methods used to animate. There are two methods
of animation: Tweening and Frame-by-Frame Learning how to animate: Well, to learn to animate takes lots of practice. If you are in need of a good tutorial on drawing/animatin i suggest the tutorials by Percival. He has a good tutorial on the walk cycle. Check them out, you might find them helpful. Also, just search the internet for tutorials, you're bound to find something. Blur Effects: Ever wondered how some artists made that cool blur effect. Well, i will tell you how to do it, although you can't do it in Flash. So for all you people who are stuck with flash, you'll have to go without. But with those of you with Photosop, you can make a picture and use the Guassian blur filter. This will make the picture look blurry. Drawing Tablets: A drawing tablet is a piece of hardware that hooks up to your computer(normally throught USB) and it allows you to draw, with a pen, on your computer. Well, you draw on the tablet and its transfered to your computer. Its a lot better than drawing with that old mouse. Most tablets have pressure sensitive drawing areas that allow you to press harder and it draws thicker lines. They are compatible with Flash and will make drawing your animations a lot easier. I suggest you get a Wacom Pad. Wacom is a very good brand of tablet. Go check out their website. Wacom.com Browse around and look at what they have to offer. You can also check out other brands of tablets, i'm not saying you have to get a Wacom, but i find that they are very good, high-quality pieces of hardware. Just choose a size that is right for you, and you're wallet. Don't think that 4"X 5" is small. You'd be suprised at how much you can draw with the little ones. -Back to
Top- We will go throught this in a step by step method so that you can easily follow along. 1)make a new scene and make that your preloader scene. goto window->scene and make sure it is at the top of the list. 2)make two layers in your new scene. call one of the "actions" and the other "loader".(just to help keep things straight.) 3)in the loader layer, make two keyframes; one on frame 1 and the other on frame 3. 4)on frame 1 of the loader layer make your text that says "loading". you can even make it a movie clip if you would like some animation to your preloader, whatever you wanna do, just keep the format the same. 5)on the actions layer make three empty keyframes. name frame 1 "start" and name frame 3 "end" 6)on frame 1 of the actions layer, put this in the actions panel: lBytes = _root.getBytesLoaded(); //defines the varibable "lBytes" as the amount of bytes loaded from the movie tBytes = _root.getBytesTotal(); //Defines the variable "tBytes" as teh amount of bytes in the total movie if (lBytes>=tBytes && tBytes>0) { gotoAndStop("end"); }//tells flash that if the loaded bytes are greater than or equal to zero and the total bytes are greater than zero, then the timeline will progress to the specified frame. 7)on frame two of the actions layer, put this in the actions panel: gotoAndPlay("start"); //makes the movie loop back to the first frame so that your movie doesn't play before its loaded 8)now on frame 3 of the "loader" layer, you need to make your text that says "play". make this text a button and in the actions panel put this script: on (release) { play(); } PreLoader w/ LoadBar: This time we will go through how to make a preloader with a loadbar because a loadbar is just another way to keep the user informed of how the movie is doing in its load process. 1)repeat all of the steps of the first preloader 2)now go back to your loading screen and make a little rectangular box. 3)select ONLY the fill from the box. Make the fill an MC and name it whatever you want BUT make sure that your registraion point is on the left! This is very important, don't forget to do it. 4)Now select your MC and go open the transform menu; windows->transform and then make the width of the box 1% 5)Now go to the stage and select your MC. Goto the property inspector and change the instance name to "box" 6)Now select your MC and then open the actions panel. Now add this to your code, right below where you define the variables: percentLoaded = Math.floor((lBytes/tBytes)*100); //makes a percent from the byteLoaded and totalBytes. _root.box._xscale = percentLoaded; //makes the _xscale of the box equal to the percentLoaded. 7)Now that should make your loadbar. Test your movie by hitting ctrl+enter and then go to view->show streaming. Then it will show your movie as it would stream at a certain speed. To change this speed goto debug and then pick your speed. PreLoader w/ text: Now this one will show you how to make a preloader with text boxes that tell you what percent is loaded and how many bytes are loaded. Even more to make your preloader spiffy. 1)Repeat the processes above, you can do a loadbar if you want although you'll still need the "percentLoaded = Math.floor((lBytes/tBytes)*100);" to make this work so hang on to that even if you don't do a loadBar. 2)Now, what you need to do is make a dynamic text box on your load screen. Leave it blank then give it an instance name "percent" 3)Go back into your actions panel and add this: _root.percent.text = percentLoaded+"% of "+lBytes+" K loaded"; //displays the percentLoaded variable with some text in the dynamic text box. 4)Now it should diplay something like this: "50% of 1234 K loaded" That's all fine and dandy but what if you want the person to be able to see for themselves how much is loaded. Well that's when you can throw in your lBytes variable: _root.percent.text = percentLoaded+"% "+Math.floor(lBytes/1024)+" /"+tBytes+" K loaded";//the same as before except this time we are puttin the bytes loaded over our bytes total. remember to put Math.floor because you don't want decimals in your preloader. I used simple math to put sure that the bytes loaded were converted into KiloBytes. Remember 1024 Bytes = 1 Kilobyte 5)It will display something like: "50% 1000/2000 K Loaded And you're done! Happy you! You made one kickass preloader! Now you can apply what you know about preloader and make even more options for your preloaders. You are only limited by your creativity now! -Back to
Top- Text Scroller: I'm gonna show you how to scroll a dynamic text field. 1)Make your dynamic text field on the main timeline or inside an MC or wherever you want to put it. Give it the instance name "textfield". If you decide to put it in an MC just change the targeting appropriately. Also, the way you want to populate your dynamic text box is with AS. Give the dynamic text box the var "text"(its in the property inspector when you select the dText box). Then on the first frame that your textbox appears on put this: text="your text that you want the dynamic text box to say" The another thing you want to make sure that your dynamic text box is set to multiLine for the line type(in property inspector) 2)Make your drawings of your up and down buttons. Then save them both as buttons and then save both of the buttons inside a movie clip. So you should have an MC with two buttons inside. 3)Now go edit you MC. On the first frame put this script: this.startScroll = function(active, type) { if (active) { this.type = type; this.onEnterFrame = function() { if (type == "up") { _root.textfield.scroll--; //Change last line to target your scroll object,(your dynamic text field). } else if (type == "down") { _root.textfield.scroll++; //same as before } }; } else { this.onEnterFrame = null; } }; 4)Now select your "up" button. Put these actions on it: on (press) { startScroll(true, "up"); } on (release, releaseOutside) { startScroll(false); } 5)Select your "down" button. Put these actions on it: on (press) { startScroll(true, "down"); } on (release, releaseOutside) { startScroll(false); } 6)And your done. Quite simple. *NOTE: That function was adapted from The Flash MX ActionScript Bible by Reinhardt and Lott. Copyright 2002. Scrolling a Movie Clip: What if what you want to scroll isn't text, what if its a picture or something similar. Well this script will do that for you. 1)Make your MC. Give it the instance name "content". Put it under a mask layer so that you only see what you want them to see at one time or you can leave it how it is, whatever your preference. 2)Make your buttons and put them in side an MC, just like for the text scroller. Now on your scrollbar MC put this code: onClipEvent(load){ scrollObj = _parent.content; upScroll = false; downScroll = false; } onClipEvent(enterFrame){ if(upScroll && scrollObj._y < scrollObj.startLimit){ scrollObj._y +=10; } else if (downScroll & scrollObj._y > scrollObj.endLimit){ scrollObj._y -=10; } } 3)Then edit your MC and put these actions on the "up" button: on (press) { upScroll = true; } on (release, releaseOutside) { upScroll = false; } 4)Put these on the "down" button: on (press) { downScroll = true; } on (release, releaseOutside) { downScroll = false; } 5)Now click on your "content" MC. Put these actions on it: onClipEvent(load){ maskHeight = 300; startLimit = this._y; endLimit = this._y - this._height + maskHeight; } 6)Now if you didn't make a mask layer than just define startLimit and endLimit as the points where you want the MC to start and where you want it to stop. 7)And you're done. *NOTE: That function was adapted from The Flash MX ActionScript Bible by Reinhardt and Lott. Copyright 2002. -Back to
Top- 1)Open a new flash document and make an MC. Whatever you want it to be, if you're just praticing make it something simple like a box or ball. 2)Now click on the MC and open the actions panel. Put in this code: onClipEvent (enterFrame) { if (Key.isDown(Key.RIGHT)) { this._x += 5; } if (Key.isDown(Key.LEFT)) { this._x -= 5; } if (Key.isDown(Key.DOWN)) { this._y += 5; } if (Key.isDown(Key.UP)) { this._y -= 5; } } This code makes the MC move if the a key is down(pressed). You define the key as Key.RIGHT or whichever. Then if the if statement is true it preforms the actions, which is it moves the oject in increments of five. Now, you can change those increments to whatever you want as long as you keep the format the same. Just remember the movement of this MC will vary depending on the FPS. Now just take that script and you can apply it to many many things. -Back to
Top- We are gonna just use that old script but this time we are going to add an && to the end of the if statement. Like so: onClipEvent (enterFrame) { if (Key.isDown(Key.LEFT) && this._x>170) { this._x -= 5; } if (Key.isDown(Key.RIGHT) && this._x<640) { this._x += 5; } if (Key.isDown(Key.DOWN) && this._y<375) { this._y += 5; } if (Key.isDown(Key.UP) && this._y>45) { this._y -= 5; } } That "&& this._y>45" makes it so that the if statement won't be executed if the object passes a certain x or y coordinate on the stage. Just change the values of those limits and you should be fine. You can apply that script to whatever you want, just by changing your limits. hitTest is a method that allows you to test to see if two MCs are touching or if an MC has crossed a certain point. This is very useful for collision detection, for say, between an enemy laser and your ship. First we'll talk about how to test for hits between two MCs. Two MCs: This is the basic syntax for a hitTest between two MCs: myMovieClip.hitTest(target) Its pretty self explanatory. Just put the name of one MC in for myMovieClip and then the name of the other where the "target" is. Then add some actions to it like. if(_root.Ship.hitTest(_root.laserfire)){ trace("THEY HIT!!!") } That will cause the output window to say "THEY HIT!!!" if the two MCs collide. Pretty simple, eh? An MC with a point: This is the basic syntax for an MC and a point in space. myMovieClip.hitTest(x, y, shapeFlag) Again just replace myMovieClip with the name of your movie clip but this time enter an x and y coordinates. Now for the shapeFlag. The shapeFlag is a boolean(true or false) that will tell flash whether to test for a hit with the bounding box of the MC or the contents. Put "true" if you want it to test a hit for the contents of the box and false if you want it to test for a hit with the boudning box. Add some actions to it: if(_root.ball.hitTest(300, 100, true)){ trace("The contents hit the point!") } -Back to
Top- Overview Dragging and Dropping a Button Why use this when I can use a movie clip? While dragging and dropping a movie clip is much more effective, this method is also commonly used. Some prefer it because you know you can interact with it once your cursor changes, as it does when over a button. How do I do it? First, make a button. Inside the button, you need the startDrag and stopDrag commands. So, right click your button and select "Actions". Inside your actions menu, put: on (press) { startDrag (); } on (release) { stopDrag (); } This makes it so that, when you press on the button, dragging starts. And when you release the button, dragging stops. Finally, select your button and make it into a movie clip (F8). That way, the startDrag command only applies to everything inside the movie clip. Notes Dragging and Dropping a Movie Clip What are the advantages of using this method? Although the scripting is more complex, it saves a lot more time. It is also easier to make animated draggable objects, since you are only working on one level. But really, it all comes down to the user's preference. How do I do it? First, make a movie clip. Select your movie clip, and right-click it. Select "Actions" from the menu. Inside your actions menu, put: onClipEvent (mouseDown) { if (this.hitTest(_root._xmouse, _root._ymouse)) { startDrag (this); } } onClipEvent (mouseUp) { stopDrag (); } This makes it so that, when the cursor is touching or overlapping the movie clip, and the mouse is pressed down, dragging starts. When the mouse is released, dragging stops. Now you are done. If you want to make your movie clip animated, edit it and add an animation on the timeline provided. What is a Tween? A tween is a transformation from one object to another, or a change of properties inbetween frames. Motion Tweens What is a "motion tween"? A motion tween is a change of properties of an object. Properties that can be changed include: _x positon, _y position, _xscale (width), _yscale (heigth), _alpha (transparency), brightness, tint, or rotation. How do I make a motion tween? There are two ways to make a tween. One way is to right-click on the frame in which you want the motion tween. Select "Create Motion Tween" at the top of the menu. Your frame should now appear blue. Make a new keyframe somewhere further down on the timeline. Change the properties of the object on the second keyframe. If you made it correctly, there should be an arrow connecting your two frames. Test your movie to see the results. In the second way, select the frame in which you want the motion tween. Select your properties menu at the bottom, and find "Tween:". Pull down the menu and select "Motion". Now, insert a new keyframe, and change the properties of the object on that keyframe. You can ease the object in or out by slecting the amount of easing you want. Easing out makes it slow down before coming to a stop. Easing in makes it speed up before stopping. Shape Tweens What is a "shape tween"? A shape tween is a change from one image to another. How do I make a shape tween? Select the frame in which you want your shape tween. Go to your properties menu, select "Tween:", and then select "Shape". Make a new keyframe further down on the timeline. Draw a new image. If you made it successfully, the frames will all be green, and an arrow will be connecting the two keyframes. Test your movie to see the results. Notes Applying the Tween Fading Make a motion tween. Set the alpha of the object being tweened to 100% on the beginning frame, and 0% on your ending frame. Moving a Character with a Tween Say you are making a walking animation. You have a character comprised of many different symbols. The way to do this is, tween every body part being used on a separate layer. After you have this done, you may want to make that sequence into a movie clip, so things don't get cluttered up. Scrolling Backgrounds Make a layer behind all of your other layers. Draw a background on that layer. Make a motion tween, and tween it left or right whenever needed. -Back to
Top- Overview Scrolling backgrounds play an essential part in platformer games, but can also be used in a variety of different Flash. Scrolling backgrounds can be simply an added effect to a movie, or a completely interactive background. Interactively Scrolling Backgrounds How does it work? All interactive scrolling backgrounds involve _x positions and/or _y positions. The concept mainly is: if this movie clip's _x(or _y) position is more than(or less than) or the same as #, tell the background movie clip to move along the _x(or _y) position by #. How do I do it? It isn't that easy, but it doesn't take a genious. Let's get started: 1) Make a movie clip for your "character", or item that you are going to control. 2) Add a basic movement script to your character: onClipEvent (load) { speed = 5; } onClipEvent (enterFrame) { if (Key.isDown(Key.RIGHT)) { this._x += speed; } else if (Key.isDown(Key.LEFT)) { this._x -= speed; } if (Key.isDown(Key.UP)) { this._y -= speed; } else if (Key.isDown(Key.DOWN)) { this._y += speed; } } You can modify how fast your character goes by changing the "speed" variable to a higher or lower number. 3) Make a movie clip for your background that is going to be scrolling. Place it behind your character (possibly on a lower level), and be sure to give it an instance name. 4) Time to add more script to our character. Add to your previous actions: onClipEvent (load) { rightLimit = 525; leftLimit = 25; bg = _root.movieClip; } onClipEvent (enterFrame) { if (Key.isDown(Key.RIGHT) && this._x >= rightLimit) { bg._x -= speed; this._x -= speed; } else if (Key.isDown(Key.LEFT) && this._x <= leftLimit) { bg._x += speed; this._x += speed; } } You can modify it to your liking by changing the variables. "rightLimit" controls what _x position your character needs to be at to make the background scroll to the right. "leftLimit" does the same, except it controls the left side. "bg" is simply the instance name of your background. You can change "movieClip" in "_root.movieClip" to whatever you labeled your background's instance name as. Freely Scrolling Backgrounds Why would I want to use this? This can add as a great effect in a lot of animations or games. It saves you the effort of animating, and is much more efficient. How does it work? This is much more simple than interactively scrolling background. The main concept is: If the timeline is currently on this frame, move the movie clip along the _x (or _y) postion by ##. And in some cases: If the movie clip goes past the boundaries, move it's _x (or _y) position to ##. How do I do it? This is much simpler than the last one. Just try it: 1) Make a movie clip that you will be using as your background. 2) Open up its actions and add: onClipEvent (load) { speed = 5; } onClipEvent (enterFrame) { this._x += speed; } Again, the speed can be modified. Just change the "speed" variable to a higher or lower number. 3 [optional]) This step is for if you want to make your background reset when it reaches a certain point. Open up your background actions again, and add: onClipEvent (load) { limit = 400; reset = -400; } onClipEvent (enterFrame) { if (this._x >= limit) { this._x = reset; } } "limit" controls what _x position the movie clip needs to be at in order for it to reset. "reset" controls what _x position it resets to. Notes Ever want to make a cool looking cursor for you flash movie? Well, its very simple and will a nice touch to your flash but i warn you to not go overboard with it. No one wants to see a flashing cursor throughout the whole movie, that will only pose as a distraction. But anyways, here's the howTo: 1)Make an MC that you want to be your cursor. give it the instance name "cursor". 2)Put these actions on your cursor: onClipEvent (mouseMove) { _root.updateCursor(); } onClipEvent (enterFrame) { Mouse.hide(); } 3)Now put these actions on the first frame where the cursor appears function updateCursor() { _root.cursor._x = _xmouse; _root.cursor._y = _ymouse; updateAfterEvent(); } 4)That's it! Easy right? -Back to
Top- on (keyPress "<Tab>") { this.tabEnabled = false; } See how that works? The fucntion "this.tabEnabled = false;" is only executed when the TAB key is pressed, disabling it for that button. So try it out and keep those cheaters from finding your secrets in your games! But what if you have buttons inside of MCs that you want to stay TAB-free? Instead of having to put this funtion on all of them you can just put this on the main MC: onClipEvent (load) { this.tabChildren = false; } Another very handy script is one that will disable ALL TAB functions for all your buttons. Very handy in some cases. It goes a little bit like this: _root._focusrect = false simple but powerful. This will make it so that NO button in the entire movie gets TAB recognition. Thanks to TheShrike and The_Super_Flash_Bros for bringing those scripts to my attention
-Back to
Top- What are variables? Naming your Variables firstName="joe" I gave that variable a name that i will remember. "joe" is someone's first
name so i gave my variable the name "firstName". Scope
Timeline Local var myVar="joe" That declares the variable myVar as "flash". But i didn't put that inside a function, did I? So that means that flash declares it just as it would a timeline variable. So local variables are only meant to be accesed inside of a function and when that function call ends, so does the variable. Remember, if you declare a local variable, it is not accessable from outside its scope. Meaning you can't pull the it up using a target path as you can with the timeline variables. Global _global.glVar=1 See how i had to put the _global identifier in front? Without that its just a normal timeline var. Also notice that i put "gl" in my var name. This is just another way to keep track of your variables and to keep your global variables separate from your other non-global variables. To read from global variables is the same as all others. But to write to them you have to identify them using _global.glVar. Example:
*Warning* Data Types
String myVar = "W i e r d F ormat ting" it would keep the formatting you gave it. *Note: you can define strings with ("") or (''). It doesn't matter. But you can't use both you have to use one or the other. If you say: myVar="joe' you'll get an error. Also, if you use apostraphes with single quotes you'll also get an error. Like: myVar='Joe's house' Flash confuses the apostraphe with the end quote. Then it doesnt' know what to do with the leftover so it gives you a nice error. So in this case double quotes would be what you'd use. Number myVar=1 That's it. It stores the number one as myVar. Then you can multiply things to it, subtract from it, add to it, it doesn't matter. Now remember, don't use quotes on these or else you'll get wierd results, like this: x = "10" You'll get "1011". See it added them together but not in a math sense. So if you're going to be doing math operations to your numbers, then leave them as numbers not strings. Boolean Those are both booleans. As you will see, booleans can either be true or false and that's it. Nothing more. They have lots of uses in AS if there can only be two conditions. Like on and off type things. Hmmmm....not much more here. Special Values x = null x as a string would output ("") while x as a number would output "0" and x as a boolean would equal false. This is useful if you're wanting to make a variable that you will define later. User input is an excellent example of when this would be used. Undefined myVar="joe" You'll get "undefined" in the output window. So when you get this make sure you're calling your variable from the right scope and that you haven't made any typos. -Back to
Top- What is the sound object? Constructing the Sound Object mySound = new Sound(); "mySound" is the name of the sound object you are creating and is what you will use when calling upon it later so remember to use descriptive naming as we discussed in the var and data type section. "new Sound()" is you telling flash that you are making a new sound. Attaching Sound to mySound mySound.attachSound("identifier") "identifier" is the song you are using. We won't ever actually put the sound onto any timeline. What we must do though is tell Flash to export that sound file because its necessary. So you must find the sound file in the library and right click it and select the "linkage" option. Select "export for ActionScript" and "export in first frame". You must now enter the "identifier" name in the linkage menu. This is how flash will know what sound file you are referring to. So when all is said and done you might have something like this: mySound.attachSound("NG1094") When you are entering the name in the "identifier" dialog box you don't need the quotes BUT you do need them when you are referring to it in the attachSound() method as I did. Playing the music! mySound.start(offset, loop) Both parameters are optional. The "offset" is where in the song you want the sound to start. The default is at the beginning. "Loop" is how many times you want the song to loop. The default is 1 time but even if you set it to 0 it will still play once through. Now that we know how to start the song we will learn to stop it using the stop command: mySound.stop("identifier") Same old stuff except you must enter the identifier of the song. This is the same identifier you use when you attached the sound. *Note: If left blank this will work just as the stopAllSounds() command would. Controlling the volume mySound.setVolume(#) "#" is a number between 0 and 100. 100 being full volume and 0 being no volume or "mute". getVolume() is a method that returns the current volume of the song. Useful when making a way to control the volume and display the current volume. Controlling Balance mySound.setPan(#) "#" is a number between -100 and 100 where -100 is only the left channel and
100 is only the right channel. 0 is both channels playing at 100%. Duration, Postition, and onSoundComplete duration position onSoundComplete() onClipEvent (enterFrame) { _global.mySound.onSoundComplete = function() { trace("songs done"); }; } That will trace "songs done" when the song is complete. Conclusion -Back to
Top- What are Movie Clip Properties? How to implement them _root.myMC._property = value The list!
These two properties control the x and y positions of the Movie Clip within the parent Movie Clip(or main stage if its not within a movie clip). Very simple to implement.
These two properties control the width and height of the Movie Clip in pixels.
These two properties control the x and y scale of the Movie Clip. This is in percent. If you use a negative percent it will flip the Movie Clip over. So if you said this._xscale=-100 it will make your movie clip look like a mirror image of itself.
This property controls the alpha value of the Movie Clip. Remember, the alpha value, when set at 0, is invisible and is completely visible at 100.
Activates or De-activates a button or movie clip. This is a boolean value so its either true or false. This will set the thing to be invisible or visible. But say you have a button with an on(press) command on it. This property will disable that so the person can't click it. Get it?
This property sets the rotation in degrees of the Movie Clip. So if you set it to 180 it will do a half turn. Or 90 it will do a quarter turn.
These properties are read-only. This means you can't set them but can only read them. It will return the value of either the x or y coordinates of the mouse.
This property will allow you to set the quality of the movie. It has 4 settings: LOW, MEDIUM, HIGH, BEST. To set the quality of the whole movie you can do this: _root._quality="HIGH"
This property can read-write the instance name value of a Movie clip.
This property returns the frame number at which the playhead is on at the time it is called. This can be useful if you want a movie clip to advance more than one frame everytime a button is clicked. Like so: _root.myMC.gotoAndStop(_root.myMC.currentframe+3) -Back to
Top- Stage.showMenu = false Put that on the first frame of your movie. And wallah! Like magic, the right-click menu is deminished to only the "settings" and "about flash player" tabs! One thing to keep in mind. If you use this on a movie that is very graphic intensive you may want to make a button to alter the quality since you can no longer do this from the right click menu. |
LAST UPDATED: 09/13/03 As of 06/27/03
Layout was created by Y3llow. |