ELSE Statements

For questions about using Classic.

Post » Mon Oct 20, 2008 7:36 am

Hello again!

I have been working on a menu function using a number of buttons, and have run into the problem of simultaneous executions from a single button press. After reading through the forums, there have been several mentions of using the ELSE function to fix this. However, I cannot seem to get it to work. Are there any examples of the else function in action that are available to check out?

Thanks!
B
2
G
4
Posts: 49
Reputation: 1,148

Post » Mon Oct 20, 2008 8:14 am

You must put "ELSE" as a different Event.
For example, if you want to accomplish something like this:

if ( MyObject('myVariable') == 12)
DoSomething;
else
DoAnotherThing;

You have to prepare such events:

Event #1:
Conditions: MyObject('myVariable') is equal to 12
Actions: DoSomething

Event #2 (right below Event #1)
Conditions: ELSE
Action: DoAnotherThing

When you use "OR" then OR is just withing the same event. But when you are using "ELSE", this "ELSE" must be a seperate event. What is more, this "ELSE" event must be put right below event you want to have else-d. You'll notice a line connecting Event #1 and "ELSE Event" - this line shows which event the "ELSE Event" is referencing to.
B
6
S
3
G
6
Posts: 219
Reputation: 3,013

Post » Mon Oct 20, 2008 8:42 am

i prefer to use ELSE in a sub-event
B
2
S
2
G
4
Posts: 254
Reputation: 1,958

Post » Mon Oct 20, 2008 10:56 am

[quote="dfyb":qjx74rb1]i prefer to use ELSE in a sub-event[/quote:qjx74rb1]
Does that work?? We only coded it to work for following events...
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Mon Oct 20, 2008 11:06 am

[quote="Ashley":27ry4zjw][quote="dfyb":27ry4zjw]i prefer to use ELSE in a sub-event[/quote:27ry4zjw]
Does that work?? We only coded it to work for following events...[/quote:27ry4zjw]
It worked some builds ago...
B
4
S
2
G
4
Posts: 719
Reputation: 2,938

Post » Mon Oct 20, 2008 3:29 pm

[quote="Ashley":23hdck3k][quote="dfyb":23hdck3k]i prefer to use ELSE in a sub-event[/quote:23hdck3k]
Does that work?? We only coded it to work for following events...[/quote:23hdck3k]
i believe so...

like

on click
--condition 1 -- do something
--else -- do something else
B
2
S
2
G
4
Posts: 254
Reputation: 1,958

Post » Mon Oct 20, 2008 3:39 pm

[quote="dfyb":37la222e][quote="Ashley":37la222e][quote="dfyb":37la222e]i prefer to use ELSE in a sub-event[/quote:37la222e]
Does that work?? We only coded it to work for following events...[/quote:37la222e]
i believe so...

like

on click
--condition 1 -- do something
--else -- do something else[/quote:37la222e]

It's following a sub-event, it's not just a sub-event.
That's why it works. :)
B
2
S
1
G
4
Posts: 92
Reputation: 1,384

Post » Mon Oct 20, 2008 4:05 pm

Oh right, yeah. I thought you meant:
+ Condition
----> ELSE ...
It works fine via subevents like you say.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Mon Oct 20, 2008 11:22 pm

AH!!

Thank you! That fixed it.
B
2
G
4
Posts: 49
Reputation: 1,148

Post » Tue Oct 21, 2008 10:19 pm

Ok. I thought I had it, but no luck. Ive uploaded the .cap if some one wants to take a look at and tell me where I am messing up, that would be helpful.

http://www.2shared.com/file/4137951/cb2d75a4/Core.html
B
2
G
4
Posts: 49
Reputation: 1,148

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests