Categories
Design Flash

2011 vs 2012

Update #1: I joint a gym to learn how to KickBoxing and Muay Thai! Here is the link to the site: http://www.samuraisports.nl/ (little warning: this website is not a beauty)
Update #2: Brummble the papertoy tribute to ThreeA vinyl: Heavy Bramble is online and ready for downloading: here.

It’s been a while … haven’t posted anything regular in a… year.
That would have been the year 2011: the year I became for the first time a dad.

So here a little update (for the one person who still reads this blog).

2011 and a little bit before that

I had big plans; I wanted to show everybody that my live didn’t change when I got a kid…
Boy…was I mistaken.
Don’t get me wrong: this has been the best year of my live!!
But the things I wanted to do this year, the plans I made… nothing of that happened.
My daughter happened! and everything else followed HER plans.

I wanted to be a part of her live and not only look after her in the weekends.
My girlfriend and I both decided to have a 4 days work week so my daughter only has to goes to the daycare center for 3 days.
The employer I was working for at that time didn’t want me to work 4 days. I tried to use a dutch-law: they said they would take me to court, etc, etc.
I don’t want to make this post about my former employer (if you want to know more about this story, just ask), so I decide that it would be best for the both of us to find another job (1.5 month before my daughter was born…. I know: I’m still bitter about that).
But here is the good news (remember: the best year of my live) I found a great new job at noprotocol.nl!!!
I could work there for 4 days, they are very flexible and an awesome group of talented people.
AND I didn’t miss anything daughter-related stuff, which I can recommend every dad to do: have a day alone with you kid.

So the first 6 month of the year 2011 is mostly about being a dad (boring stuff for people who don’t have kids, nothing to explain to the people who have them).

Professionally (during the day I’m a Flash Designer/Developer) I learned about Robotlegs, AS3-navigator, LoaderMax, etc. Had some interesting talks with the people of “the bigger boat” (group of freelancers). AND I can do the job in 4 days (sometimes with some creative time-management from my employer and myself) which I knew would be possible, but conformation is alway nice.
In the next 6 months of 2011 I started to think about what I wanted. What makes me happy, what is making me happy right now and what will make me happy in the future. I miss the feeling I had when I started to work as a junior designer: wanting to learn EVERYTHING to become a senior. But now I am a senior… what’s next? Do I want to be a programmer for the rest of my live? Questions that are not answered yet.

I’m also a papertoy designer (something I do at night). This year was not a good year for papertoys: I needed my sleep!
I have done 1 exhibition in Amsterdam and I did an exhibit at Sneakerness Amsterdam (also the first time that I sold papertoys).
Both exhibition was done the rest of the dutch papertoy designers (3eyedbear, Marshall Alexander, Dolly Oblong) and one german papertoy designer (Nick Knite).
For these events I made 2 new papertoys, but they will not be downloadable. Nick Knite and myself wanted to organize a papertoy calendar with papertoy designers we both like… sadly I had to cancel that: no time to start/finish it ðŸ™
All and all not very productive year.

2012

My live (and this blog) is more than just one specialty. So here a short list:

Flash / Development

This is my job, this is how I make a living… and Flash is Dead! (again). I’m not worried so I will keep learning even more about that subject. But I need more! I have made a small CMS in 4 weeks in PHP (what an ugly language is that!) but that didn’t excited me much.
So I want to learn haXe! I’m quite excited about this language so I will be writing about that soon.
I would love to lead a team… or join a group of flash/geek-superstars (whatever moves me forward)
I want to finish what I have started in 2011:

  • finalize (and improve) my project setup.
  • automate the stuff that I have to do over-and-over-again

Find out how a senior finds his “what’s next”
Start having coffee-meeting with the industry tech-directors/tech-team leaders/etc to answer BIG question
Will be joining the after-work-drink-on-friday with my colleagues more often (once a month)

Urban Papercraft / papertoy

I really have no plans for papertoys: I used to do this to relax, but last year I relaxed by sleeping.
There is still two books I wanted to write…. but I can’t promise that it will be finished this year.
You can always ask me for a workshop or lecture about papertoys: just let me know!

