Graphics Programs Reference
In-Depth Information
40
41
42
43
44
45
46
47
48
49
50
51
52
53
sxUp_btn.onPress = function() { sx = 1.05; }
sxUp_btn.onRelease = function() { sx = 1; }
sxDn_btn.onPress = function() { sx = 0.95; }
sxDn_btn.onRelease = function() { sx = 1; }
syUp_btn.onPress = function() { sy = 1.05; }
syUp_btn.onRelease = function() { sy = 1; }
syDn_btn.onPress = function() { sy = 0.95; }
syDn_btn.onRelease = function() { sy = 1; }
szUp_btn.onPress = function() { sz = 1.05; }
szUp_btn.onRelease = function() { sz = 1; }
szDn_btn.onPress = function() { sz = 0.95; }
szDn_btn.onRelease = function() { sz = 1; }
values. We are familiar with this in real life. If we know the size of an object and we
want to make it twice as big, we multiply the size by 2. Similarly, if we know the size
of an object and we want to make it one quarter of the original size, we divide by 4,
or equivalently, multiply by 0.25. The numbers we are using to scale up and down are
only a little greater than 1 or a little less than 1, but you will discover that objects grow
and shrink quite rapidly with the values used.
As you can see by the length of the button script, our scripts in this chapter will be long-
er than in previous chapters. Since we will be using this script in all of our examples
and exercises, we are saving it as an ActionScript file named 3Dbuttons.as that we will
include at the beginning of each of our remaining scripts. This modular approach makes
it easy to reuse scripts and cuts down on development time and effort for new projects.
Simple Planar Object
Let's begin our journey into full 3D by starting off with a simple planar object. Although
it is only a simple 2D object, by the time we're done, we'll have something that's fun
to interact with. We need to define our object. This can be sketched out on a napkin or
plotted out as shown in Figure 9.3. Also, programmers might choose to develop a sepa-
rate utility program that plots and stores points.
Since we are using a planar object, we only need to worry about horizontal and vertical
coordinates, but we need some way of getting them into Flash. A number of options are
available, from hard-coding them into the program we are going to create, to loading
Search WWH ::




Custom Search