Avatar of nth1971
nth1971
 asked on

eventListner parameters and functions

Hi can anyone advise why my parameters are not being passed into the function

hoverGrow.addEventListener(MouseEvent.MOUSE_UP, DeltaShareExp(315000, 350));
hoverGrow1.addEventListener(MouseEvent.MOUSE_UP, DeltaShareExp(280000, 350));
hoverGrow2.addEventListener(MouseEvent.MOUSE_UP, DeltaShareExp(315000, 1150));
hoverGrow3.addEventListener(MouseEvent.MOUSE_UP, DeltaShareExp(200000, 1150));
hoverGrow4.addEventListener(MouseEvent.MOUSE_UP, DeltaShareExp(315000, 28000));
hoverGrow5.addEventListener(MouseEvent.MOUSE_UP, DeltaShareExp(595000, 28000));





function DeltaShareExp(event:Event, startingNumber:Number, endingNumber:Number):void
{
	var i:uint = 1;
	var myTimer:Timer = new Timer(10,100);
	myTimer.addEventListener(TimerEvent.TIMER, function(event:TimerEvent):void 
	 {
		 
	  var xNum:Number = startingNumber - i++ * endingNumber
	    myText.text = String(xNum); 
	  
	});
	myTimer.start();
}

Open in new window

Adobe Flash

Avatar of undefined
Last Comment
nth1971

8/22/2022 - Mon
nth1971

ASKER
i've kind of done it but it seems like a lot of code.. is this the best way??

hoverGrow.addEventListener(MouseEvent.MOUSE_UP, function(event:MouseEvent):void{  
						   var startingNumber:Number = 315000;  
						   var endingNumber:Number = 350;  
						   var deltaDrop:Boolean = true;
						   DeltaShareExp(event, startingNumber,endingNumber,deltaDrop);  

 }); 
hoverGrow1.addEventListener(MouseEvent.MOUSE_UP, function(event:MouseEvent):void{  
						   var startingNumber:Number = 280000;  
						   var endingNumber:Number = 350;
						   var deltaDrop:Boolean = false
						   DeltaShareExp(event, startingNumber,endingNumber, deltaDrop);  

 }); 
hoverGrow2.addEventListener(MouseEvent.MOUSE_UP, function(event:MouseEvent):void{  
						   var startingNumber:Number = 315000;  
						   var endingNumber:Number = 1150; 
						   var deltaDrop:Boolean = true
						   DeltaShareExp(event, startingNumber,endingNumber, deltaDrop);  

 }); 
hoverGrow3.addEventListener(MouseEvent.MOUSE_UP, function(event:MouseEvent):void{  
						   var startingNumber:Number = 200000;  
						   var endingNumber:Number = 1150; 
						   var deltaDrop:Boolean = false
						   DeltaShareExp(event, startingNumber,endingNumber, deltaDrop);  

 }); 
hoverGrow4.addEventListener(MouseEvent.MOUSE_UP, function(event:MouseEvent):void{  
						   var startingNumber:Number = 315000;  
						   var endingNumber:Number = 2800; 
						   var deltaDrop:Boolean = false
						   DeltaShareExp(event, startingNumber,endingNumber, deltaDrop);  

 }); 
hoverGrow5.addEventListener(MouseEvent.MOUSE_UP, function(event:MouseEvent):void{  
						   var startingNumber:Number = 595000;  
						   var endingNumber:Number = 2800;
						   var deltaDrop:Boolean = true
						   DeltaShareExp(event, startingNumber,endingNumber, deltaDrop);  

 }); 





function DeltaShareExp(event:Event, startingNumber:Number, endingNumber:Number, deltaDrop:Boolean):void
{
	var i:uint = 1;
	var myTimer:Timer = new Timer(10,100);
	myTimer.addEventListener(TimerEvent.TIMER, function(event:TimerEvent):void 
	 {
		 
		 if(deltaDrop == true){
	  var xNum:Number = startingNumber - i++ * endingNumber
	  myText.text = String(xNum); 
		 }else{
	  var xNum2:Number = startingNumber + i++ * endingNumber 
	  myText.text = String(xNum2); 
		 }
		   
	});
	myTimer.start();
}

Open in new window

ASKER CERTIFIED SOLUTION
dgofman

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
tomaugerdotcom

DISCLAIMER: you're not meant to copy and pasted my code verbatim as I typed it directly into the EE editor and haven't done any testing. There are certainly typos. Sorry about that.
nth1971

ASKER
Tom, Interesting particularly the way you have approached it... take a while to absorb this but I get the gyst and I understand what you say in the first comment so thanks that really helps.... and thanks dgofman works perfectly.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes