Unfortunately, there is no simple way to play a sound. You will have to import the sound, write several lines of code, and then write several more lines of code to play the sound in anything but the standard way.
Linking and Playing Sounds
The first thing you need to do before playing a sound with ActionScript is to link it. Import the sound into the Library, select Linkage from the Library panel’s menu, and set the sound to export with the movie. You can also assign a different linkage name to the sound, but Flash starts you off with the same name as the Library element, which is the same name as the file.
If you are working with a movie that has a lot of sound, it is a good idea to set the default sound compression to Raw in the Publish Settings. When you test your movie, Flash will not take the time to compress the sound. This way, you can test your movie as quickly as possible. Then, change the default sound compression setting to what you really want before publishing a copy for the Web.
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
How do you link a scrollbar to a text field?
A3: Drag it onto the text field.
4: Which component allows the user to type in a text response?
A4: You can set the Editable parameter of a combo box to true, which allows the user to type in a response as well as select one from the pull-down menu.
Hour 22. Controlling Sound with ActionScript
There are two ways to add sound to Flash movies. The first is to lay it into the timeline. This doesn’t require ActionScript. Another way is to use ActionScript to trigger sounds stored in the Library.
In this hour, you will:
Find out how to access sounds with ActionScript
Learn how to control sound balance
Use sound properties to monitor a sound
Build an ActionScript beat box
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
The quiz questions are designed to test your knowledge of the material covered in this hour. The answers to the questions follow.
Quiz
1: Which components can be used to allow the user to make an exclusive choice?
A1: Radio buttons, combo boxes, and list boxes. Technically, push buttons also allow you to make a single choice, but they also usually perform some other task.
2: Which components can be used to allow the user to make a nonexclusive choice?
Check boxes and list boxes. List boxes can be set to allow only one item to be selected at a time, or they can be set to allow multiple items to be selected at one time.
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
Can I use the ScrollBar component on something besides text fields?
A2: Yes. In fact, the ListBox and ComboBox components use it. If you are an expert ActionScript programmer, you can read the documentation to find out how to access the properties of the ScrollBar so that you can use it in other ways.
Q3: Can I use the scroll pane to show an image rather than a movie clip?
A3: Yes and no. The scroll pane shows only movie clips. But that doesn’t stop you from making a movie clip that contains an image. In fact, that is how you should work things if you want to build an image browser. Some programs, such as Macromedia Fireworks, allow you to save images as Flash files. These can then be read in using loadScrollContent.
Q4: So how can I customize components even more?
A4: You don’t even need ActionScript for this. But you do need to check out the documentation about how to alter and create component skins
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
You can change the style of components using ActionScript. You can either change all the components, a group of components, or just one component. Use this capability to customize your components so that they don’t look like everyone else’s.
Q&A
Q1: When should I use components instead of my own interface movie clips?
A1: Use components when time is short or you are not sure that your ActionScript abilities will allow you to get the results you want. However, components will never be as easy to customize as your own movie clips. In addition, components tend to slow down your movies. If reaction time is important, you will want to make your own components that are optimized to perform exactly as you need.
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
Dodge branded car is a best mate to accompany and drive you wherever you want. Therefore it deserves for your best treatment. It is important to pay attention on its machinery conditions and its appearance. Having both good machine condition and marvelous appearance is the primary requirement to decide whether your car is fabulous or not. To make your car looks gorgeous, you should give adequate touch by putting some accessories in both inside or outside your car.
Carid.com which is one of the greatest car accessories distributors provides complete high quality auto accessories for Dodge automobiles and others. All of those accessories are displayed on its website. There are various Dodge accessories available on the website, such as dash kits, billets grilles, floor mats, chrome accessories, spoilers, headlights, tail lights, custom wheels, body kits, and other auto accessories are presented on Carid.com. Those accessories presented by Carid.com are not only applied for style and beauty, but they have certain function to support the safety and comfort for your car.
All Dodge accessories offered on Carid.com will give you idea of better driving that you should experience. Do not wait any longer to visit the website and get twenty percents discount for every purchase you make.
You can also set any one of the style attributes for a component directly. However, you can’t do it using nice and neat dot syntax like you would expect. Instead, you need to use the setStyleProperty command. This takes the style property as a string in the first parameter and the value you want to set it to as the second parameter.
So using these three methods of setting component styles, you can customize your components to your heart’s content.
Summary
Components are complex movie clips built in to Flash. They re-create some common user interface elements such as check boxes, radio buttons, pushbuttons, pull-down menus, and scrollbars.
When you add a component to your movie, you need to set various parameters of the component. Most components have an ActionScript callback function that is triggered when the component is used. You can also access the state of a component at any time.
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
Although the globalStyleFormat object is used by all the components on the stage, you can create your own style objects that can be used by one or more components that you specify.
You do this by creating an FStyleFormat object. When you do this, your new object has the same set of properties as the globalStyleFormat object.
Any style elements that are not explicitly set are just not included in the style object. So when you apply this style to a component, that aspect of its style will not change.
To apply the style to a component, use the addListener command:
If this seems like an odd use for addListener, you are right. But think of it like this: You are telling the component to listen to the style object.
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
Flash’s components have a nice look to them. But if all Flash developers start using them, soon all our Flash movies will look alike.
Fortunately, you can customize the components in many different ways. You can even create custom skins for them. Let’s take a look at three ways to customize components using ActionScript.
Global Customization
Using the globalStyleFormat object, you can customize the look of all your components at once. Here is an example that changes the text color of all text in all components to blue:
You can change much more than just the font. The number of style items is too long to list here. You can change the color and style of checks in CheckBoxes, circles in RadioButtons, arrows in ScrollBars, background colors, highlight colors, selection colors, and so on. Check any of the various Flash help systems to see a complete list.
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
The PushButton component calls buttonPressed. Let’s build this function piece by piece to process each of the sections of the form.
The function starts off by creating a new array. It then checks each check box to see whether its getValue() function is true. If it is, the label from that check box is added to that array. When this loop is finished, the array own contains any user selections made with the check boxes.
To check the multiple selections of the list box, you will need to loop through the array returned by getSelectedItems(). You then need to examine the label property of each item.
If you were building this for actual use, you would probably do something more constructive than using trace commands. For instance, you could make a LoadVars object that then gets submitted to the server.
Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours
Recent Comments