Presentation is loading. Please wait.

Presentation is loading. Please wait.

CISC 110 Day 7 “The Outliers, Part1” hitTest(), Text Input, Frame and Timer Loops, Publishing Flash Content.

Similar presentations


Presentation on theme: "CISC 110 Day 7 “The Outliers, Part1” hitTest(), Text Input, Frame and Timer Loops, Publishing Flash Content."— Presentation transcript:

1 CISC 110 Day 7 “The Outliers, Part1” hitTest(), Text Input, Frame and Timer Loops, Publishing Flash Content

2 At this point in the course, you have already seen everything that you need to complete the course project Now we will begin to look at topical features and tools that provide advanced functionality

3 …Let’s reflect on that for a moment…

4 Outline keyCode to Character Conversion hitTest() Text Input Frame and Timer Loops Publishing Flash Content –Export to SWF –Export to EXE –Embed in HTML –FTP –Web Hosting 4

5 keyCode to Character Conversion var e:KeyboardEvent; … trace(e.keyCode); trace(String.fromCharCode(e.charCode)); Output for ‘g’: 71 g

6 hitTest movieClip1.hitTestObject(movieClip2) Returns “true” if movieClips are overlapping and “false” if they are not.

7 hitTest …many different hitTests are supported… e.g. myMovieClip.hitTest(x, y, shapeFlag) …check out the API (manual) online!

8 Input Text Fields How to create using ActionScript: var theTextField:TextField = new TextField(); theTextField.type = TextFieldType.INPUT; theTextField.border = true; theTextField.x = 10; theTextField.y = 10; theTextField.multiline = true; theTextField.wordWrap = true; addChild(theTextField); 8

9 Input Text Fields Without ActionScript: 1.Create an Input Text box (“Tools” Panel) 2.Assign an Instance Name 3.…now you can access it in ActionScript! 9

10 TextEvent // Add event listener for any key pressed stage.addEventListener (TextEvent.TEXT_INPUT, readMsg); function readMsg(evt: KeyboardEvent):void { // next line outputs most recent key pressed (as a character) trace(evt.text); } 10

11 FocusEvent FOCUS_IN occurs when user selects an object letterBox.addEventListener(FocusEvent.FOCUS_IN, blankOutText); function blankOutText(evt:FocusEvent):void { msgBox.text = " "; } 11

12 FocusEvent FOCUS_OUT occurs when an objects is deselected: i.e. click anywhere outside of the object with mouse letterBox.addEventListener(FocusEvent.FOCUS_OUT, readMsg); function readMsg(evt:FocusEvent):void { trace(msgBox.text); } 12

13 Frame and Timer Loops Sometimes we want to repeat something while continuing the rest of the animation, e.g., checking if we’ve hit a monster. For this, we can use frame and timer loops. 13

14 Frame Loop We can create a frame loop by listening for an enter frame event, which is “fired” as each frame is played (i.e. at the same frame rate as the timeline) stage.addEventListener(Event.ENTER_FRAME, fadeMC); function fadeMC(evt: Event):void {if(square.alpha > 0) { square.alpha = square.alpha – 1; } } 14

15 Timer Loop We can create a timer loop by creating a Timer object, which fires every specified number of ms. var timer: Timer = new Timer(1000); // 1 second timer.addEventListener(TimerEvent.TIMER, fadeMC); timer.start(); function fadeMC(evt: TimerEvent):void {if(square.alpha > 0) { square.alpha = square.alpha – 1; } } 15

16 Publishing Flash Content Export to SWF Export to EXE (“Create Projector…”) Embed in HTML –File, Publish Preview, HTML –File, Publish Settings –File, Publish

17 FTP File Transfer Protocol (FTP) –Designed for uploading files to servers

18 Web Hosting Comes in “all shapes and sizes” –Inexpensive options: Hostrocket.com 1and1.com

19 USAT


Download ppt "CISC 110 Day 7 “The Outliers, Part1” hitTest(), Text Input, Frame and Timer Loops, Publishing Flash Content."

Similar presentations


Ads by Google