-
1. Re: How to keep an item hidden when retruning to my games home frame?
moccamaximum Dec 1, 2014 12:59 AM (in response to Rackoon)if you are using actionscript 3:
btn199.addEventListener(MouseEvent.CLICK, takeQuestion);;
function takeQuestion(e:MouseEvent):void{
e.currentTarget.visible = false;
//hides the button
var index:int = e.currentTarget.name.substr(3,3);
//results in 199 in our case
gotoAndStop(index);
//jumps to frame 199 were the question is
}
-
2. Re: How to keep an item hidden when retruning to my games home frame?
Ned Murphy Dec 1, 2014 5:30 AM (in response to Rackoon)One way would be to add the button instance to an array that you loop thru every time you go back to that frame and make the buttons in the array invisible.
Another way would be to have the buttons contained in an object (movieclip/sprite) that exists in all frames but is only made visible at the beginning frame.... that way you never leave the buttons behind and the ones you turn invisible inside that object will remain invisible.
-
3. Re: How to keep an item hidden when retruning to my games home frame?
Rackoon Dec 1, 2014 8:44 PM (in response to moccamaximum)Thank you both for the help. Ned, I think I would need a lot more practice to do what your speaking of.
Hey moccamaximum, I understand most of what you typed. but I am a little fuzzy on where to stick it. I have a very basic understanding of event handlers and functions and still learning.
As for the veritable I will need to review that part again.
some guidance would be a big help; here is one of my tests I have been working with. If I can make it work for three on the first frame then it will work for 200
Home frame has button one, two, and three on it (button one takes you to frame 2) (button two takes you to frame 3) (button three takes you to frame 4)
suppose I click on button one and I am taken to frame 2; I select the correct multi-choice button (call it button four) I am taken back to home frame 1 and button one is gone or transparent.
(This is where I get stuck is when I select another button and come back to home frame transparent buttons reappear)
Could you help me attach the correct action-script you gave me to the correct buttons? Also this part confuses me one var index:int = e.currentTarget.name.substr(3,3);
-
4. Re: How to keep an item hidden when retruning to my games home frame?
moccamaximum Dec 1, 2014 11:41 PM (in response to Rackoon)if a buttons name is "btn1"
var index:int = e.currentTarget.name.substr(3,1);
will get you to the "1" in "btn1" and thus telling you which Button was pressed
this is useful to let a MouseEventHandler tell where he originated
Lets say you have 3 buttons:
btn1,btn2,btn3
you can now attach a single EventListener
btn1.addEventListener(MouseEvent.CLICK, clickHandler);
btn2.addEventListener(MouseEvent.CLICK, clickHandler);
btn3.addEventListener(MouseEvent.CLICK, clickHandler);
and depending on which button was pressed, execute different behaviour:
function clickHandler(e:MouseEvent):void{
e.currentTarget.visible = false;
//hides the button
var index:int = e.currentTarget.name.substr(3,1);
gotoAndStop(index);
//jumps to frame 1 when btn1 is clicked
//jumps to frame 2 when btn2 is clicked
//jumps to frame 3 when btn3 is clicked
}



