Presentation is loading. Please wait.

Presentation is loading. Please wait.

Primitive Data Types 2. Boolean Data Type: It is used in logical operations to represent a certain state. هو يستخدم في العمليات المنطقية لتمثيل دالة معينة.

Similar presentations


Presentation on theme: "Primitive Data Types 2. Boolean Data Type: It is used in logical operations to represent a certain state. هو يستخدم في العمليات المنطقية لتمثيل دالة معينة."— Presentation transcript:

1 Primitive Data Types 2. Boolean Data Type: It is used in logical operations to represent a certain state. هو يستخدم في العمليات المنطقية لتمثيل دالة معينة It is used in logical operations to represent a certain state. هو يستخدم في العمليات المنطقية لتمثيل دالة معينة It could only hold two values: يستخدم فقط مع القيمتين It could only hold two values: يستخدم فقط مع القيمتين true true false false Ex) var f2:Boolean = true; Ex) var f2:Boolean = true;

2 Primitive Data Types 3. String Data Type: It used to store data as a text ( a sequence of characters). انها تستخدم لتخزين بيانات نصية ( سلسلة من الحروف ) It used to store data as a text ( a sequence of characters). انها تستخدم لتخزين بيانات نصية ( سلسلة من الحروف ) Ex) “ This is some text ” Ex) “ This is some text ” String in flash should be enclosed within double quotation ( “” ) النص في فلاش يجب ان يكون بين String in flash should be enclosed within double quotation ( “” ) النص في فلاش يجب ان يكون بين Ex) to declare a variable (s) of type String and store “ some text ” in it: Ex) to declare a variable (s) of type String and store “ some text ” in it: var s:String = “ some text ” ;

3 Primitive Data Types Each character in a string has an index. كل حرف في فلاش له موقع ( مؤشر ) Each character in a string has an index. كل حرف في فلاش له موقع ( مؤشر ) The indices of characters are numbered (0,1,2,3, … ) from left to right. مؤشرات الاحرف ارقام من اليسار الى اليمين The indices of characters are numbered (0,1,2,3, … ) from left to right. مؤشرات الاحرف ارقام من اليسار الى اليمين The string characters created in the previous example have indices as follows: The string characters created in the previous example have indices as follows: s o m e t e x t 0 1 2 3 4 5 6 7 8

4 Primitive Data Types Functions to manipulate string: اقترانات للتعامل مع النص Functions to manipulate string: اقترانات للتعامل مع النص 1. charAt(i); This function returns a character from a string found in index (i) هذا الاقتران يرجع الحرف من النص الموجود في الموقع This function returns a character from a string found in index (i) هذا الاقتران يرجع الحرف من النص الموجود في الموقع i: integer number represent an index. i: integer number represent an index. Ex) var s:String = “ some text ” ; Ex) var s:String = “ some text ” ; trace(s.charAt(2)); // m 2. indexOf(str); This function returns the index of the passed (str) within the text. بدون النص يرحع موقع النص المرر في ( ) This function returns the index of the passed (str) within the text. بدون النص يرحع موقع النص المرر في ( ) Ex) trace(s.indexOf( “ m ” )); // 2 Ex) trace(s.indexOf( “ m ” )); // 2

5 Primitive Data Types 3. length; Returns the number of characters in the string. Returns the number of characters in the string. Ex) trace(s.length);//9 يرجع عدد احرف النص Ex) trace(s.length);//9 يرجع عدد احرف النص 4. substr(index,length); Returns a part of the string as specified in the parameters. يرجع الجزء المحدد من النص Returns a part of the string as specified in the parameters. يرجع الجزء المحدد من النص index: an integer gives the starting point of the taken part. index: an integer gives the starting point of the taken part. length: the number of characters to take starting at (index). length: the number of characters to take starting at (index). Ex) trace(s.substr(1,5));// ome t Ex) trace(s.substr(1,5));// ome t s o m e t e x t 0 1 2 3 4 5 6 7 8 index

6 Primitive Data Types 5. toUpperCase(); Returns the capital letter representation of the string. يرجع احرف السترنك الى احرف كبيرة ( يعرضها احرف كبيرة دون تغييرها على النص الاصلي ) Returns the capital letter representation of the string. يرجع احرف السترنك الى احرف كبيرة ( يعرضها احرف كبيرة دون تغييرها على النص الاصلي ) 6. toLowerCase(); Returns the lower letter representation of the string. يرجع احرف السترنك الى احرف صغيرة ( يعرضها احرف صغيرة دون تغييرها على النص الاصلي ) Returns the lower letter representation of the string. يرجع احرف السترنك الى احرف صغيرة ( يعرضها احرف صغيرة دون تغييرها على النص الاصلي )

7 String Example Ex) this example illustrate how to build a flash program to read string value from keyboard, convert it to its capital representation, and print the result in a text field on the stage: Ex) this example illustrate how to build a flash program to read string value from keyboard, convert it to its capital representation, and print the result in a text field on the stage: 1. Create a flash file. 2. Insert a text field on the stage, convert its type to (Input Text) and give it an instance name (txtinput) When you change the type of a text field to (Input Text), you can insert text values into it at runtime في وقت التشغيل from keyboard. When you change the type of a text field to (Input Text), you can insert text values into it at runtime في وقت التشغيل from keyboard. Giving an instance name to a text fields allow us to access it using action script. يعطي المثال اسم لحقل النص يسمح بالوصول اليه باستخدام Giving an instance name to a text fields allow us to access it using action script. يعطي المثال اسم لحقل النص يسمح بالوصول اليه باستخدام