The graffiti inspired papertoys I do will not be downloadable: that will be my art and art can’t be given away 😀
So what can the fans download? I have created a toy based upon 3A vinyl toy: Brummble. That will be released very soon.
And more perhaps? Not really a plan for that but sometimes I get a tickle and that needs to be scratched… and the product of that scratching (now this metaphor is getting dirty) will be downloadable.
Can you ask me for exhibitions? Yes, please do. I like the idea that my work is art and not only a (paper)-toy.
That is also the reason that I have titled this paragraph “Urban”: urban-art, urban-toy, urban-paper that’s what I will be making.
Can you ask me for a papertoy book? Yes, please do. I have worked on two books with much pleasure and would be honored to asked for another.
Can you ask me for a custom? Yes you can… but time is very precious right now. So your project must be VERY interesting.
I have promised to finish a custom Zealot Guard from Abz, and that is what I will do. Why do this custom? This is a VERY exciting project by a (perhaps the only) female papertoy designer.
There are some plans to visit Germany for some workshops, but other than that I have no idea.
2012 will reveal itself to me as it goes towards 2013 😀

Blog

Now I have some energy back in the evening I will be writing again on this blog, but not as often as I did before 2011. I used to write every week. That will change to once a month: a ‘big’ post. The ‘big’ post will be a tutorial or something else that needs more explaining. That will mean that there will be at least 12 more posts. Between these ‘big’ posts there will be some papertoy related images (minimal writing).
I will be writing about haXe, so that will be exciting (for programmers). I think I can be of some help making haXe more accessible for the ‘normal’ programmer.

That is not the only way to follow me: I have a twitter account. here I talk about everything that interests me (design/development/sneakers/games/video/whatever)

Misc

When my daughter was born I quit the gym (it was too expensive). I wanted to find something cheaper… It turned out to be very cheap: I didn’t join a gym but I also didn’t do something else. This year I will be joining a gym…. and to be very specific: I want to try Kickboxing!
Another thing that I will do, or stop doing… Is doing things for free. And that goes also for friends and family; they will pay (not necessarily with money, but for free doesn’t work for me anymore)

I’m looking forward to 2012!

Categories
AS3 FDT Flash

FDT and ANT – part 2

Trying to build the ultimate build.xml in ANT: debug/production zip ftp version … etc: will save a lot of keystrokes in FDT4

source: http://twitter.com/MatthijsKamstra/statuses/25194997777

All the information about the ultimate build.xml can be found on the internet, so I will post the links and you can figure it out for yourself.

I used the build.xml made by Jankees van Woezik (Base 42) as the base of my ultimate ANT build file. You can read about it and download here: My workflow with ANT and FDT.

Because we work a little bit different I had to do some modifications (for example: I work with 2 swf: preloader.swf and main.swf and work on PC). I created a list of stuff that I wanted to do with ANT and behind the “wish” you find a link to the site I found the solution for the problem:

  1. base ant script >> http://blog.base42.nl/2009/12/11/my-workflow-with-ant-and-fdt/
  2. inspiration >> http://code.google.com/p/sekati/source/browse/trunk/build.xml
  3. install ftp protocol in fdt/eclips >> http://www.rumblingskies.com/blog/?p=75
  4. update version ant script >> http://github.com/base42/projectcreator/blob/master/original/flash/builders/ant/updateVersionFile.xml
  5. another update ant script >> http://www.sephiroth.it/weblog/archives/2010/01/update_your_app_version_using_ant_bui.php
  6. update Firefox (only works on OSX) >> http://epologee.com/blog/2009/focus-and-reload-pages-in-firefox-with-ant/
  7. html wrapper >> http://fdt.powerflasher.com/blog/?p=1392
  8. create folders >> http://code.google.com/p/sekati/source/browse/trunk/build.xml

Something like this needs some time to find its place in my workflow, and will be changed a lot. That is the reason why I’m not posting my ant file… not because it’s ugly or a secret… but because I need to refine it. 

Oh… I also have a small todo list (perhaps you could call it a nice-to-have-list)

As you can see, these are the thing that I don’t need a lot, but perhaps in the nearby future…


FTP (File transfer protocol)

Ant doesn’t have the FTP protocols default installed so you need to update FDT4/Eclipse.
You can find the explanation here: http://www.rumblingskies.com/blog/?p=75

Update #1:The locations of the files you need are changed so let me post the correct ones here:

Save these files in the following folder: C:\FDT\plugins\org.apache.ant_***\bin\

Update #2: hmmm jakarta-oro seems to be Retired… and I haven’t got time to figure this out right now…

