Event Handling in flash Event: is an instantaneous occurrence usually triggered by user. هو احداث تقع فورا وتطلق عادة باستخدام المستخدم Event: is an instantaneous.

Slides:



Advertisements
Similar presentations
Flash MovieClip Symbols Movieclip symbols are reusable pieces of flash animation هي قطع من حركات الفلاش يعاد استخدامها عدة مرات Movieclip symbols are reusable.
Advertisements

Arrays in Flash What is an Array: What is an Array: Array is a list of cells, each cell in the list has a number to identify it (index or position). هي
Computer and Communication Fundamental Basic web programming Lecture 8 Rina Zviel-Girshin.
JavaScript and the DOM Les Carr COMP3001 Les Carr COMP3001.
NumericStepper Component You can use the numeric stepper anywhere you want a user to select a numeric value. You can use the numeric stepper anywhere you.
Macromedia Flash MX 2004 – Design Professional and Interactivity WORKING WITH SYMBOLS.
Event Handling Events and Listeners Timers and Animation.
1 Flash Actionscript Event Handling. 2 Event Handling Right now we know all about variables lets go back to our text input/output example: Suppose we.
Flash Workshop Flash Workshop :: Agenda  Introductions  Look at a few Flash Examples  Flash Web Sites  Flash Web Applications  Flash Games.
© Anselm Spoerri Lecture 12 Flash –Done So Far and Build Upon It –Create Function –Create “Button” using ActionScript –Name Keyframes –Create “Disjointed.
Work with symbols and instances Work with Libraries Create buttons Assign actions to buttons Unit Lessons.
Kapi’olani Community College Art 258 Interface Programming II In-class Presentation Week 5A.
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
Chapter 3 Working with Symbols and Interactivity.
XP Tutorial 5 Buttons, Behaviors, and Sounds. XP New Perspectives on Macromedia Flash MX Buttons Interactive means that the user has some level.
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
© 2011 Delmar, Cengage Learning Chapter 3 Working with Symbols and Interactivity.
© 2010 Delmar, Cengage Learning Chapter 3: Working with Symbols and Interactivity.
Getting a handle on ActionScript A basic primer for non-programmers.
Frame Part of timeline panel You can remove normal frames from a certain layer by (MRC + Remove Frames). يمكنك ازالة الاطر العادية من طبقة معينة باستخدام.
Lab 6: event & input intro User Interface Lab: GUI Lab Oct. 2 nd, 2013.
Adobe Flash CS3 Revealed Chapter 3 - WORKING WITH SYMBOLS AND INTERACTIVITY.
Creating Scenes A scene in flash contains one or more layers that show related objects, in the stage, that act and interact to deliver a certain idea.
Motion Tweening – Lesson 81 Motion Tweening Lesson 8.
Mouse Events & Keyboard Inputs Flash ActionScript Introduction to Thomas Lövgren
Lecture 10 JavaScript: DOM and Dynamic HTML Boriana Koleva Room: C54
Event JavaScript's interaction with HTML is handled through events that occur when the user or browser manipulates a page. When the page loads, that is.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.
© Anselm Spoerri Lecture 10 – Related: Part 1 Flash –Build Flash Website with Animated Navigation Structure –Decide on Overall Navigation Layout, Import.
Building the Events Components– Lesson 111 Building the Events Components Lesson 11.
Object Oriented Programming.  Interface  Event Handling.
Macromedia Flash 8 Revealed WORKING WITH SYMBOLS AND INTERACTIVITY.
Macromedia Flash Design Professional And Interactivity WORKING WITH SYMBOLS.
1 Actionscript for Flash by Dr SC Li. 2 Understanding more about instances Symbolsgraphics buttons Movie clips Instances (without names) No interaction.
Event Handling. Objectives Using event handlers Simulating events Using event-related methods.
COS 125 DAY 20. Agenda Assignment 8 not corrected yet Assignment 9 posted  Due April 16 New course time line Discussion on Scripts 
SCRIPT PROGRAMMING WITH FLASH Introductory Level 1.
JavaScript Functions A function is a block of code that can be reused. It is similar to a method in Java. It consists of a function name, an argument.
Dr.Al-Mothana Gasaymeh. Mask layers تظهر ما تحت objects التي عليها كيفية عملها : كبسة يمين على الطبقة و اختيار Mask.
7. JavaScript Events. 2 Motto: Do you think I can listen all day to such stuff? –Lewis Carroll.
Computer Vocabulary Computer
Dr.Al-Mothana Gasaymeh. Buttons تسخدم لخلق تفاعل بين المستخدم و البرنامج دائما ضع الازرار في طبقة مستقلة.
Open a new Flash File Action Script 2.0. Create a button like you did last lesson and name it Click to Play.
JavaScript Events.
LESSON : EVENTS AND FORM VALIDATION -JAVASCRIPT. EVENTS CLICK.
Intro to ActionScript CIS 126 Greg Shorts. What Is ActionScript? ActionScript is the scripting language Flash uses to control its movies and the objects.
CGS 3066: Web Programming and Design Spring 2016 Programming in JavaScript.
Copyright © 2003 Pearson Education, Inc. Chapter 4 – Slide 1 by Michael Kay The Web Wizard’s Guide to Flash.
Motion Tween Motion Tween allow us to move a shape on the stage from one place to another. تسمح بحركة الشكل من مكان الى اخر Motion Tween allow us to move.
NumericStepper Component You can use the numeric stepper anywhere you want a user to select a numeric value. You can use the numeric stepper anywhere you.
Primitive Data Types 2. Boolean Data Type: It is used in logical operations to represent a certain state. هو يستخدم في العمليات المنطقية لتمثيل دالة معينة.
Integrating Components and Dynamic Text Boxes with the Animated Map– Lesson 101 Integrating Components and Dynamic Text Boxes with the Animated Map Lesson.
Introduction to JavaScript Events Instructor: Sergey Goldman 1.
Macromedia Flash MX Design Professional And Interactivity WORKING WITH SYMBOLS.
Event Driven (Asynchronous) Programming. Event handling in Unity Subclass a class that contains event handling methods, and then override those methods.
 Movieclip symbols are reusable pieces of flash animation  consisting usually of one or more graphic/button symbols  thus they are flash movies within.
