Strategy to show hide X

lotto.hype.zip (786.9 KB)

Hi Guys.

I need to do the following:

When a client clicks on a lotto ball the it shows an X if not showing and visa versa.
I then need to save the state of the showX = Y or N.
When starting the app read the settings showX and show or hide it.
This is working as expected.

I now need to duplicate this for 59 different balls.

I cannot work out a way (other than duplicate each set of code & animation) to allow me to save the state of each instance of showX.

ie showX1 = Y
showX2 = N

Cheers

Steve Warby

Hi Steve!

Possibly an “array” would be the ticket…
http://www.w3schools.com/js/js_arrays.asp

1 Like

@JimScott is correct, you would do this with an array.

But localStorage only accepts strings so we would need to convert the array structure to a string and when getting it back re structure it into an array again. This is very simple as shown in this updated version of your projects.

The best was I can see to id each ball that is clicked is to make the X button into a symbol.
Then duplicate it as needed and give each one an id corresponding with a ball. Place the duplicated symbols over the corresponding balls.

(NOTE: because we are now using symbols, I have removed the time line on the scene. The symbol now has the timeline. Also I have removed the click actions from the buttons and put it on the symbols so we get the symbols id when we click. In the Main Timeline I have removed the start symbols timelines )

lotto.hype 2.zip (791.1 KB)

The code works when a symbol is clicked it’s id is checked against the array.

Hi,

I now have this working using 6 balls.

This works fine on the coding side.
To get the symbols to show in the middle of the balls I had to offset them to the left.
On full screen it is okay but as I make the screen smaller (or view on Iphone) the ‘X’ is offset to the left.

I cannot work out why this is happening or why I need to offset the symbols in the first place.

Cheers

Steve Warby

Can you post your current version

Whoops forgot to attach

lotto2.hype.zip (2.0 MB)

I am now also using php to save the array to a text file on the server and retrieve on startup.

My php files are:
get.php
<?php
ini_set(‘display_errors’, 1);
ini_set(‘display_startup_errors’, 1);
error_reporting(E_ALL);
$data = json_encode(file_get_contents(‘myFiles/xSetting.txt’));
echo $data;
?>

post.php

<?php
sleep(1);
if (empty($_POST['fileName'])) {	
}
else {
$fname = $_POST['fileName'];
$data = json_decode($_POST['jsonString']);
$file = fopen('myFiles/'.$fname, 'w');
fwrite($file, $data);
fclose($file);
}
?>

The problem is (I think) that the data returned is not formatted as an array.

How do I ensure I am sending an array, storing an array in xSettings.txt, then returning the array.

Any question is on the population of the balls.

The layout okay on different devices but on a web page there is a lot of white space. Is there a way to add more to the rows as the page size increases

Cheers

Steve Warby.

1 Like

Ok I have a working model.

But from what I can see from what you were doing you do not understand the php stuff that I wrote and you copied int the project.
Thats ok because it looks like you were trying. The problem is if you are going to understand my changes.

I will post this example now. And try and come back with whats going on later…

Note. Delete your file xSetting.txt in the myFiles folder before you run this.
This will always write a new one out when you click a symbol but at the start you will get odd results if your file is not formatted right.

Also this will mean you will get a 404. When you first ever run because the xSetting.txt file will not be found. Don’t worry about that at the mo.

lotto.hype.zip (1.7 MB)

Thats great thanks.

I understand the structure okay now.

Cheers

Steve Warby

Thanks to Mark I have a working example.

The next phase it to:

  1. Save the date and time along with the status of the ‘x’
  2. Have two versions ( the admin version allows the clicks ) the admin version has no on click (I simply remove the on click event).

Thanks for the help

Steve Warby

lotto3.hype.zip (2.6 MB)