You probably can add the zips you downloaded there, I extracted the two files and that worked for me. I did this in FDT4 and all I got was an alert about “The specified Ant runtime classpath does not include a tools.jar library…..” which I ignored (and without any problem).

After the installment of the two .JAR files you need an ANT script to get thing started which I just copied from the previous link:
[as light=”true” wraplines=”true”]
<target name="ftp_upload" description="uploads files through ftp">
<echo message="uploading files" />
<ftp server="123.456.78.90"
port="21"
remotedir="/www/ant_upload_test"
userid="my_user_id"
password="my_password"
passive="no"
depends="yes"
binary="yes">
<fileset dir="../bin" />
</ftp>
</target>[/as]


Update version

It’s a combination of writing a build.txt file and a Version.as file.
See what Jankees van Woezik did and I use the script from Sephiroth to have a building number that adds 1.


Firefox refresh

this feature is awesome in combination with ftp, so here the one who found the how: Eric Paul (epologee). Read more about it here: focus-and-reload-pages-in-firefox-with-ant

So downloaded the file, installed the firefox extension and gave it a run:
[as light=”true” wraplines=”true”]
<target name="focus Firefox and reload page">Execute failed: java.io.IOException: Cannot run program "open" (in directory "C:\foo\bar\test"): CreateProcess error=2, Het systeem kan het opgegeven bestand niet vinden
[/as]

After some googling, I found that it’s a OSX command that doesn’t work on Windows:

[as highlight=”1″ light=”true” wraplines=”true”]
<target name="focus Firefox and reload page">
<exec executable="open">
<arg line="-a Firefox" />
</exec>
<exec executable="flash/tools/fresno/fresno">
<arg line="-j ‘content.location.reload()’" />
</exec>
</target>[/as]

I haven’t found a solution that refreshes the page like Fresno does on Windows.
So the only thing I can think of is:

[as light=”true” wraplines=”true”]
<target name="Launch in Firefox (reload)">
<echo>Launch in Firefox (not really a reload)</echo>
<exec executable="H:/Program Files/Mozilla Firefox/firefox.exe" spawn="yes">
<arg line="${flashproject.preview.url}" />
</exec>
</target>
[/as]


Html wrapper

I changed the file a little bit (removed the history) not really difficult.


Folders

You get the idea….

