Version: 4.2.1 +
In this exercise you will combine a Button with an Action object
- The Futurama Editor must be installed.
- Futurama Runtime must be installed.
- Completing the tutorial Working with Actions in Futurama first, is recommended.
This is a sequel of the previous exercise ’World Population’. You can download the basis for this exercise (the end-result of the of the World Population exercise) by clicking here.
With the combination of a Button and an Action object, you can enable the visitor of your application to invoke changes. In this exercise we will use the Button-Action combination to let the visitor switch the visibility of the series of continents in the population graph.
Create two buttons for every continent that will turn the visibibity of the series of that continent in the graph on/off.
Take the following steps to do so:
- Create two buttons for every continent. Name the first button ‘Name Continent on’ and the second button ‘Name Continent off’.
- Create in every Button the function Action. In the Properties of the Action object, refer to the Population Graph.
- Now create a Node within the Action object and a Fixed (type boolean) within the Node, that will change the property Visible in True or False. Name the Fixed for example 'Asia:Visible'. See the Tips section for information to do so.
Now open your website in a browser and see if you can change the visibility of the different series by clicking the buttons.
- When the TargetControl property refers to an object in your application, you can change the properties of that object. This is done by creating objects within the Action object that have the name of the property you want to change. For instance a boolean named 'Visible' with a value 'True' or 'False', will change the visibility of the object referred to.
- A graph is a special multi-layered object. The different series included in the graph, all have properties of their own. When you want to change the properties of series, you first have to create a Node named 'Series' within the Action. Within the Node you now have to add a object holding the new property input. This object should hold the Path to the property of the series you want to change. The path is seperated by colons. For instance: 'Asia:Visible' changes the visibility property of the Asia series.
- Remember to fill in the Text property of every Button.
- The scale of the Y-axis is defined automatically, based on the input of series. Therefore the scale of the graph will change when continents are made invisible. To prevent this, set the Maximum of the Y-axis to for instance 10.000.
You can download our solution for this assignment by clicking the image at the right. (Futurama 18.104.22.168)
Please note that you can very well have a different solution that is just as good as ours.
If you want some more practise on this subject, you could try the extra exercises below.
We won't provide a solution for these variations, just consider them as a way to further experiment with Futurama.
- (Easy:) Make sure all continents are visible when you open the website.
- (Medium:) Make sure the height of the Y-Axis (amount of people) is a fixed value. In this way it is more clear that the different continents appear and disappear.