Copy link to clipboard
Copied
Hi,
I am working on this Presentation where i have Next and Back Button
In Normal conditions , Net button would only take the user to the Next Frame, but in Some Frames , i have certain Popups which has to be loaded before user can move out of that frame.
I am trying to develop that logic to work around same Mouse Event Listener but different function applied when needed.
I am very new to AS3 so any guidance in this matter would be highly appreciated in making this code work.
You could put a conditional or switch in the event handler function that takes action based on the currentFrame property.
Copy link to clipboard
Copied
You could put a conditional or switch in the event handler function that takes action based on the currentFrame property.
Copy link to clipboard
Copied
Ned. thats what i am trying to put but for some reasons , its not taking me passed that frame , i have succeeded to stop it on a certain frame by removing the vent Listener but once i am done with the condition , it should reactive the Listener , but thats not happening , i know its a pretty simple thing , but due to my lack of experience with AS3 , its causing me trouble to troubleshoot it all by my self.
Here is my Code:
btn_nxt.addEventListener(MouseEvent.CLICK, simplenext);
////////////////////////////////SIMPLENEXT FUNCTION FOR NEXT BUTTON ///////////////////////////////////////////
function simplenext(event: MouseEvent): void | ||
{ | ||
if (currentFrame == 9) | ||||
{ | ||||
btn_nxt.removeEventListener(MouseEvent.CLICK, simplenext); | ||||
trace("Normal Next Button Disabled"); | ||||
btn_nxt.addEventListener(MouseEvent.CLICK, nextframe9); | ||||
trace("Frame 9 Next Button Activated"); | ||||
btn_notice1.addEventListener(MouseEvent.CLICK, loadnotice1); | ||||
pop1.closebtn.addEventListener(MouseEvent.CLICK, unloadbtn1); | ||||
} |
else { |
nextFrame(); |
} | ||||
} |
/////////////////////////FUNCTION FOR FRAME 9 //////////////////////////////////////
Please note that Count is the Counter variable that i defined to increment once the popup movie clip is loaded
function nextframe9(event: MouseEvent): void
{
if(count == 1 && stage.contains(pop1) )
{
removeChild(pop1);
}
if(count == 1)
{
nextFrame();
}
else
{
addChild(pop1);
pop1.x = 40;
pop1.y = 120;
count = 1;
}
}
Copy link to clipboard
Copied
What I suggested is not what I see you implementing. You are trying to change the function that the button calls and you don't need to do that, but you can if you work out the logic properly. Chances are you are missing following the logic if it is not behaving as you intend. I think you are tangling yourself in the logic by separating things out as you are.
This is where you need to learn how to make the best use of the trace() function. If you expect something to happen based on conditions being met, then you need to check those conditions to see if they are what you think rthey should be.
Copy link to clipboard
Copied
Thanks Ned for the guidance , can you give me an example a sample to get an idea of how you think I should run this , I am new with action script 3 and you ar eright , I am tangeling my self a lot with this logic for a while now , I need to devliver this presentation by Monday and I am no where near fixing this thing for me.
Copy link to clipboard
Copied
If you find a function is not doing whatyou expect, test the conditions that should have made it process. For instance... check the values to see that they are what you expect them to be....
function nextframe9(event: MouseEvent): void
{
trace("count value (1?): ", count);
trace("pop1 present (true)?: ", stage.contains(pop1));
if(count == 1 && stage.contains(pop1) )
Find more inspiration, events, and resources on the new Adobe Community
Explore Now