(reminder for myself: http://fdt.powerflasher.de/docs/FDT_Ant_Tasks)

Categories
AS3 FDT Flash

Create SWC library from FDT

I use Greensock Tweening Platform a lot, it awesome. Download it (here for example) and you have everything you need.

Now I start working with SWC files and they are so compact: I love it.
But how do you get a library in a SWC? Google has an answer but it’s very complex.

The best answer is from Bruno Fonzi on

Twitter / Bruno Fonzi: How to create SWC librarie ….

How to create SWC libraries from FDT:
Right click Project > Run as > FDT Library
or
Menu > Run Configurations > Create new FDT Library

So start with a New Flash Project (the name you will use for this project will be the name of the SWC: in my case “Greensock_Tweening_Platform”) and copy the com folder from the Greensock ZIP into the src (of source) folder.

If you follow the instructions and create a SWC you will get an error about: UIComponent and Vector (depends on your Project properties).

So to fix this: follow the 2 red x’s

com > greensock > loading > display > FlexContentDisplay
I don’t use this one, so delete.

The next depends on the project properties (I used SDK: Flex 3.3 and Player Version 9 and there are no Vectors in Player version 9)
com > greensock > plugins > EndVectorPlugin
I can’t use this one, so delete this on too.

Create the SWC again and your done: you have one file with the Greensock Tweening Platform in it.

Categories
AS3 FDT Flash

FDT and ANT – part 1

Just started to work with FDT and wrote about my “troubles” (post#1 and post#2) with my transition from FlashDevelop.
(have to be very carefull what I say: “they” are watching me: here and here 😀 )

And it seems to be a very natural (geeky) thing to learn about ANT.

And where do you go to learn about ANT and SWF/Flash/FDT? (Google?)
After some tinkering all I got was: failed to create task or type fdt.launch.application

This post was very useful: FDT and ANT | A User’s Guide – Part I by Alan Klement.
Watch the videos (I’m not very fond of tutorial videos but in this case; they get the job done).
What I love about the “Video I: Getting Started” is the fact that it builds up from scratch. So watch this video when you want to know about ant-files/xml, how to open the ANT-View, how to open/execute an ANT-file.

The second video (Video II: Compiling a SWF) was what I really was looking for: how to export a SWF. Very nice because it starts from scratch.
And it gave me the answer I was looking for: why didn’t my ANT-file didn’t work (it about 3/4 of the video):

BUILD FAILED
[blabla]\source\a\example\build\build.xml:17: Problem: failed to create task or type fdt.launch.application
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any / declarations have taken place.

Solution is very simple, but if you don’t know, you will hate FDT and really it’s not it fault:
Goto the green “play” button with the brown bag, in the toolbar (one picture says more than a thousand words:)

Select the ANT-file you want to change (I have only one :D), goto to tab “JRE” and change the Runtime JRE to Run in the same JRE as the workspace and your done:

Very useful are the ANT-snippets and ANT-Build-template!
Download (created by Alan Klement) and “install” the ANT-template (how-to on this page but here the short version)

To add XML files templates go: Preferences > XML > XML Files > Editor > Templates and click import.

To add Ant snippets go: Preferences > Ant > Editor > Templates and click import.

I haven’t seen the second part of this tutorial: FDT and ANT | A User’s Guide – Part II but I will.
It seems to be focused on the use of the templates and snippets.

source:
FDT and ANT | A User’s Guide – Part I
FDT and ANT | A User’s Guide – Part II

Categories
FDT Flash

Missing in FDT after working with FlashDevelop

I love FlashDevelop but moved to FDT (read my other post about this subject)…
Not an easy thing (the biggest problem is that it totally not intuitive ) to do and I’m missing some stuff that I had in FlashDevelop.

CTRL+U to change the selected text to uppercase

Update #1: I have found it:
ToUpperCase = CTRL+SHIFT+X
ToLowerCase = CTRL+SHIFT+Y

CTRL+SHIFT+1 to “Promote member to class”

(there is a similar way to do this in FDT but not the same)

CTRL+SHIFT+Q to create a block comment
It is in FDT but I can’t get it to work so you have to work with CTRL+7 (toggle comment) which is a minor adjustment.

The auto-completing FlashDevelop is awesome!! With some tinkering (info here) you can get FDT in the same room but it’s still not the same. I’m used to write private variable with a prefix “_” (example: _variableName). When I want the variable name to autocomplete in FlashDevelop I just type variableName (without the “_” prefix because it stupidly positioned on the keyboard) and it will find it. In FDT you need to start with the prefix “_” otherwise it will ignore the variable name… why???

Also missing: Explore (Open “Project Manager” and right-click on a folder)
(can’t find it in FDT)

But I shouldn’t complain, there is a reason why I’m changing to FDT

Big plus from FDT:
CTRL+SHIFT+F to Format code which is not possible in Flashdevelop
SWC Browsing is limited in FlashDevelop
Cross Platform: FlashDevelop works only on Windows
Refactor: this is so awesome (and expensive!!!)

source:
http://blog.flashmech.net/2008/08/review-fdt-vs-flashdevelop/

Categories
AS3 FDT

Moving from FlashDevelop to FDT

Yes, its time, I need to…
So how to make the transition from FlashDevelop to FDT as easy as possible?

Let FDT react like FlashDevelop

And I don’t even have to break a sweat: the amazing Steven Sacks (creator of Gaia) wrote an article about it: read here.
The only two thing that I’m using are:
Open Window > Preferences

Under FDT > Editor > Code Assist copy and paste this into Auto activation triggers for AS, and set the delay to 0ms (zero).

abcdefghijklmnopqrstuvwxyz_. :

and

Under Problems > AS3 Problems:
Unresolvable > Unresolvable variable reference in E4X and Unresolvable member reference in dynamic object should both be set to Disabled (from Warning to Disabled).

The shortcuts I just left them as they where: I’m working in another program so I should use the shortcut given by that program.

Update #1: hmmm I noticed that I can’t live without CTRL+ENTER…. explanation here: Using CTRL-ENTER to compile ActionScript code in FDT. So now I have CTRL+ENTER and debug run: CTRL+SHIFT+ENTER 😀

short explanation (so I can do this quickly if something happens to FDT):

Under Preferences > Run/Debug > Launching at the bottom at Launch Operation: Select “Always launch the previously launched application

then

Under Preferences > General > Keys find (or type in “type filter text” – searchbox: “last”) a command called “Run Last Launched” and click Copy Command. Assign (binding) the shortcut CTRL-ENTER to the copied command and change “when” to Editing ActionScipt Source (no spelling mistake: it really says that) Editing ActionScript Source.
Do the same thing for the “Debug Last Launched” command and assign the shortcut : CTRL-SHIFT-ENTER and change the when to Editing ActionScipt Source.

I’m not sure if the stuff I wrote here is only for FDT4 but the way it was explained on the site previous mentioned didn’t work in FDT4

Some templates/snippets that are very useful

I used this plugin for my trace in FlashDevelop, so how to do this in FDT?

Update #2: I shouldn’t forget to mention CTRL+0 (read the shortcut list for FDT) which is the shortcut for “Quick Trace”. This one I use to trace variable for example and the trace template below for functions.
Update #4: This is really a reminder for myself, but if you need it you know where you can find it in FDT4.
Some minor adjustments like:

Preferences > FDT > Build Path change Source folders to “source” (I like source above src) and Output folder to “deploy” (I like deploy above bin)

Preferences > FDT > Code Style > Code Templates (Misc) to “Override System UserName – ${user}

Preferences > FDT > Editor goto “Folding” and uncheck “Folding enabled” (I like to see everything, comment also)

Preferences > FDT > Tools > Flash/Flash Help to add paths to Flash (in my case: “H:\Program Files\Adobe\Adobe Flash CS4\Flash.exe”) and the Flash help files (in my case: “H:\Program Files\Adobe\Adobe Flash CS4\en\First Run\HelpPanel\Help”)

Preferences > General > Web Browser change to “Use external Web browser” to my favourite browser: Firefox (no Google Chrome there yet)
You can add any browser that you want.

Update #5: visit http://www.rumblingskies.com/blog/?p=75 and add FTP capabilities to ANT.

You have to create a code-template/code-snippet:
go to Preferences > FDT > Editor > Templates

This is a template that resembles the trace I used in FlashDevelop
Trace:

trace ( "+ ${enclosing_type}.${enclosing_method}() - args: " + [ ${enclosing_method_arguments} ] );

and I found some other useful templates

Public method:

public function ${methodName}():${type} {
    trace(">> ${enclosing_type}.${methodName}() args: "+[]);
    ${cursor}
};

for some strange reason there is no shortcut for asdoc ðŸ™

ASDoc:

/**
 * ${cursor}	
 * @example	
 * @param		${enclosing_method_arguments}
 * @return	 	
 */	
 */
Update #3: (sadly if there are no param in the function “${enclosing_method_arguments}” will be printed..)

a switch a use a lot with FlashDevelop:

Switch:

switch (${value}) {
	case ${result}:
		trace ("${result}" +${result} );
		${cursor}
		break;
    default:
        trace("case '"+${value}+"':\r\ttrace ('--- "+${value}+"');\r\tbreak;" );
}

and the template for a singleton

Singleton: (from gskinner)

package ${enclosing_package} {

	/**
	* @author ${user}
	*/
	public class ${enclosing_type} {
	
		private static var _instance:${enclosing_type};
		private static var _allowInstantiation:Boolean;

		public static function getInstance():${enclosing_type} {
			if (_instance == null) {
				_allowInstantiation = true;
				_instance = new ${enclosing_type}();
				_allowInstantiation = false;
			}
			return _instance;
		}

		public function ${enclosing_type}():void {
			if (!_allowInstantiation) {
				throw new Error("Error: Instantiation failed: Use ${enclosing_type}.getInstance() instead of new.");
			}
		}
		
		${cursor}
	
	} // end class

} // end package

enough for now, here some other posts about the subject

Source:
http://blog.hydrotik.com/2007/11/19/fdt-30-code-templates/
http://www.breaktrycatch.com/useful-fdt-templates/
http://www.stevensacks.net/2010/04/30/setting-up-fdt-to-look-and-behave-like-flashdevelop/
http://www.gskinner.com/blog/archives/2006/07/as3_singletons.html
http://blog.flashmech.net/2008/08/review-fdt-vs-flashdevelop/
https://fosswiki.liip.ch/display/FLASH/Code+Snippets+for+FDT+and+Flex
http://cote.cc/blog/using-ctrl-enter-to-compile-actionscript-code-in-fdt
http://www.fdt.powerflasher.com/developer-tools/fdt-3/getting-started/shortcuts/
http://blog.flashmech.net/2008/10/fdt-tip-boost-your-code-assist/

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
AS3 Flash

What a Flash / ActionScript Developer needs to know

Yesterday I saw this post in my RSS feeds, and I just want to remember this (and make sure that I’m really a senior 😉 )

So here is a list of stuff you need to know when you say you are a senior Flash/ActionScript developer:
http://pv3d.org/2009/08/28/10-things-every-senior-flash-developer-should-know/

I don’t like to regurgitate so I only show you the top 10, for examples visit the list by John Lindquist

  1. The Elastic Racetrack
  2. FlexSDK, mxmlc, compc, and all that jazz
  3. Player Events, Custom Events, Event Bubbling
  4. Statements, Keywords, and Directives
  5. ASDoc
  6. Managing visual assets (images, fonts, CSS, etc)
  7. Arrays, Collections, Dictionaries, Mapping
  8. Programmatic motion (tweening, easing)
  9. OOP and Coding Against Frameworks
  10. Version control

And after reading this I remembered gskinner had a similar list:
http://www.gskinner.com/blog/archives/2009/07/flash_actionscr.html

This is a bigger list and a lot of comments, so you need to visit the list and read it and all its comments

Another post about the subject: “Things Every Flash Developer Should Know” –> http://gskinner.com/talks/things/

Categories
AS3 Flash

My first AIR app: SWF2GIF-banner – part 1

Sometimes, and I’m not very fond of them, I need to make banners…..
The animation part is not so bad, but making the different sizes…. that can be a drag.
And after you made the SWF banners, you also need to make the animation in GIF.

This is how I use to do it:

  1. make the SWF banner
  2. embed it in a html page with a background color that is not in the banner itself (a border around the SWF banner helps)
  3. make snapshots of the animation
  4. open photoshop >> (I used a action for this part….)
  5. place all the images in one document
  6. cut the browser from the screenshot
  7. select the background-color reverse the selection and cut
  8. make a animation from all the layers (end photoshop action)
  9. save

I have never made an AIR application but I think that it should be possible to make a SWF2GIF converter in AIR.

Stuff what I need to find out:

  • browse for a file
  • load that file into air
  • take snapshots of the animation
  • controle the frame rate of the animation
  • make a animated gif
  • save everything
  • etc.

Lets start with some basic:
I’m still working on CS3, and it seems that AIR default is installed with CS4
Installing the Adobe AIR update for Flash CS3

English: http://help.adobe.com/en_US/AIR/1.5/devappsflash/WS5b3ccc516d4fbf351e63e3d118666ade46-7fc3.html
Dutch: http://help.adobe.com/nl_NL/AIR/1.5/devappsflash/WS5b3ccc516d4fbf351e63e3d118666ade46-7fc3.html

You can also use FlashDevelop 3.0.1, AIR is also installed with that program and in combination with Flex sdk you don’t even need Flash.

Because I’m not finished with it (I will only work on it when I have to build banners) I will post now and then some parts of the code.

For some reason I couldn’t find the code to load SWF into AIR using “browse”.

[as light=”false” wraplines=”true”]
private function openSwfFile(e:MouseEvent = null):void
{
var imagesFilter:FileFilter = new FileFilter("Flash SWF", "*.swf");
myFile = new File();
myFile.addEventListener(Event.SELECT, selectHandler);
myFile.browseForOpen("Open", [imagesFilter]);
}

private function selectHandler(event:Event):void
{
myFile.removeEventListener(Event.SELECT, selectHandler);
loadSWF(myFile.url);
}

private function loadSWF(inName:String):void
{
trace( "Main.loadSWF > inName : " + inName );
mLoader = new Loader();
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderComplete);
mLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onErrorComplete);
mLoader.load(new URLRequest(inName));
}
private function onLoaderComplete(e:Event):void { startOnEnterFrameHandler(); }
private function onErrorComplete(e:IOErrorEvent):void { trace( "Main.onErrorComplete > e : " + e ); }

private function startOnEnterFrameHandler():void
{
_movie.addChild(mLoader);
// _movie.addEventListener(Event.ENTER_FRAME , onEnterFrameHandler);
}
[/as]
just use a button to activate.

I know the code is not complete… and that some classes have strange names… it’s work in progress.