Copy link to clipboard
Copied
Hi , i am trying to develop a Slideshow where Next Button needs to behave in a certain way on a specific Frame , lets say a Specific Condition is met only then Next Button would work , I have been able to achieve that but problem is the Button Retains its Event Listener even on the next Frame , whereas i have already included removeEventListener on the next frame with a new Function for the button , but its doesnt take it like that.
Can anyone help please ?
Copy link to clipboard
Copied
Show the code you are using for that button for the different frames.
Copy link to clipboard
Copied
Hello Ned,
I have fixed the issue with few Frame , but where we have the conditions to be met on two consecutive frames , I am not able to achieve that.
here is the Code on my first Frame.
FRAME1
stop();
slidecounter.text = String(this.currentFrame - 1 + "/" + indexframe);
mc_prog.width = 0;
/////////////////////////////////////////////////////////////////////////////////
//LIBRARIES TO BE IMPORTED ///////////////////////////////////////////////////////////
import flash.events.MouseEvent;
//VARIALBLES INITIATED
var score:Number = 0;
var questions:Number = 0;
var qtotal:Number = 11;
var attempt:Number = 0;
var indexframe:int;
indexframe = this.totalFrames - 1;
var notes:Array = new Array();
var count:int;
count = 0;
var backcounter:int;
backcounter = 0;
var count2:int;
count2 = 0;
var backcounter2:int;
backcounter2 = 0;
var count3:int;
count3 = 0;
var backcounter3:int;
backcounter3 = 0;
// MOVIE CLIPS INITITATED ////////////////////////////////////////////////////////////////
var volbutton1:volcontrol;//VOLUME BUTTON ROLLOVER MOVIE CLIP
volbutton1 = new volcontrol();
var clist:courselist;//VOLUME COURSE LIST ROLLOVER MOVIE CLIP
clist = new courselist();
var pop1:Mc_slide9 = new Mc_slide9;
pop1 = new Mc_slide9;
var pop2:Mc_slide13 = new Mc_slide13;
pop2 = new Mc_slide13;
var pop3:Mc_slide17 = new Mc_slide17;
pop3 = new Mc_slide17;
//BUTTONS INITIATED
btn_nxt.addEventListener(MouseEvent.CLICK, fl_ClickToGoToNextFrame);//NEXT SLIDE BUTTON
btn_bck.addEventListener(MouseEvent.CLICK, backbtn);//BACK BUTTON
btn_loc.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage); //LIST OF COURSES BUTTON
btn_notice1.addEventListener(MouseEvent.CLICK, loadnotice1);
pop1.closebtn.addEventListener(MouseEvent.CLICK, unloadbtn1);
btn_notice2.addEventListener(MouseEvent.CLICK, loadnotice2);
pop2.closebtn.addEventListener(MouseEvent.CLICK, unloadbtn2);
btn_notice3.addEventListener(MouseEvent.CLICK, loadnotice3);
pop3.closebtn.addEventListener(MouseEvent.CLICK, unloadbtn3);
//VOLUME BUTTON ROLL OVER FUNCTION EVENT LISTENERS ///////////////////////////////////////
btn_vol.addEventListener(MouseEvent.ROLL_OVER,vol);
btn_vol.addEventListener(MouseEvent.ROLL_OUT,volout);
btn_loc.addEventListener(MouseEvent.ROLL_OVER,coursel);
btn_loc.addEventListener(MouseEvent.ROLL_OUT,corlist);
// FUNCTIONS INITIATED /////////////////////////////////////////////////////////////////
function fl_ClickToGoToNextFrame(event: MouseEvent): void
{
nextFrame();
}
function backbtn(event:MouseEvent):void{
prevFrame();
}
function fl_ClickToGoToWebPage(event: MouseEvent): void {
navigateToURL(new URLRequest("https://www.onlineinduction.com/fmgl/courselist.php?ist=2&type=Vendor Employee Inductions"), "_self");
}
/////////////////////////////////////////////////////////////////////
//VOLUME BUTTON ROLLOVER EFFECT FUNCTION
function vol(e:MouseEvent):void
{
addChild(volbutton1);
//popup_instance.width = 675;
//popup_instance.height = 300;
if(this.currentFrame == 2)
{
volbutton1.x = 150;
volbutton1.y = 528;
}
else{
volbutton1.x = 278;
volbutton1.y = 528;
}
}
function volout (e:MouseEvent):void {
removeChild(volbutton1);
}
function coursel(e:MouseEvent):void {
addChild(clist);
if(this.currentFrame == 2)
{
clist.x = 85;
clist.y = 532;
}
else if(this.currentFrame == 5){
clist.x = 115;
clist.y = 325;
}
else{
clist.x = 175;
clist.y = 532;
}
}
function corlist (e:MouseEvent):void {
removeChild(clist);
}
////////////////////////////////////////////////////////////////////////////////////
function loadnotice1(Event:MouseEvent):void//FRAME 9 FUNCTION FOR IMPORTANT NOTICE
{
if ( count == 1 && stage.contains(pop1))
{
removeChild(pop1);
}
if(count == 1)
{
nextFrame();
}
else
{
addChild(pop1);
pop1.x = 40;
pop1.y = 120;
count = 1;
}
trace("Counter Value:" + count);
}
function loadnotice2(Event:MouseEvent):void//FRAME 9 FUNCTION FOR IMPORTANT NOTICE
{
if ( count2 == 1 && stage.contains(pop2))
{
removeChild(pop2);
}
if(count == 2)
{
nextFrame();
}
else
{
addChild(pop2);
pop2.x = 40;
pop2.y = 120;
count2 = 1;
}
trace("Counter Value:" + count);
}
//////////////////////////////////////////////////
function loadnotice3(Event:MouseEvent):void//FRAME 9 FUNCTION FOR IMPORTANT NOTICE
{
if ( count3 == 1 && stage.contains(pop3))
{
removeChild(pop3);
}
if(count == 3)
{
nextFrame();
}
else
{
addChild(pop3);
pop2.x = 40;
pop2.y = 120;
count2 = 1;
}
trace("Counter Value:" + count);
}
///////////////////////////////////////////////////////
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;
}
}
function nextframe13(event: MouseEvent): void
{
if(count2 == 1 && stage.contains(pop2) )
{
removeChild(pop2);
}
if(count2 == 1)
{
nextFrame();
}
else
{
addChild(pop2);
pop2.x = 40;
pop2.y = 120;
count2 = 1;
}
}
///////////////////////////////////////////////////////
function nextframe17(event: MouseEvent): void
{
if(count3 == 1 && stage.contains(pop3) )
{
removeChild(pop3);
}
if(count3 == 1)
{
nextFrame();
}
else
{
addChild(pop3);
pop3.x = 40;
pop3.y = 120;
count3 = 1;
}
}
//////////////////////////////////////////////////////////////////////////////////
function backbtnscript1(event:MouseEvent):void
{
if(stage.contains(pop1) )
{
removeChild(pop1);
backcounter = 1;
trace("back" + backcounter);
}
prevFrame();
}
function unloadbtn1 (e:MouseEvent):void {
removeChild(pop1);
}
////////////////////////////////////////////////////////////////////////////////
function backbtnscript2(event:MouseEvent):void
{
if(stage.contains(pop2) )
{
removeChild(pop2);
backcounter2 = 1;
trace("back" + backcounter2);
}
prevFrame();
}
function unloadbtn2 (e:MouseEvent):void {
removeChild(pop2);
}
////////////////////////////////////////////////////////////////////////////////
function backbtnscript3(event:MouseEvent):void
{
if(stage.contains(pop3) )
{
removeChild(pop3);
backcounter3 = 1;
trace("back" + backcounter3);
}
prevFrame();
}
function unloadbtn3 (e:MouseEvent):void {
removeChild(pop3);
}
//SLIDE COUNTER
and here is the Code on all the Frames where I need to call in specific Listeners
FOR EXAMPLE ON FRAME 8,9,10,
Here Is the Code ,
FRAME 8
stop();
slidecounter.text = String(this.currentFrame - 1 + "/" + indexframe);
count = 0;
backcounter = 0;
btn_nxt.addEventListener(MouseEvent.CLICK , fl_ClickToGoToNextFrame);
btn_bck.addEventListener(MouseEvent.CLICK, backbtn);
btn_bck.removeEventListener(MouseEvent.CLICK , backbtnscript1);
btn_nxt.removeEventListener(MouseEvent.CLICK , nextframe9);
pop1.closebtn.addEventListener(MouseEvent.CLICK, unloadbtn1);
//btn_notice1.addEventListener(MouseEvent.CLICK , loadnotice1);
FRAME 9
stop();
slidecounter.text = String(this.currentFrame - 1 + "/" + indexframe);
//POPUP FUNCTION
count = 0;
btn_nxt.removeEventListener(MouseEvent.CLICK , fl_ClickToGoToNextFrame);
btn_bck.removeEventListener(MouseEvent.CLICK, backbtn);
btn_bck.addEventListener(MouseEvent.CLICK , backbtnscript1);
btn_nxt.addEventListener(MouseEvent.CLICK , nextframe9);
btn_notice1.addEventListener(MouseEvent.CLICK , loadnotice1);
FRAME 10
stop();
slidecounter.text = String(this.currentFrame - 1 + "/" + indexframe);
count = 0;
backcounter = 0;
btn_nxt.addEventListener(MouseEvent.CLICK , fl_ClickToGoToNextFrame);
btn_bck.addEventListener(MouseEvent.CLICK, backbtn);
btn_bck.removeEventListener(MouseEvent.CLICK , backbtnscript1);
btn_nxt.removeEventListener(MouseEvent.CLICK , nextframe9);
pop1.closebtn.addEventListener(MouseEvent.CLICK, unloadbtn1);
I am repeating this Pattern on each frame set where I need these Listeners ,
Problem is with the next one where I have two consecutive frames have different conditions to meet, any ideas how would I disable and enable listeners respectively on these frames ?
I hope I am not confusing this very much ?;(
Copy link to clipboard
Copied
There's a bit too much code for me to tell what the problem is. If you can limit what you show to the code that is giving you a problem it will help.
A quick review of your nextframe9 function makes me wonder about it. Regardless whether or not pop1 is present, you add it anyways, and the count doesn't change when you do.
Copy link to clipboard
Copied
Thanks man , I wil try to sqeezet a little if I can , I am just new so I am asking a lot of Dumb questions I know.
as of nextframe9 is concerned , I am trying to ensure that if the Movie Clip (pop1) is already on the stage when user clicks that , and count has already gone 1 since it popped up , the event listener should remove it off the stage and move on to next Slide , Idea is that we donot let the user Ignore the Notice. its working for me for now , unless of course if I am doing something fundamentally wrong here:(
HERE IS WHY I DID WHAT I DID
function nextframe9(event: MouseEvent): void
{
if(count == 1 && stage.contains(pop1) )) //CONDITION ONE , When user has clicked btn_notice and poped the Notice manually but didn't close it, then Counter would be 1 and therefore if now he clicks on NEXT Button , there is no need to pop the Notice again and move on.
{
removeChild(pop1);
}
if(count == 1)//CONDITION TWO , When user has clicked btn_notice and poped the Notice manually and closed it so there is nothing on the stage at the moment, then Counter would be 1 and therefore if now he clicks on NEXT Button , there is no need to pop the Notice again and move on.
{
nextFrame();
}
else )//CONDITION THREE, When user Forgot to check the Notice and tried to move on , in that Case if he clicks on Next , the Next button should pop the Movie clip open.
{
addChild(pop1);
pop1.x = 40;
pop1.y = 120;
count = 1;
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now