So I am brand new to programming. I was using a book to follow along an example of basic programming in which you create an interactive storybook. It consists of three separate screens with buttons to toggle between them. I made the buttons greyish, then rainbow when your mouse is over them and them made them stay rainbow and move down and to the right a bit when you click them.
That all works fine, but I notice when I go to one screen, then go back to the other, the button is displayed in it's over state (as if the mouse is over it, which it isn't). In this case, the button is rainbow. If I put my mouse over it then take it off again, it resets it and it changes to the grey up state again. I was wondering what might cause this? The code I use it quite simple, I'm wondering if it's a script thing, or something to do with my button symbols.
I've incldued the code below. Please ignore all the extra comments I added, I put them in to help me learn
Thanks for any help!
package // groups all your code neatly together
import flash.display.MovieClip; //MovieClip is a pre-made collection of classes which allow you to display things on screen. It must be imported BEFORE your class definition
import flash.events.MouseEvent; //MouseEvent is another pre-made class used for mouse actions
//Classes are building blocks, blueprints for creating instances of themselves
public class Main extends MovieClip //extending MovieClip allows this class to use all the properties and methods of MovieClip to hlep it display things on the screen
//importing and extending classes is called "INHERITANCE"
//These are variable declarations. It has (name of the variable[can be anything]):(type of variable being created)
//Variables just represent changing information, such as score or current location
var startPage:StartPage; //creates a variable called startPage, to store instances of StartPage (the library symbol)
public function Main() //this runs all the code within it once the class it's in is instantiated (it's the constructor method)
//public means that this constructor method is freely available to be used by different classes from different packages
//the parantheses contain parameters for this function (this function doesn't need any, so they are empty)
//These are directives, a single line action that the function performs
startPage = new StartPage; //this changes the variable startPage to an instance of the StartPage symbol
leftHill = new LeftHill;
rightPond = new RightPond;
//addChild is a built in method that (amongst other things) displays instances of MovieClip symbols on the stage
addChild(startPage); //adds its argument (what's in the brackets) to the "display list", instances in the display list are visible on the stage
//in this case the argument is the variable startPage, which was defined as an instance of our StartPage library symbol
//Event Listeners, these are built in methods that listen for a particular event, in this case clicking on a butotn
//With dot notation, things live inside whatever is to their left of the dot
//Event Handlers, these 'handle' the event, doing whatever they are programmed to do when the corresponding event is heard
//This 'function' line is a function definition. Fucntion definitions are block statements that include one or more directives
//The name of the function (here 'onHillButtonClick') is known as the method name
//You can call upon the function you have defined using a 'method call' and it will perform ALL the directives within it
//At the end is the 'type declaration', which indicates what kind of information might be returned to the program from the function. Here nothing is returned, so it's "void"
removeChild(startPage); //removeChild removes an instance from the stage. However, it is still stored in the Flash Player memory