Categories
AS3 Flash

Twitter RSS reader – part 2

This is a “must-read” update for twitter rss reader in flash as3.


read here the complete (dutch) error message

Stupid, stupid, stupid, I already knew this: Flash cross-domain security.
Which simple says that it’s not allowed to “get” anything from another website unless the server has a crossdomain.xml.
The nasty part is that, while you are testing in Flash IDE nothing goes wrong. So I only bumped into this when I put it on my server…

So what to do?

  1. Ask Twitter to change there crossdomain.xml and add my domain…… (is this really an option?)
  2. Find something around the crossdomain security from Flash

Luckily solution two is the easiest one: use a proxy to get the data we want.
Because PHP doesn’t have the same restrictions as Flash has we will be using a proxy.php.

This is how it works: Flash wants a crossdomain.xml if you “get” data from another server, but if you “get” data from the same server there is no problem. So we will be asking the proxy.php to “get” the xml/rss and serve it to Flash.

So instead of loading the data directly from Twitter
http://twitter.com/statuses/user_timeline/27657030.rss
We will be using the proxy instead
http://yoursite.com/xml_proxy.php?url=http://twitter.com/statuses/user_timeline/27657030.rss

I didn’t write the proxy myself:
The proxy that I used can be found here: http://xmlrpcflash.mattism.com/proxy_info.php (it has some extra explanation about the subject )
This proxy can be use for all sorts of xml, and any server.

As always I’m reinventing the wheel: this group needed a specific solution but is nice to read more about it:
http://woveninteractive.net/2009/02/twitter-in-flash-getting-past-the-securityerrorevent/
They wrote something similar, but a proxy more specific suited for twitter and the use of twitterscript.

Update #1: I found another proxy.php (I really don’t think you need another, but choices are nice πŸ˜€ ).
PHP Proxy Script for cross-domain requests
Sorry for the dutch error… I have a dutch version of XP (not my choice)

Error #2044: Niet-afgehandelde securityError:. text=Error #2048: Schending van beveiligingssandbox: http://emceekay.nl/paper/flash/twttr.swf kan geen gegevens laden van http://twitter.com/statuses/user_timeline/27657030.rss.
at nl.emceekay.twttr::TwttrBase/getFeed()
at nl.emceekay.twttr::TwttrMain()
Categories
AS3 Design Flash Urban papercraft

Twitter rss reader in Flash as3

Update #1: must read this post, otherwise this code will fail when you place it on your server!

I recently started my own company (eMCeeKay.nl) and I need to make a website for it…. Not really a problem besides that I don’t have any time to create a design.

So I was thinking about a easy way to update this website without spending extra time on that.

Because the main focus of the company is papertoys (urban papertoys), I need design or papertoy related info in my my new website ().

And I came with two ways to update it without extra effort: twitter (I tweet about a lot of stuff but primarily about papertoys) and this the content on this blog (category: urban-papercraft).

I started with the Twitter part.
There are two Twitter AS3 libraries that “speak” to the Twitter API: twitterscript/ and tweetr/.
But after reading the source I concluded that it was a little bit to much: I don’t want to tweet from emceekay.nl or do searches, so that was not the way to go.

A little google search gave me the solution: http://www.theflashlogs.org/flash/displaying-twitter-feeds-in-flash-with-rss/, simple using the standard rss from Twitter (in my case: Matthijs Kamstra – Twitter – rss).

The code on theflashlogs.org is pritty simple, and very easy to use.
So my code is a little addition to that, I need some stuff done to the rss feed:

  • remove “MatthijsKamstra:” form the title
  • convert @paperkraft to a link
  • convert #Mecha6 to a link
  • convert http:// to a link

