If you use the line size of 0, you get a hairline. A hairline is a thin line that remains 1 pixel wide even if the line is scaled up. This is in contrast to a 1-pixel line that gets thicker as the scale of the movie increases.

After you have set the line style, you use lineTo and moveTo to draw. Imagine an invisible pen on the screen. You can direct its tip to move around on the screen. As it moves, you can tell it to draw on the screen, or just move without drawing.

The moveTo command moves the tip of the drawing pen to a location on the screen. The lineTo command moves the pen from its current location to another location and leaves a trail. Here is some code that draws a line from 275,200 to 300,225:

If you do not use a moveTo command before you use a lineTo command, the first line will be drawn from point 0,0 to the point specified in the lineTo command.

Check out the example movie 24lines.fla. You can play with the line size, color, and alpha. When you set the alpha to 50, it gives the impression that the lines are laying on top of and under each other. Check out 24coloredlines.fla to see a variation where the lines all draw as different colors.

Here is a simple script that draws a crossed pattern on the screen. It creates diagonal lines in each direction all the way across the screen.

Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours

Comments No Comments »

A new feature in Flash MX is the capability for ActionScript to draw lines, curves, and fills; create new, empty movie clips; and create new text fields. With this capability, you can start with an empty movie and populate it with elements.

In this hour, you will:

Learn how to draw lines and curves

Learn how to draw filled areas

Let the user draw with the mouse

Place drawn items into new movie clips

Create new text fields

Drawing Lines
Flash MX contains a simple set of drawing commands that allow you to create a wide variety of graphics from scratch. You can draw straight lines, curves, and even filled areas.

Drawing Straight Lines
Drawing a line with ActionScript is easy. First, you need to define the line style. The lineStyle command takes three parameters: the line thickness, color, and alpha. The color is expressed as an ActionScript hexadecimal number. So 0×000000 is black, 0xFFFFFF is white, and so on. The alpha parameter determines a line’s transparency. A value of 100 makes an opaque line, whereas a value of 50 makes a line that is faded 50 percent, and graphics behind it can be seen.

Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours

Comments No Comments »

What file formats must you use for sounds and images to load them dynamically?

A3: Sounds need to be MP3 files, and images need to be JPEG files. However, another way to do it is that you can load either if it is in an external movie file.

4: Using getBytesTotal and getBytesLoaded, how do you determine the percentage of the movie loaded?

A4: If you divide getBytesTotal by getBytesLoaded, you will get a value from 0.0 to 1.0. If you want to display a percentage, you need to multiply this number by 100. You may also want to use Math.round() to convert this to an integer instead of a long floating point number

Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours

Comments No Comments »

The quiz questions are designed to test your knowledge of the material covered in this hour. The answers to the questions follow.

Quiz
1: How much of a Flash movie normally needs to load before it starts?

A1: Only the media for the first frame is needed for the first frame to be displayed and the movie to begin. You’ll need to stop the movie there if you want to wait for more before continuing.

2: What are two ways to determine whether a movie is completely loaded?

A2: One way is when the getBytesLoaded equals the getBytesTotal function. Another method is to check the _frameLoaded property and compare it to the _totalFrames property.

Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours

Comments No Comments »

You can also report to the user the progress of the loading. You can give them straight text feedback, or something a little more visual like a progress bar.

You can also divide your movie into several files and use loadMovie to jump from file to file as the user needs the content.

External files can be loaded into your movie using various methods. You can load Flash movies as movie clips. You can load external JPEG files and MP3 sounds too.

Q&A
Q1: You can load movies into movie clips, but can you unload them too?

A1: Yes. The unloadMovie command removes a loaded movie from a movie clip instance.

Q2: Can I report the file size of a streaming movie to a user in K?

A2: A K is a kilobyte, which represents 1,024 bytes. So you can use getBytesTotal and getBytesLoaded to get the number of bytes and then divide that by 1,024 to determine the amount of K that will be loaded. A meg, or megabyte, is 1,024K, or 1,048,576 bytes.

Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours

Comments No Comments »

Now you do not have to drive to any accessories store to buy some accessories for your car. Simply, you only have to sit in front of your computer and begin surfing to find the fine online car accessories shops. You will be very lucky once you find Carid.com. Carid.com is a superior car accessories seller with complete collections of any automobile brands. You can access this website everyday up to midnight.  This website also open live chat with any customer who need information about its products. Besides, there  is also a contact line on you can get through.

Carid.com offers you low pricing with twenty percent discount for each product. There are various accessories from various brands of car available in its online shop. The product from Dodge automobiles is one of them. You can find complete accessories produced by Dodge automobiles on the catalog presented by the website such as dodge dash kit, dodge steering wheel, dodge grills, dodge chrome, dodge spoilers, lambo doors, and grill guard. Dodge accessories sold on the shop are originally produce by Dodge company.

Now let’s stop your browsing on Carid.com and get detail information about any car accessories you need, and get twenty percents discount by buying the products.

Comments No Comments »

Notice that you don’t need the start command with a streaming sound. However, you do need to pay careful attention to how you make the MP3 file. For instance, if you use the 128Kbps or 160Kbps setting that is popular for playing MP3 music, it will be too large of a file to stream over the Internet, especially if the user has a modem. 32Kbps or less will give the stream a chance to work successfully.

Summary

Streaming is a great way to ease the user into a large Flash movie. You can use ActionScript to track the loading process. As a movie streams, you can hold the movie on the first frame and then let it continue when the entire movie has loaded.

Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours

Comments No Comments »

Here is an example of the first method, which plays an event sound. This means that the entire sound is loaded into memory first and then played if a start command is issued.

Flash remembers that the start command was issued, even though the sound has just begun to download. When the sound is finished downloading, it plays immediately.

The second method uses a true in the second parameter. This tells Flash to stream the sound in. As soon as some of the sound has been loaded, the sound starts playing. The sound continues as the rest is loaded. If the user’s connection is a good one, the user will hear the entire sound as it loads.

Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours

Comments No Comments »

Flash MX has an new capability that developers have been begging Macromedia for since they bought Flash; it can import an external JPEG file.

The way you do this is simple. Just use the a loadMovie command like you are planning to replace a movie clip with an external Flash movie. However, give the location of a JPEG file instead:

myMovieClip.loadMovie(”picture.jpg”);

The movie clip is now replaced by a movie clip that holds that bitmap image. Check out the movie 23loadjpeg.fla for an example.

Loading a Sound
There are also two ways to play a sound from an external file. They both use the sound object and the loadSound command. The sound file needs to be in the popular MP3 format.

Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours

Comments No Comments »

When using loadMovie, you can use the getBytesTotal and getBytesLoaded functions to check the progress of the load. This means that you can report the progress to the user with text or even a progress bar like the one used earlier in this hour.

If you want to preload a movie clip to have it ready before the user even gets to a place where it is needed, you can set up the external movie so that nothing is on the first frame but a stop() command. Then load the movie into a blank movie clip that is off the stage. When it completes, the movie just sits there on its blank first frame.

However, the movie file will be sitting in the user’s browser cache. Now when it comes time to really use the movie clip, do the loadMovie command again. The movie will be there quickly because the file has already been downloaded. Then issue a gotoAndPlay(2) command to get it past that first frame.

Taken From: Sams Teach Yourself Flash™ MX ActionScript in 24 Hours

Comments No Comments »

  • Partner links