Monday, May 7, 2012

Flash: Screen Saver (Programming I)

We will be using these actions for the project today:

/* ------------ Actions for Frame #1 ------------ */

/* Set Speed */
speed = 1.5;
movex = speed;
movey = speed;

/* Set Borders */
left = 110;
top = 130;
right = 904;
bottom = 648;

/* Randomly place object -- sw & sh are stage width & height */
sw = 1024;
sh = 768;
xpos = random(sw)+1;
ypos = random(sh)+1;

/* ------------ Actions for Frame #2  ------------ */

/* Place ball on the screen at x1,y1 */
setProperty ("ball", _x, xpos);
setProperty ("ball", _y, ypos);

/* Move object by adding/subtracting xm,ym */
xpos = xpos + movex;
ypos = ypos + movey;

/* Adjust direction if we hit an edge */
if (xpos > right){ movex = speed * -1 }
if (xpos < left) { movex = speed  }
if (ypos > bottom){ movey = speed * -1 }
if (ypos < top) { movey = speed  }

/* ------------ Actions for Frame #3 ------------ */
gotoAndPlay(2);

No comments:

Post a Comment

REMEMBER:

•  Add your name to your projects
•  Save Photoshop projects as PSD and JPG
•  Save Bryce projects as BR7 and [Save Image As] JPG
•  Save Sculptris projects as SC1 and JPG and export it as an OBJ.
•  Save Rhino projects as 3DM and JPG
•  Save Flash projects as FLA and go to FILE>PUBLISH SETTINGS and publish as SWF and JPG
•  Upload finished projects to your portfolio and/or your DeviantArt page
•  Keep checking your grade on PowerSchool