SE-2840 Dr. Mark L. Hornick 1 Dynamic HTML Handling events from DOM objects.
THE DOM.
Events and Event Handling
var variableName:datatype;
ActionScript Basics 2016 (2.0 – 3.0)
Introduction to JavaScript Events
Flash Demonstration – Unit 5 – ActionScript 2.0
Event Driven Programming
JavaScript Events.
Interface Programming 2 Week 1
الأحــداث events الوينــدوز هــو محــيط رســائلي يــتم إرســال رســالة عنــد حــدوث حــدث مثــل مــرور الماوس فوق صورة أو فوق زر معين أو التركيز على نافذة.
Working with Symbols and Interactivity
MovieCLip Instances & ActionScript
Flash Demonstration – Unit 5
Presentation transcript:

Event Handling in flash Event: is an instantaneous occurrence usually triggered by user. هو احداث تقع فورا وتطلق عادة باستخدام المستخدم Event: is an instantaneous occurrence usually triggered by user. هو احداث تقع فورا وتطلق عادة باستخدام المستخدم Ex) clicking a button, moving mouse, clicking on a mouse Ex) clicking a button, moving mouse, clicking on a mouse Event Handling: writing action script that will be executed when the event occurs. هو كتابة الاكشن الذي سينفذ عند وقوع الحدث Event Handling: writing action script that will be executed when the event occurs. هو كتابة الاكشن الذي سينفذ عند وقوع الحدث Events can be handled by using Callback يمكن التعامل مع الحدث من خلال استدعاءه Events can be handled by using Callback يمكن التعامل مع الحدث من خلال استدعاءه Callback: function tied directly to a particular event. اقتران مربوط مباشرة مع حدث معين Callback: function tied directly to a particular event. اقتران مربوط مباشرة مع حدث معين

Event Handling in flash Ex) onEnterFrame = function() Ex) onEnterFrame = function(){ …. } Event handling examples: Event handling examples: 1. Handling button events: onPress: the event is triggered when a button is pressed. الحدث سيطلق عندما يكون الزر مضغوط onPress: the event is triggered when a button is pressed. الحدث سيطلق عندما يكون الزر مضغوط ex) btn.onPress = function() ex) btn.onPress = function() { …. } Code written inside function is tied to the event (onEnterFrame) الكود المكتوب داخل الاقتران مربوط مع الحدث Code written here will be executed when (btn) is pressed This callback function is written in the first frame btn: is the instance name of a button