8 String Example 3. Insert a text field on the stage. Convert its type to dynamic and give it an instance name هو الفراغ الموجود تحت نوع حقل النص )) (txtoutput) 4. Add a button on the stage. Insert the text (Convert to Capital) in the button. اضف زر على المسرح واكتب عليه ( تحويل الى كبير ) 5. In the action pane of the button, add the following script: on(press){ var s:String; s = txtinput.text; txtoutput.text = s.toUpperCase(); } To take the text inserted into (txtinput) and assign it to (s)ياخذ النص المدخل وبضعه في س To make return the capital letter representation of s. Then assign it to (txtoutput)يعرض الاحرف الموجودة في س على شكل حروف كبيرة دون تغيير في حالتها الاصلية (أي تبقى داخل س صغيرة

9 Global variable Global variables are visible to every timeline and every scene in your flash file. هو متغير ظاهر ( يمكن تعامل معه ) في اطار زمني واي مشهد Global variables are visible to every timeline and every scene in your flash file. هو متغير ظاهر ( يمكن تعامل معه ) في اطار زمني واي مشهد To declare (or create) a variable with global scope, use the _global identifier before the variable name and do not use the var keyword. To declare (or create) a variable with global scope, use the _global identifier before the variable name and do not use the var keyword. Ex) _global.myName = “ globalvar"; الصيغة الرئيسية في تعريف ( انشاء ) المتغير العام Ex) _global.myName = “ globalvar"; الصيغة الرئيسية في تعريف ( انشاء ) المتغير العام

10 Flash Sounds There are two ways to add sounds to our flash file: طريقتين لاضافة صوت على ملف الفلاش There are two ways to add sounds to our flash file: طريقتين لاضافة صوت على ملف الفلاش 1. import a sound file (in whatever format the flash editor can handle, e.g. mp3, wav... etc), and pull it onto the stage. استيراد ملف صوت ( باي صيغة كان....) ثم اسحبه الى المسرح Ex) Ex) 1. create new flash file 2. Go to File  Import  Import to Library 3. Choose the sound file from your computer, and click open. 4. You can notice that your sound file was added to your library. يمكن ملاحظة ان ملف الصوت اضيف الى متكبتك 5. Now, Drag and drop that flash symbol into the stage. 6. Test the movie

11 Flash Sounds 1. if you want to have better control in playing the sound file, you may need some actionscripts. اذا اردت التحكم بشكل جيد في تشغيل ملف الصوت انت تحتاج الى الاكشن سكربت starting and stopping the music by pressing the corresponding button. starting and stopping the music by pressing the corresponding button. Ex) This example illustrates how to control sounds inside flash program. هذا المثال يوضح كيف تتحكم بصوت داخل برنامج فلاش Ex) This example illustrates how to control sounds inside flash program. هذا المثال يوضح كيف تتحكم بصوت داخل برنامج فلاش 1. Open a new file in the Flash 2. Import a sound file into the library. 3. MRC on the imported sound(in the library window; you may need to open the library window first), and select linkage on the pop up menu. اضغط بالماوس اليمين على الصوت المستورد ( في المكتبة ) واختار لينك

12 Flash Sounds 4. Check اختار )) the export to actionscript option and type the name "mysound" in the textbox. This will assign an id to the imported sound, so later on the actionscripts can refer to it. هذا من شانه اعطاء اسم للصوت المستورد وبالتالي يمكننا من الرجوع اليه في الاكشن ( أي الوصول للصوت من خلال الاكشن ) This will assign an id to the imported sound, so later on the actionscripts can refer to it. هذا من شانه اعطاء اسم للصوت المستورد وبالتالي يمكننا من الرجوع اليه في الاكشن ( أي الوصول للصوت من خلال الاكشن ) 5. Ok, back to the main stage. Select the first frame on the timeline, open the action window and put the following code in it: var snd:Sound = new Sound(); snd.attachSound("mysound"); Basically, the above code will create a sound object and attach the imported sound file to it. الكود الموجود في الاعلى ينشىء كائن صوت ويرفق الصوت المستورد له Basically, the above code will create a sound object and attach the imported sound file to it. الكود الموجود في الاعلى ينشىء كائن صوت ويرفق الصوت المستورد له 6. insert a (play) button in the stage and write the following code in the action panel of it: انشىء زر ( تشغيل ) على المسرح واكتب في الاكش الذي الكود التالي

13 on(release) { _root.snd.start(0, 10); } Flash Sounds _root: to access every object in the main timeline للوصول لاي كائن على خط الزمن الرئيسي Start(0,10): This will start playing the sound (and loops 10 times) when the button is clicked. هذه تبدا تشغيل الصوت ( ويشغل عشر مرات ) عندما يتم النقر على الزر Action is performed when releasing the button الاكشن ينفذ عندما يتم ابعاد الماوس عن الزر ( أي نضغط على الزر ونشيل الماوس عنه )

14 Flash Sounds 7. Repeat step 6 to create the stop button but associated with the following actionscritps instead: اعد الخطوة 6 لانشاء زر ايقاف واكتب في الاكشن سكربت تبعه التالي on(release) { _root.snd.stop(); } Stop(): to stop the sound


Download ppt "Primitive Data Types 2. Boolean Data Type: It is used in logical operations to represent a certain state. هو يستخدم في العمليات المنطقية لتمثيل دالة معينة."

Similar presentations


Ads by Google