Convert a C++ program to AS

I don’t know how good people are at AS here, but there’s one thing I’ve been wanting to convert to AS for ages, but not sure on how to go about doing it - I understand the basic process of this fire drawing routine in C++ but not how to turn it into something Flash can do

If anyone has patience and leet skill…this is the effect:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=2348&lngWId=3