-
1. Re: Need to Disable to Button Until all the Elements of Array has been Displayed
Ned Murphy Nov 4, 2014 4:24 AM (in response to navigator81)Part of the problem will be that you are trying to rely on clicking a disabled button to enable that button. As long as the button is disabled you can't use it to enable itself. Instead of adding an event listener to btnnxt right away, just assign it when it is ready to be used. Each time you load you need to check the count value and if it equals 2 then you can assign the event listener to enable the btnnxt.
You do not need an array (count) for this since you are only using its length property... a simple integer value will suffice.
Since I do not see you creating a variable named note3, you probably get an error for that.
In your load2 function you are still targeting the note1 for placement where it should already have been placed.
-
2. Re: Need to Disable to Button Until all the Elements of Array has been Displayed
navigator81 Nov 4, 2014 5:14 AM (in response to Ned Murphy)Thank you so Much Ned for a quick Reply.I am very new to AS3 and therefore having my troubled along with me.
I see the logic in your point which would certainly work but i am trying different ways to achieve it , please forgive my lack of knowledge in this domain , but i am not able to figure out the code for this.
Here is my modification as per your suggestion :But i must be doing something really wrong as its not working
import flash.events.MouseEvent;
var note1:Mc_Notice1 = new Mc_Notice1;
var note2:Mc_Notice2 = new Mc_Notice2;
var notes:Array = [note1,note2];
var count:int;
count = 0;
btnload1.addEventListener(MouseEvent.CLICK , load1);
btnload2.addEventListener(MouseEvent.CLICK , load2);
function load1(Event:MouseEvent):void
{
addChild(notes[0]);
notes[0].x = 100;
notes[0].y = 100;
count ++;
if ( count < 2){
btnnxt.addEventListener(MouseEvent.CLICK , nextdis);
}
trace("Counter Value:" + count);
}
function load2(Event:MouseEvent):void{
addChild(notes[1]);
notes[0].x = 100;
notes[0].y = 100;
count ++;
trace("Counter Value:" + count);
if ( count == 2){
btnnxt.addEventListener(MouseEvent.CLICK , nextframe);
}
//count0 = 1;
trace("Counter Value:" + count);
}
function nextdis(Event:MouseEvent):void{
btnnxt.mouseEnabled = false;
}
function nextframe(Event:MouseEvent):void{
btnnxt.mouseEnabled = true;
nextFrame();
}
-
3. Re: Need to Disable to Button Until all the Elements of Array has been Displayed
navigator81 Nov 4, 2014 6:20 AM (in response to navigator81)Ok , Ned , well your Guidance really worked , thanks alot for that.
I made it work , though since i am very new to AS3 , i really had to experiment , here is the final Code :
import flash.events.MouseEvent;
stop();
var note1:Mc_Notice1 = new Mc_Notice1;
var note2:Mc_Notice2 = new Mc_Notice2;
var notes:Array = [note1,note2];
//var count:Array = new Array(1);
var count:int;
count = 0;
btnload1.addEventListener(MouseEvent.CLICK , load1);
btnload2.addEventListener(MouseEvent.CLICK , load2);
function load1(Event:MouseEvent):void
{
addChild(notes[0]);
notes[0].x = 100;
notes[0].y = 100;
count ++;
trace("Counter Value:" + count);
if ( count == 2)
{
btnnxt.addEventListener(MouseEvent.CLICK , nextframe);
}
}
function load2(Event:MouseEvent):void
{
addChild(notes[1]);
notes[1].x = 100;
notes[1].y = 100;
count ++;
if ( count == 2)
{
btnnxt.addEventListener(MouseEvent.CLICK , nextframe);
}
trace("Counter Value:" + count);
}
function nextframe(Event:MouseEvent):void{
trace("Mouse Enabled");
nextFrame();
}
Once again , Thanks alot for the help and Guidance
Best Regards


