Posts Tagged ‘Flash’

PHP urlencode() and urldecode()

Friday, April 16th, 2010

</p>
<p>&lt;?php</p>
<p> $testString = &quot;This is a test &#8216; with &#8216; several apostrophes&#8217;&quot;;<br />
 echo $testString . &quot;&lt;br /&gt;&quot;; // This is a test &#8216; with &#8216; several apostrophes&#8217;<br />
 $testString = urlencode( $testString );<br />
 echo $testString . &quot;&lt;br /&gt;&quot;; // This+is+a+test+%27+with+%27+several+apostrophes%27<br />
 $testString = urldecode( $testString );<br />
 echo $testString . &quot;&lt;br /&gt;&quot;; // This is a test &#8216; with &#8216; several apostrophes&#8217;<br />
?&gt;</p>
<p>

Adobe Air, SQLite, and apostrophes

Tuesday, March 16th, 2010

I’m currently developing an Air application and I run into a problem inserting file names with apostrophe (because apostrophe are used as string delimiter). There are several ways to handle this problem. You can add two apostrophes, and Jake Churchill has made a function for this.

While working with back-end I’ve used PHP’s utf8_encode edit: I meant rawurlencode() quite a lot, and AS3 has several similar functions, but there is only one that encodes apostrophes, and it’s called escape(). So what you can do is escape() the strings to be inserted into SQLite, and use unescape() after receiving the string back from the database.

Here is an example with escape() and unescape() used in AS3:

var testString:String = &quot;This is a test &#8216; with &#8216; several apostrophes&#8217;&quot;;<br />
trace( testString ); // This is a test &#8216; with &#8216; several apostrophes&#8217;<br />
testString = escape( testString );<br />
trace( testString ); //This%20is%20a%20test%20%27%20with%20%27%20several%20apostrophes%27<br />
testString = unescape( testString );<br />
trace( testString ); //This is a test &#8216; with &#8216; several apostrophes&#8217;

Here is an example with rawurlencode and rawurldecode() used in PHP:

$testString = &quot;This is a test &#8216; with &#8216; several apostrophes&#8217;&quot;;<br />
 echo $testString . &quot;&lt;br /&gt;&quot;; // This is a test &#8216; with &#8216; several apostrophes&#8217;<br />
 $testString = rawurlencode( $testString );<br />
 echo $testString . &quot;&lt;br /&gt;&quot;; // This%20is%20a%20test%20%27%20with%20%27%20several%20apostrophes%27<br />
 $testString = rawurldecode( $testString );<br />
 echo $testString . &quot;&lt;br /&gt;&quot;; // This is a test &#8216; with &#8216; several apostrophes&#8217;

Sound visualizer in Flash

Tuesday, April 28th, 2009

Per Kristian Stoveland held a cool presentation of his Sound Spectrum Analyzer at FUGN (Flash user group Norway) in the beginning of April. Inspired by this session I decided to try this my self.
I remembed seeing a beutifull graphic called “Imagination” made by Paul Neave, which he also had released as open source. So I grabbed my copy of it and tweaked a little bit and instead of mouse interaction I hooked it up with the SoundMixer.computeSpectrum() in Flash. I turned out pretty cool I think!
This is my first attempt so there will be more to come. The source code need to be cleaned up so I will release it later. The awesome soundtrack is by virgill & tasium.

Check it out!

soundvisualizer

Colin Moock, James Patterson and Hoss Gifford with new training video

Saturday, April 25th, 2009

Colin Moock, James Patterson and Hoss Gifford has put out a new training video series called:  “The lost Actionscript 3 weekend”. You can download some free chapters and after watching them I must say I’m going to buy the DVD’s. Use this link to get a discount.

It’s impressive that Colin Moock manage to outtalk both Hoss Gifford and James Patterson, and at the same time! :-)

Check it out!

The lost Actionscript 3 weekend

Flash on the Beach

Tuesday, September 30th, 2008

 Flash on the beach 2008

I’m currently on Flash on the Beach in Brighton. I were here last year and it strucked me then how well organized this conference was, and I must say it lives up to its reputation this year as well. This year I’m together with Hågen Landsem, which actually was my teacher at school, and of course all the other guys from Norway (and the rest of the world for that matter).

One thing we’ve noticed is that FOTB08 is a little bit more technical than last year; the Flex/Air session is dominating more now. This is a trend that runs the hole Flash community. This was something Hågen and I talked about yesterday, and It was interesting to hear some speakers expressed their concern about this evolution as well. One of the speakers that addressed this was Aral Balkan, he had a very nice session that was both entertaining, inspiring and an eye opener for many I think. He talked about the simplicity of AS1 compared to AS2, and especially AS3 and how this might be negative for the Flash community. That it might leave some of the creative people out of the Flash community, and those are, by my opinion, the most important users of the Flash platform. It is the creative part that has brought Flash to what it is today.

Anyway, we had a short chat when he was done and he really seems like a nice guy. I think it is very important that guys like Aral Balkan speak up about this.

Flash and SEO

Monday, May 12th, 2008

Flash and SEO has been quite a problem and the main argument for the people in the business who is against Flash. I’ve planned to do something about this for a long time and finally I found a project that was suitable to try this. First I will say that many people think that making a website completely in Flash is craziness, and very often I do agree. However sometimes the client wants a “flashy” site with lots of animations and stuff and how am I to deny them that?

Since the introduction of SWFObject it’s been quite easy to provide the user with html content for those who does not have flash installed, and this is what I’ve done. Since I use amfphp a lot and also for my little CMS for flash, all the content except from the images are stored in a mySQL database. This makes it easy to extract all the content and echo it out in the flashcontent div tag.

I did this for a project called moelo.no and after a while Google index the whole site. To make it even more search friendly I used Apache Rewrite Engine to replace the query string URL with more search friendly URLs. I was surprised how easy easy it was to write the rewrite rule. Here is the all the lines I had to write to make it work:

RewriteRule ^kategori/([0-9]+)/underkategori/([0-9]+)/prosjekt/ ([0-9]+)(.*)\.html$ index.php?KategoriID=$1&UnderkategoriID=$2&ProsjektID=$3
RewriteRule ^kategori/([0-9]+)/underkategori/([0-9]+)(.*)\.html$ index.php?KategoriID=$1&UnderkategoriID=$2
RewriteRule ^kategori/([0-9]+)(.*)\.html$ index.php?KategoriID=$1

Now basically what this does is rewrite a url that looks like this:

http://www.moelo.no/index.php?KategoriID=1&UnderkategoriID=6

to this:

http://www.moelo.no/kategori/1/underkategori/6/

Then I add a suffix that takes the title of the article as filename and adds a .html extension to the end to to the URL to make it even more search friendly. The rewrite engine rules just ignores this. Now the URL looks like this:

http://www.moelo.no/kategori/1/underkategori/6/boliger.html

The next trick was to actually show the right content in the flash version as well when a user clicked a link in Google. I did this very easy by passing the arguments to SWFObject and this way I could load them as variables in flash:


var so = new SWFObject("http://www.moelo.no/index.swf", "index", "1000", "600", "8", "#ffffff");
so.addParam("quality", "best");
so.addVariable("kategoriid", "4");
so.addVariable("underkategoriid", "15");
so.addVariable("prosjektid", "122");
so.addVariable("forsiden", "");
so.write("wrapper");

Finally I added a rule in the robot.txt file that blocks the SWF-file from all robots.

It works like a charm!

The next job is to rewrite my hole flash based CMS into OOP because the hole shit is written in procedural code. This happened because it started as a minor project a long time ago and it has escalated for each project, and this makes it a pain in the ass to update and maintain.