Here is my code:
[as light=”false” wraplines=”false”]
package nl.emceekay.twttr
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.text.TextField;
/**
* // nl.emceekay.twttr.TwttrExample
* …
* @author Matthijs Kamstra aka [mck]
*/
public class TwttrExample extends MovieClip
{
//default: http://twitter.com/matthijskamstra
private var url:String = "http://twitter.com/statuses/user_timeline/27657030.rss";

private var _txt:TextField;

public function TwttrExample()
{
stage.scaleMode = "noScale";
stage.align = "TL";

// generate textfield
_txt = new TextField()
_txt.x = 10;
_txt.y = 10;
_txt.width = stage.stageWidth – 20;
_txt.height = stage.stageHeight – 20;
_txt.wordWrap = true;
_txt.multiline = true;
_txt.autoSize = "left";
addChild(_txt);

// start
getFeed(url);
}

//////////////////////////////////////// loading rss / show rss ////////////////////////////////////////

private function getFeed (inURL:String) : void
{
_txt.htmlText = "getting tweets";

var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onFeedHandler);
loader.load(new URLRequest(inURL));
}

private function onFeedHandler (e:Event):void
{
_txt.htmlText = "";
var _feed:XML = new XML(e.target.data);
var _item:XMLList = _feed.channel.item;
for each (var feedItem:XML in _item){
var _title :String = feedItem.title;
var _pubDate :String = feedItem.pubDate;
var _link :String = feedItem.link;

_title = convertTweet(_title);

_txt.htmlText += _title + "<br><i>" + _pubDate + "</i><br><br>";
}
}

//////////////////////////////////////// twitter specific ////////////////////////////////////////

// one place to convert the tweet
private function convertTweet (inString:String):String
{
var _str:String = inString;
_str = twttrStripName(_str);
_str = twttrConvertHTTP(_str);
_str = twttrConvertMention(_str);
_str = twttrConvertHashtag(_str);
_str = twttrConvertSmileys(_str);
return _str;
}

// remove the writers name from the tweet
private function twttrStripName (inString:String):String
{
var _str:String = inString;
var _charNumber:Number = _str.indexOf(":");
return _str.substr(_charNumber + 2);
}

// convert http-strings to links
private function twttrConvertHTTP(inString:String):String
{
var _str:String = inString;
var _array:Array = _str.split(" ");
for (var i:int = 0; i < _array.length; i++)
{
var _str2:String = twttrStripChar(_array[i]);
if (_array[i].indexOf("http") != -1)
{
_array[i] = "<u><a href=’" + _str2 + "’ target=’_blank’>" +_array[i] + "</a></u>";
}
}
return _array.join(" ");
}

// convert mentions (@) to links
private function twttrConvertMention(inString:String):String
{
var _str:String = inString;
var _array:Array = _str.split(" ");
for (var i:int = 0; i < _array.length; i++)
{
var _str2:String = twttrStripChar(_array[i]);
if (_array[i].substr(0, 1) == "@")
{
_array[i] = "<u><a href=’http://www.twitter.com/" + _str2.split("@")[1] + "’ target=’_blank’>" +_array[i] + "</a></u>";
}
}
return _array.join(" ");
}

// convert hashtags (#) to links
private function twttrConvertHashtag(inString:String):String
{
var _str:String = inString;
var _array:Array = _str.split(" ");
for (var i:int = 0; i < _array.length; i++)
{
var _str2:String = twttrStripChar(_array[i]);
if (_array[i].substr(0, 1) == "#")
{
_array[i] = "<u><a href=’http://twitter.com/search?q=%23" + _str2.split("#")[1] + "’ target=’_blank’>" +_array[i] + "</a></u>";
}
}
return _array.join(" ");
}

// TODO: [mck] convert πŸ™‚ to a smiley image
private function twttrConvertSmileys(inString:String):String
{
var _str:String = inString;
return _str;
}

// remove "strange" characters from the end of the string
private function twttrStripChar(inString:String):String
{
var _str:String = inString;
var _charArray:Array = [‘,’, ‘;’, ‘:’, ‘ ‘, ‘-‘, ‘_’];
for (var i:int = 0; i < _charArray.length; i++)
{
if (_str.charAt(_str.length – 1) == _charArray[i]) {
_str = _str.substr(0, _str.length – 1);
}
}
return _str;
}

} // end class

} // end package
[/as]

Currently I have only this proof of concept, but soon I will post the example on emceekay.nl

