Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming Your App’s Memory 靜宜大學資管系 楊子青

Similar presentations


Presentation on theme: "Programming Your App’s Memory 靜宜大學資管系 楊子青"— Presentation transcript:

1 Programming Your App’s Memory 靜宜大學資管系 楊子青

2 Memory Slots Just as people need to remember things, so do apps.
When someone tells you the phone number of a pizza place for a onetime immediate call, your brain stores it in a memory slot. In this chapter, you’ll learn how to set up an app’s memory, how to store information in it, and how to retrieve that information at a later time.

3 Named Memory Slots An app’s memory consists of a set of named memory slots. Some of these memory slots are created when you drag a component into your app; these slots are called properties. You can also define named memory slots that are not associated with a particular component; these are called variables.

4 1. Properties Components (Button, TextBox, and Canvas…)
are part of the user interface. Each component is completely defined by a set of properties. The values stored in the memory slots of each property determine how the component appears.

5 Modifying the memory slots in the property form to change the app’s appearance

6 2. Variables Defining Variables Setting and getting a Variable
Setting a Variable to an Expression Incrementing a Variable Building Complex Expressions Displaying Variables

7 2.1 Defining Variables You define a variable when your app needs to remember something that is not being stored within a component property. For example, a game app might need to remember what level the user has reached. If the level number is not something the user will see, you’d define a variable to store it.

8 Defining Variables 1. 拖曳出 initialize global name to

9 Defining Variables 2. 設定變數名稱 3. 設定初值

10 2.2 Setting and getting a Variable
設定(變更)變數值 選擇變數名稱

11 Setting and getting a Variable
取得變數值 選擇變數名稱

12 2.3 Setting a Variable to an Expression
Incrementing a Variable Building Complex Expressions

13 Math drawer In the Math drawer, App Inventor provides a wide range of mathematical functions.

14 2.4 Displaying Variables Changing a variable has no direct effect on the app’s appearance. When you modify a component property, the user interface is directly affected. This is not true for variables. This is one of the advantages of storing data in a variable as opposed to a component property it allows you to show just the data you want when you want to show it. It also allows you to separate the computational part of your app from the user interface, making it easier to change that user interface later.

15 HelloPurr_Extend

16 1. 複製專案進行修改 開啟HelloPurr專案,Save as為HelloPurr_Extend

17 Media部分,以Upload File加入獅子圖片(lion.jpg)與獅吼聲音(roar.mp3)

18 回顧:LabelName的Text屬性,決定顯示文字內容

19 回顧:Button1的Image屬性,決定該按鈕的長相(顯示哪張圖片)

20 回顧:Sound1的Source屬性,決定 播放哪個聲音檔

21 如何動態調整顯示文字? 圖片?聲音?

22 執行結果: 初次播放roar.mp3發生error

23 Google找解決方法

24 Screen1.Initialize

25 鱷魚拔牙整人玩具 http://www.i-gamer.net/play/2978.html

26 2. 按圖片,第6次出現獅子

27 3. 隨機第2-6次出現獅子


Download ppt "Programming Your App’s Memory 靜宜大學資管系 楊子青"

Similar presentations


Ads by Google