Event Handling in flash onRelease: The event is triggered when a button is released after being pressed. الحدث سيطلق عند بعد الضغط ( أي بعد مانضغط على الزر onRelease: The event is triggered when a button is released after being pressed. الحدث سيطلق عند بعد الضغط ( أي بعد مانضغط على الزر ex) btn.onRelease = function() { … } ex) btn.onRelease = function() { … } onRollOver: The event is triggered when the mouse cursor moves over a button. الحدث سيطلق عند ما يكون مؤشر الماوس يتحرك فوق الزر onRollOver: The event is triggered when the mouse cursor moves over a button. الحدث سيطلق عند ما يكون مؤشر الماوس يتحرك فوق الزر Ex) btn.onRollOver = function() { … } Ex) btn.onRollOver = function() { … } 2. Handling mouse events: onMouseDown: it is triggered whenever the mouse button is pressed anywhere in the stage ex) onMouseDown = function() {} الحدث سيطلق عندما يضغط زرالماوس في أي مكان على المسرح onMouseDown: it is triggered whenever the mouse button is pressed anywhere in the stage ex) onMouseDown = function() {} الحدث سيطلق عندما يضغط زرالماوس في أي مكان على المسرح

Event Handling in flash onMouseUp: it is triggered whenever the mouse button is released after being pressed onMouseUp: it is triggered whenever the mouse button is released after being pressed ex) onMouseUp=function() {…} onMouseMove: it is triggered whenever the mouse cursor moves over a component الحدث سيطلق كلما تحرك مؤشر الماوس فوق عنصر onMouseMove: it is triggered whenever the mouse cursor moves over a component الحدث سيطلق كلما تحرك مؤشر الماوس فوق عنصر ex) onMouseOver=function() {…}

Mouse Events Application Ex) This example shows how to drag a movie clip symbol from place to another using mouse events. Ex) This example shows how to drag a movie clip symbol from place to another using mouse events. 1. Create a new flash document 2. Insert a movie clip symbol onto the stage 3. Give it an instance name (m_shape) 4. In the action panel of the first frame: Declare a number variable (i) and initialize it to zero Declare a number variable (i) and initialize it to zero Add a (onMouseDown) handler that assigns one to (i) Add a (onMouseDown) handler that assigns one to (i)

Mouse Events Application Add a (onMouseMove) handler and insert the following code into it: Add a (onMouseMove) handler and insert the following code into it:if(i==1){m_shape._x=_xmouse;m_shape._y=_ymouse;} Add a (onMouseUp) handler that assigns zero to (i) Add a (onMouseUp) handler that assigns zero to (i) Test the Program Test the Program To check whether the mouse button is being pressed To move the movie clip symbol with the mouse cursor

Handling Key Events Key events are handled by الاحداث التي تتناولها المفاتيح ( عاى الكيبورد ) Key events are handled by الاحداث التي تتناولها المفاتيح ( عاى الكيبورد ) 1) Creating an object to listen to key events انشاء كائن للاستماع إلى الأحداث 2) Associate the object with the key event types ربط كائن مع نوع من الاحداث 3) Register the object to start listening to key events تسجل الكائن للبدء في الاستماع للحدث Event types triggered when pressing keyboard keys: انواع الاحداث التي تطلق عند الضغط مفاتيح الكيبورد Event types triggered when pressing keyboard keys: انواع الاحداث التي تطلق عند الضغط مفاتيح الكيبورد A. onKeyDown: it is triggered whenever a keyboard button is clicked down الحدث سيطلق ( يبقى شغال ) طالما زر الكيبورد كان مضغوطا للاسفل B. onKeyUp: it is triggered whenever a keyboard button is released الحدث سيطلق ( يبقى شغال ) طالما زر الكيبورد كان مضغوطا للاعلى ( أي غير مضغوط )

Handling Key Events Ex) This example receives events from keyboard and prints the code of the pressed key: Ex) This example receives events from keyboard and prints the code of the pressed key: 1. Create a new flash document 2. In action panel of the first frame, type the following code:

Handling Key Events Some important functions found in class key: Some important functions found in class key: 1) Key.getAscii(): returns the ASCII code of the pressed alphanumeric character (s,r,5,3, ….) يرجع الاسكي كود للمفاتيح ( الارقام او الاحرف ) التي تضغط 2) Key.getCode(): returns the code of the pressed non-alphanumeric keys (shift, ctrl, tab … ) يرجع الاسكي كود للمفاتيح ( غير ارقام والاحرف مثل سباس وشفت وكنترول واسهم الاتجاهات ) التي تضغط

Handling Key Events var i:Object = new Object(); i.onKeyDown = function() {trace(Key.getCode());}Key.addListener(i); Creating an object to listen to key events Associate the object with the key event types This code will be executed when pressing on any keyboard key Register the object to start listening to key events

Excersice Write a flash application that moves a movie clip symbol using Keyboard. Write a flash application that moves a movie clip symbol using Keyboard.