Because this is part one of what I want to do, and don’t want to search for every link again, I’m posting also the WordPress link here (it’s just because I’m lazy).

So here the feeds I will be using:

Categories
Design Urban papercraft

II LOVE mag – YEBOMAYCU

I’m in the latest edition of the II LOVE magazine from Marko Zubak

In this issue we will remain on the first phase of creation, the form. Here the accent is put on the sculptural aspect of denuded paper toys, giving an impression that each one of them represents it’s own species.
Here is shown a selection of more than 50 paper toys, but of course, there are lot of other different kinds of paper toys out there. Many great designs are left out because of various reasons and I feel really sorry for some of them.

by Marko Zubak, creator of II LOVE magazine

Download II LOVE magazine from YEBOMAYCU.

Categories
Misc

Inspirational stuff

World War – 3D Animation @ University Of Hertfordshire 2008 from Digital Animation Herts Uni UK on Vimeo.

World War was created by Vincent Chai for his final degree project whilst studying 3D Animation at the University Of Hertfordshire.

Vincent Chai portfolio:
http://www.vincentch20.co.uk/

visit http://www.uhanimation.co.uk to see more films created by the University of Hertfordshire Digital Animation 3D|VFX|2D|Games Art students.

Categories
Design Urban papercraft

Flickr gallery: Urban paper – part 2

I’ve already made a Urban paper series – part 1.

What do I mean with Urban paper? Paper with a street attitude…

But as “part 1” already implies; there is also a second gallery, here it is: my Flickr gallery about Urban paper – part 2.

Urban paper - part 2

I hope you like it, drop a comment if you want… here or at Flickr

Categories
Custom Design Urban papercraft

NOISSGrunny a MechaBunny custom

A while back Nick Knite asked me to create a custom for his MechaBunny.

I’ve created NOISSGrunny:
NOISSGrunny

But the Mecha6 are made by a all-star papertoy team: Scott Schaller, Shin Tanaka, Tougui, Castleforte, Marshall Alexander and ME.
The Mecha6 have arrived!!

Here the Nick Knite – MechaBunny slideshow on Flickr (including my custom):

Categories
Design Urban papercraft

Flickr gallery: Inspiration Papertoys – part 1

I’ve been playing (again) with Flickr galleries, and I made a papertoys series what should inspire you.

So here it is: my Flickr gallery: Inspiration Papertoys – part 1.

Inspiration Papertoys - part 1

I hope you like it

Categories
Design Urban papercraft

Flickr gallery: Urban paper – part 1

I’ve been playing with Flickr galleries, and I made a Urban paper series.

What do I mean with Urban paper? Paper with a street attitude…

So here it is: my Flickr gallery about Urban paper – part 1.

Urban paper - part 1

I hope you like it

Categories
Design Urban papercraft

Flickr gallery: Papertoy robots – part 1

I know that I haven’t been very active on my own blog, that doesn’t mean that I haven’t been busy!
Sadly I can’t tell a lot about that….

I the meanwhile I made a Flickr gallery about Papertoy robots – part 1.

A thumbnail gallery about papetoy robots
A thumbnail gallery about papetoy robots

I hope you like it

Categories
Design Urban papercraft

Lo Slungg

Finally I found some time to finish the templates from Lo Slungg. Sorry it took so long.

For the readers that don’t know Lo Slungg, here is a image:

Lo Slungg

Lo Slungg papertoy
Lo Slungg papertoy

And download the files for the WIP Lo Slungg template here:

The .ZIP file contains a .PDF
(You can use freeware like FilZip or 7zip to extract a .ZIP-file and read a .PDF with Acrobat or Foxit)

This is the first time I have an explanation page (the first page) with the templates. I couldn’t fit the explanation onto the templates, so don’t print the first page!.
Lo Slungg templates explanation page
Explanation page


And if you are interested in a custom you can find the Blank Lo Slungg template here:

The .ZIP file contains a .PDF
(You can use freeware like FilZip or 7zip to extract a .ZIP-file and read a .PDF with Acrobat or Foxit)

Do you like it?
Post a comment!