I tried to make a BlackJack game but when i tried to open it in my phone(i tried 5 phone) ,i give a number to input and app freeze,i tried to install it as apk but it didnt work too,where is the problem
(Canned Reply: ABG- Export & Upload .aia)
Export your .aia file and upload it here.
.
ıts bigger than 8 mb
okay i will try
its still freezing
you created an endless while loop using the while block, which results in a not responding app
Taifun
but if user press button 3,global pes will be true,so tis not endless
as you found out yourself, it's a bad idea to use a while loop like that... see The model of event processing in App Inventor by @Franklyn_A_Turbak
The model of event processing in App Inventor is not particularly intuitive and is full of surprises like the one that Christian has reported.
I and other members of the App Inventor educational team created this paper and this talk to explain App Inventor's event model and to provide guidance on how to express certain computational patterns in this model.
The essence of App Inventor's event model is the following five Event Rules:
- Only one event handler can be executing at any given time.
- Other events that occur while an event handler is executing are queued and handled later, in order.
- Any GUI changes during an event handler are not displayed until the event has completed.
- Certain system actions (playing a sound file, initiating a web request, etc.) are executed in a thread separate from the current event handler.
- Playing a sound on a Player component first terminates any sound currently playing except when the source file has not been reset, in which case the new play request is ignored if the sound is already playing.
To see if you understand these rules, take the quiz that starts on slide #17 of the talk.
In particular, Event Rule #3 explains the behavior that Christian is reporting: because no GUI changes made during the execution of an event handler are displayed until the event handler has completed, the setting of Screen1.Title and TextBox1.Text appear to happen simultaneously.
As noted in the paper, effective programming in the context of these rules requires using some different programming idioms than one may use in other programming languages.
- Many iterative processes expressed with loops in other languages must, in App Inventor, be expressed as global state machines in which each step of the iteration is triggered by an event.
- The Clock.Timer event is used to express iterations, delays, and the interleaving of actions. In Christian's case, Scott has recommended using a timer to program the delay between two messages.
- App Inventor actions that take a long or unpredictable amount of time are expressed as pairs of (1) a method that initiates the action and (2) a callback event handler that is executed when the action completes. Examples of such pairs are Camera.TakePicture/Camera.AfterPicture and TinyWebDB.GetValue/TinyWebDB.GotValue. To solve Christian's problem. Taifun has suggested using the pair Notifier.ShowChooseDialog/Notifier.AfterChoosing.
- lyn -
Taifun
okay but did you understand my problem,how can i do that,i want that:if these 3 event is true,buttons can be enable but if any event is false,buttons need to be disabled
If/else statement
but if else will control it for just one time,i want to control this situation forever
You appear to be calling your while test in a button click event ? Replace with if/else ?
Alternatively, use a clock timer to routinely run the if/else.
oh you didnt understand the content i think,it was a blackjack game and this button's goal is confirm the bet amount,so we can just click this button for 1 time.but i didnt understand clock method fully,cna you explain please
Put your if/else statement in a procedure.
Look at your blocks logic. Wherever one/any of those three values changes, run the procedure.
I'm making a BlackJack game.When we choose stay button,dealer starts draw cards until 17 or bigger.But in my code,dealer open all cards at the same time,but i want a delay like dealer open a card,wait 3 second,open another card exc. Can you help me,İ will add my documents in a drive file cause its bigger than 8mb
Use a clock timer.