Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another Array question 1

Status
Not open for further replies.

69flash6900

Technical User
Dec 20, 2004
9
0
0
CA
Hi All,

I know this my second dumb question but this flash project has been dumped in my lap until we can get another developer and I am struggling with the limitations of actionscript.

Basically I have an array of numerical values pulled in from an asp page ( no problem there ) and I need to perform a number of different functions on this data depending on user choice.

This is so simple in C++ but I have no idea ( and cannot get a hint from the Flash documentation ) as to how to pass a function to the array to obtain the value(s) I need. Nothing complicated here as these are just standard financial functions.

Thanks for your help with this beginners question,

Chris
 
2 separate problems here

first flash dont come with any finanial functions i am aware of.....only a few basic math ones ....so you would have to write your own

second flash dont really allow you to pass a function to an array directly...however you can step through the array applying the function at each step and just modify the functions you will have to write anyway to accomodate this....the other approach would be to just write the functions which is prob easier to understand for someone following you and write an array prototype to handle functions....this is just adding a feature to the array to allow the functionality you require
somethin like

Code:
Array.prototype.calc = function(SomeFunction) {
	for (var i = 0; i<this.length; i++) {
		trace(SomeFunction(this[i]));
	}
};
aspArray = [2.6, 47, 0.991];
aspArray.calc(bill);
function bill(aspArray){
	payment = aspArray + 100;
	return payment
}
 
billwatson,

Many Thanks. It was a lot of work coding all of the functions that we needed but without your answer it would have beeen so much harder.

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top