Browse DevX
Sign up for e-mail newsletters from DevX


Powerful Printing in Flash : Page 2

Use Flash's robust printing support to add print functionality to your Flash movies or Web applications. By using off-screen movie clips and ActionScripts movie clip copying commands, effective printouts can be assembled on the fly.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Your Sample Flash Movie
Imagine a hypothetical situation: the client, an art museum, needs a simple drawing program in Flash for their Web site to promote a new art exhibit. They want to reach kids, and the Flash movie is supposed to increase interest in visiting the exhibit by allowing them to create their own artwork (perhaps in the style of the coming exhibit). The client also requires the following:
  • The movie must allow the user to print the drawings, so that the printout can be used as a free pass for kids to the exhibit.
  • The printout must contain info on the exhibit (name, hours, etc.), as well as the date the printout was made.
Figure 1 shows the main interface for the Flash movie.

Figure 1: Main Movie Interface. The movie clip where drawing will take place has been outlined to make it visible.

This sample Flash movie is the beginning of a small drawing program; it allows users to select one of 3 colors, as well as a tool to draw with (currently, only a circle). When users click on the drawing area, the movie places a circle at the clicked point in the selected color. The drawing area is actually its own movie clip, called drawingArea, and has been outlined to make it visible during development.

The ActionScript code to implement the drawing is as follows:

circleCount = 0; drawingArea.onPress = function() { // make a copy of the circle movie, and name it circle plus // its sequence number appended as a suffix (i.e. circle0, // circle1, etc.) and place it on the clip drawingArea clip drawingArea.attachMovie("circle","circle" + circleCount,circleCount); // get a reference to this new clip var circleClip = eval("drawingArea.circle" + circleCount); // move the new clip to where the mouse was clicked circleClip._x = drawingArea._xmouse; circleClip._y = drawingArea._ymouse; // set color of the new clip based on the value checked in the // colorGroup radio button group var clipColor = new Color(circleClip); switch (colorGroup.getValue()) { case "red": clipColor.setRGB(0xff0000); break case "green": clipColor.setRGB(0x00ff00); break; case "blue": clipColor.setRGB(0x0000ff); break; } // increment the total number of circles circleCount++; };

Now, when users click the drawing area, a new circle of the selected color appears. Notice that the mouse clicks relative to the drawingArea movie clip (drawingArea._xmouse and drawingArea._ymouse), not to the main, or _root, clip. When you move the new circle clip, you do so relative to the clip that contains it, namely the drawingArea clip.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date