ARTDM 170 Week 8: Scripting Interactivity


Published on

Published in: Education
  • Be the first to comment

  • Be the first to like this

ARTDM 170 Week 8: Scripting Interactivity

  1. 1. ARTDM 170, Week 8: Scripting Interactivity<br />Gilbert<br />
  2. 2. Homework<br />Please put your .swf file in a folder with your last name and first initial<br />Put the folder in my dropbox<br />Example: smith-hmyAnimation.swf<br />
  3. 3. Open Flash<br />Create a new ActionScript 3.0 document:MyObject.fla<br />Create a new ActionScript<br />
  4. 4. Frame by Frame Animation<br />
  5. 5. Frame by Frame<br />Create a new Movie Clip symbol<br />Add keyframes for each new frame of the animation<br />Drag the animation to the stage and test your movie<br />
  6. 6. Using Objects on the Stage<br />
  7. 7. Adding Objects<br />Drag an instance of a symbol to the stage<br />Name the instance: myObject<br />Now you have an object that you can refer to in your code:myObject.x = 100;<br />
  8. 8. Dragging Objects<br />
  9. 9. Dragging<br />Use functions to both start and stop the dragging as well as to add new event listeners:<br />private function startDragging(event:MouseEvent) {stage.addEventListener(MouseEvent.MOUSE_UP, stopDragging);myCircle.startDrag();}private function stopDragging(event:MouseEvent) {stage.removeEventListener(MouseEvent.MOUSE_UP, stopDragging);myCircle.stopDrag();}<br />The event listeners are added to the stage just in case the user moves around too quickly or somehow is not on the object when clicking or releasing the mouse.<br />
  10. 10. Throwing Objects<br />
  11. 11. Throwing Velocity<br />To throw an object you want to make sure the values for velocity (moveX and moveY) are updated according to the where the user has moved the object and it’s change in location over time.<br />private function trackVelocity(event:Event):void {<br /> moveX = myCircle.x - oldX;<br /> moveY = myCircle.y - oldY;<br /> oldX = myCircle.x;<br /> oldY = myCircle.y;<br />}<br />
  12. 12. Homework, due Oct 14<br />Create a Title and Description for your final project<br />Create a new frame by frame animation<br />Move your animation using scripts<br />