Its been ages since my last post, but thought I’d share a class I used in a recent job, that involved building a Annuity Calculator in Flex.

Really straight-forward…it consists of two methods, one returning PMT (installment amount), and the other PV (Present Value).

We pass the Interest Rate (IR), Present Value (PV) and Repayment Term to the calculatePMT() method and return the PMT, and the other way round…we pass the Monthly Installment (PMT), Interest Rate (IR) and Repayment-Term to the calculateBond() method, to return the Present Value(PV).

I hope this helps somebody, as I couldn’t find many recourses out there for Annuity Calculators and ActionScript….ENJOY!!!

package customclasses {

public class PmtCalc {

public function calculatePMT(PV:Number, IR:Number, YEARS:Number):Number {

var newIR:Number = IR/12;
var newNP:Number = YEARS*12;

return Math.round((PV*(newIR/100)) / (1-Math.pow(1+(newIR/100), -newNP)));
}

public function calculateBond(PMT:Number, IR:Number, YEARS:Number):Number {

var newIRb:Number = (IR/100)/12;
var newNPb:Number = YEARS*12;

var v:Number = Math.pow(1+newIRb, -newNPb);
var pv:Number = PMT*(1-v)/newIRb;

return Math.round(pv);
}
}
}

Comments 4 Comments »

There’s a new tutorial available for download from the tutorials management app.

This tutorial is based on the example provided by Yahoo developers Network. It will take you through all the steps to create a simple Flex3(ActionScript 3) Application that utilises webservicesx’s GeoIPService WebService and the system.Capabilities class to collect user information, and then display the user’s country on a Yahoo Maps Mashup.
-Package Download: .rar file at 36MB (Includes ASTRA Yahoo Maps API)
-Video Tutorial: Yes
-PDF Tutorial: Yes
-Source included: Yes

View the sample app here.

Please leave comments and suggestions ;)

Comments 6 Comments »

I recently started using Flex 3 Beta 2, as the trial period for Flex 3 Beta 1 ended. After adding my service as a compiler argument (-services “services-config.xml”), I was getting the following error: Invalid endpoint port ‘ ‘ specified for channel definition ‘bytearray-amfphp’.

This prompted further investigation, and after reading through a few blogs, posts and bug reports, I seemed to have found the reason.

Due to changes to the Flex compiler, and it’s arguable if it’s actually a bug or not, we can NO LONGER specify the full URI of the ‘gateway.php’ file on line 17 of our ’services-config.xml’ file the way we used to:

However, there are two solutions/workarounds. The first will solve the problem, but create a new one, being that you will receive an error when using FireFox(unless you are using the latest Flash Player Plug-in, version 9,0,60 at the time of this post). To do this, we need to specify a port(80) in our URI:

The final workaround is to specify a relative URI. This is great, because I got it working on multiple player versions, but it forces us to install AMFPHP on our web root:

Please note:
[quote]
URI = “/myamfphp/gateway.php” - this works fine if myamfphp is in the ROOTDIR of my webserver .
URI=”myamfphp/gateway.php” - this doesnt work because it’s getting changed to “http:myamfphp/gateway.php” .
[/quote]

It seems that this is the only workaround I could find. If somebody has more information, or a different method, please leave a comment ;)

Further reading:
http://bugs.adobe.com/jira/browse/SDK-13050
http://bugs.adobe.com/jira/browse/SDK-12908

Comments 10 Comments »

One of our goals here at The LibLab Tutorials, is to build a comprehensive development environment reference library. I have just added the first of many to come, on the topic of Installing and testing AMFPHP on a web-server. Please use our tutorials management app to view the sample media, or download the entire package.

Comments No Comments »

I have added a new, comprehensive tutorial to the tutorials management app. It’s free, and you can download the .rar package. The package contains a Video tutorial, as well as a PDF version.

It’s quite lengthy, covering everything from creating a new AMFPHP service and Flex project, to sending the customizable drag-and-drop text and an image as a JPG encoded ByteArray to the server. From there, we save the JPG on the server, and email it in MIME format.

You can view the sample app here.

I hope you enjoy it. Please leave comments and suggestions…;)

Comments 6 Comments »

Hi and welcome to our new tutorials page / blog.

Check back soon for more content…and engaging tutorials.

Comments 10 Comments »