php v as3
coworker: “You have to base64_decode that string to get your xml”
me: “base what?”
This is really geeky, so I’ll spare you if you’re not interested.
1. open google, type base64_decode
2. First link is php’s base64_decode function
3. open jedit, type:
echo(base64_decode(’blahblah’);
4. Save file
5. Open file in web browser
6. Yay! It returns what I expected
total time: 5 minutes
Now to do it in actionscript 3
1. search as3 base64_decode, nothing good
2. search as3 base64 decode, still nothing
3. search actionscript bas64 decode
4. found the perfect thing on dynamicflash blog
5. site wasn’t working properly; couldn’t download files
6. found this but can’t figure out how to download file. Can’t copy/paste due to line numbers in code
7. go back to dynamicflash. Blog owner works for the company I work for
8. do internal search of the guy
9. IM him and hope that he’s still at work
10. he fixes the blog
11. download file
12. open flex builder, create new sandbox project
13. copy & paste in downloaded class files into project
14. type
{
import dynamicflash.util.Base64;
public class sandbox() {
trace(Base64.decode(’blahblah’));
}
}
15. Compile in debug (auto opens firefox)
16. Switch back to flex builder to see result of trace.
17. Yay it worked.
total time 1 hour
To be fair, Adobe app development is still “gorgeous sexy“, but sometimes it makes me want to punch something.
Yes. Yes yes yes.
One beautiful thing about a popular, solutions-oriented open source language like PHP is that people have almost inevitably already solved the problem you have, and it’s usually pretty easy. It’s jarring to move between PHP and a closed, proprietary language like AS3 for this reason.
December 24th, 2007 at 3:42 am
I love PHP more than I love most foods.
December 25th, 2007 at 9:45 pm
@Ed. It’s an interesting new experience that I’m slowly getting used to.
@Andrew. I think I love most foods more than php :)
December 26th, 2007 at 4:54 am
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/58407
decode64.(”mystring”)
:P
December 26th, 2007 at 5:44 pm
Umm mx.utils.Base64Encoder : http://livedocs.adobe.com/labs/flex3/langref/mx/utils/Base64Encoder.html ?
Added in Flex 3, but quite usable.
January 2nd, 2008 at 11:00 pm
Here’s a link to something you will find very useful:
http://metal.hurlant.com/blog/index.php?s=as3crypto
Handles most of your encryption/decryption needs and also has a pretty slick Base64 class too. It’s written by my boss. I won’t name names since he doesn’t publicly use his name on the blog, but you know where to look it up. ;)
Enjoy!
-Jeremy
January 3rd, 2008 at 9:16 pm
@Michael Thanks for the tip. Perhaps in the next release they’ll do decoding too.
@Jeremy sweet :)
January 4th, 2008 at 9:49 pm
@Ed, ActionScript is actually ECMA aka JavaScript which is an open standard. Flash is (correct me if I’m wrong) the only platform to fully support the entire ECMA standard.
January 14th, 2008 at 9:56 pm
Who is still using PHP?!
RoR is the future ;)
January 15th, 2008 at 4:39 am
Glad to see another fellow blogger using jEdit. I do all my own development using just that single editor - powerful!
January 15th, 2008 at 11:25 pm
at the risk of sounding like a geek of the anal kind, i do believe you meant to write:
echo ( base64_decode ( ’blahblah’ ) );
*ducks*
but, ya, php rocks :)
February 5th, 2008 at 1:15 am
@Hans HAHAHA! but you’re wasting precious horizontal space! Though, that’s not nearly as bad as wasting vertical space:
function
{
}
vs
function {
}
February 5th, 2008 at 3:32 am