I love ANTs

I’m a ANT lover. By ANT I mean http://ant.apache.org/ and not http://en.wikipedia.org/wiki/Ant


ANT is a task automation script written in Java you can write in XML and add different script languages (Javascript, Java, Ruby, Beanshell, etc) and also shell command line and other tasks really useful to development.
I use a lot of ANT because it comes bundled in Eclipse.
There’s alternatives for this in other languages and platforms, so this may be interesting for people using other dev environments to imagine how you can save development time.

You can find below a list of some useful ANT tricks and Flash debugging I use.
And there’s lot more I can add on this and also for other applications where I use javascript for Adobe IDEs (Photoshop, Flash, AfterEffects) and some other useful scripts I have in Python, but overall what I want to say with this is to be creative when coding, use the advantage that you’re an developer and create some tools that will save your time regardless the platform.

Executing scripts

<project name=”TestProject” default=”Some task”>

<target name=”Some task”>

<script language=”javascript”>

<![CDATA[

echo = project.createTask("echo");

echo.setMessage("Hello from JS");

echo.perform();

]]>

</script>
</target>
</project>

Just a simple example using javascript to output a message. As I said, you can use different scripts and access project properties.

<project name=”TestProject” default=”Some task”>
<target name=”Some task”>
<exec executable=”say”>
<arg value=”hello”/>
</exec>
</target>
</project>

You can run any executable, in this example running “say” command line app in OSX.

<target name=”Upload to TestFlight”>
<input message=”Release note” addproperty=”releaseNote” />
<fail message=”Release note is empty”>
<condition>
<not>
<and>
<isset property=”releaseNote” />
<length string=”${releaseNote}” when=”greater” length=”0″ />
</and>
</not>
</condition>
</fail>
<exec executable=”curl”>
<arg value=”-F file=@${project.bin}/${project.name}.ipa” />
<arg value=”-F api_token=${tf.apiToken}” />
<arg value=”-F team_token=${tf.teamToken}” />
<arg value=”-F notes=${releaseNote}” />
<arg value=”-F distribution_list=’${tf.distributionList}’” />
<arg value=”-F notify=True” />
<arg value=”http://testflightapp.com/api/builds.json” />
</exec>
</target>

Another example of running executable files, this time uploading a file to TestFlight automatically when compiling the app as release.

There’s different tasks for manipulating files, such FTP, SVN, ZIP, Rename, etc.

Sound task

<project name=”TestProject” default=”Some task”>
<sound>
<success source=”/System/Library/Sounds/Glass.aiff” />
<fail source=”/System/Library/Sounds/Ping.aiff” />
</sound>
<target name=”Some task”>

</target>
</project>

Sound task plays a sound when a task is executed and you can define which sound to play when a task is successful or it raises some error.
The sound task is useful for time consuming tasks, like compiling a whole project.
Usually when I’m compiling AIR projects to iOS takes about a minute, so I can execute the task and go browsing the internet or check emails and it’ll let me know when it’s finished compiling.

UpToDate

<target name=”Check Changed” id=”CheckChanged”>
<uptodate property=”notchanged” targetfile=”">
<srcfiles dir=”${basedir}” includes=”**/*.as” />
<srcfiles dir=”${basedir}” includes=”**/*.mxml” />
</uptodate>
</target>
<target name=”Compile” depends=”Check Changed” unless=”notchanged”>
<echo message=”Compiling” />
</target>

Uptodate task checks whether a file has changed from last execution.
So, when running Compile task, it first checks if any file in the project with *.as *.mxml has changed, and it executes the task only if there’s any file changed.

Versioning

<script language=”javascript”>
<![CDATA[
var versionArr = String(project.getProperty("project.version")).split(".");

versionArr[versionArr.length - 1] = Number(versionArr[versionArr.length - 1]) + 1;

project.setProperty(“version”, versionArr.join(“.”));
]]>
</script>
<propertyfile file=”${basedir}/build_project.properties”>
<entry key=”project.version” value=”${version}” />
</propertyfile>

Just a simple javascript for auto-incrementing a version number and writing the new version number in a properties file. Usually the *.properties file is used for defining variables in ANT.

Versioning SWF

******FLASH DEVELOPERS READ THIS!!!!!!******

The Flex mxmlc compiler has a parameter you can pass to define a namespace and variable that will exist in your SWF when compiled.
> mxmlc … -define+\=CONFIG\:\:VERSION,${version} …

This is really useful when debugging the app and you’re not sure if your browser is caching your SWF file.
In AS3 you can call CONFIG::VERSION anywhere and it’ll return the value you set in the compiler argument. So I use it together with the Versioning task and UpToDate task above and each time I compile it assigns a new version number to my SWF.
And I do:
/*FDT_IGNORE*/
trace(“VERSION:”, CONFIG::VERSION);
/*FDT_IGNORE*/
FDT_IGNORE is another trick for FDT users, it won’t raise any syntax error anything within this block comment.
So, I know which is the most recent version and the version my browser is running, you can also print it on screen if it makes easier for other non-techie people are checking.
Also, if you Google for Flex mxmlc define, there’s loads of examples showing how to use it with CONFIG::DEBUG,true / false, so when compiling you can use it as well to show/hide the version number on screen, and other scripts you use for debugging.

Vote in HexoSearch Vote

Comments (1)

Editing BitmapData from different domain

Wonder how to apply smoothing, read and write pixels on a image loaded from a different domain name?

Quite simple, load as binary first and than load the ByteArray as Bitmap.


var urlLoader:URLLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.addEventListener(Event.COMPLETE, urlLoaderComplete);

var url:String = "http://www.adobe.com/images/shared/product_mnemonics/50x50/flash_player_50x50.gif";
urlLoader.load(new URLRequest(url));

function urlLoaderComplete(e:Event):void
{
  var loader:Loader = new Loader();
  loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderComplete);
  loader.loadBytes(urlLoader.data as ByteArray);
}

function loaderComplete(e:Event):void
{
  var bmp:Bitmap = e.currentTarget.content as Bitmap;
  addChild(bmp);
  var bitmapData:BitmapData = bmp.bitmapData
  bitmapData.applyFilter(bitmapData, bitmapData.rect, new Point(0, 0),
    new ColorMatrixFilter([
      0, 0, 0, 0, 0,
      1, 1, 0, 0, 0,
      0, 0, 1, 0, 0,
      0, -1, -1, 1, 0
  ]));
}

Vote in HexoSearch Vote

Comments (2)

Fast Metaball Effect in AS3


var container:Sprite = new Sprite();
var balls:Vector. = new Vector.();
var m:Matrix;
var s:Shape;
var r:Number;
var c:uint;
for(var i:int = 0; i < 10; i++){
r = Math.random() * 100 + 100;
m = new Matrix();
m.createGradientBox(r, r, 0, -r * 0.5, -r * 0.5);
s = container.addChild(new Shape()) as Shape;
c = Math.random() * 0xFFFFFF;
s.graphics.beginGradientFill(GradientType.RADIAL, [c, c], [1, 0], [0x00, 0xFF], m);
s.graphics.drawRect(-r * 0.5, -r * 0.5, r, r);
s.x = Math.random() * 400;
s.y = Math.random() * 300;
moveBall(s);
balls.push(s);
}
function moveBall(s:Shape):void
{
//whatever easing to move the spheres
}
var s2:Shape = container.addChild(new Shape()) as Shape;
m = new Matrix();
m.createGradientBox(200, 200, 0, -100, -100);
c = Math.random() * 0xFFFFFF;
s2.graphics.beginGradientFill(GradientType.RADIAL, [c, c], [1, 0], [0x00, 0xFF], m);
s2.graphics.drawRect(-100, -100, 200, 200);
var bmpData:BitmapData = new BitmapData(400, 300, true, 0x00000000);
var bmp:Bitmap = addChild(new Bitmap(bmpData)) as Bitmap;
addEventListener(Event.ENTER_FRAME, render);
function render(e:Event):void
{
s2.x = mouseX;
s2.y = mouseY;
bmpData.applyFilter(bmpData, bmpData.rect, new Point(0, 0), new BlurFilter(2, 2, 2));
bmpData.draw(container);
var i:int, l:int;
var aArr:Array = [];
var c:int;
for(i = 0; i <= 0xFF; i++)
{
c = (i - 0x80) << 1;
if(c < 0) c = 0;
aArr[i] = c << 24;
}
bmpData.paletteMap(bmpData, bmpData.rect, new Point(0, 0), null, null, null, aArr);
}

Vote in HexoSearch Vote

Comments (4)

Wi-Fireworks Interactive Installation

I had a great opportunity to make an interactive installation at unit9.

So, I came up with the technical idea, using the mobile device’s web browser that supports html5, and an internet connection, you could interact with a computer, without the need to install any app.

The idea our creative director Kishi brought was simple, you draw, and make your drawing a firework.
With the help from unit9, we were able to create this unique way to interact from a mobile to a computer, in a straightforward way, no need to install any app, no need of advanced technical knowledge.

Vote in HexoSearch Vote

Comments

My first installation, Wi-Fireworks

So, my time has came.
My first installation.

It’s really simple drawing installation.
You get your iPhone and access the URL from your browser in the instruction on the projection, and just start drawing, and you can see it right away on the projection.
You don’t need to install any application.

You can check some videos here: http://www.facebook.com/event.php?eid=106749376013168

So, I used HTML5 + JavaScript for the web application, PHP for the socket (I know, it’s not the best solution, but it was what I could’ve done at this time), C++ & OpenFrameworks for the application running for the projection and a MySQL database to store all the drawn data.

What I’ve learned from this?
- you don’t really need to learn Objective-C and pay hundreds to Apple to make some simple application
- don’t try to do what everyone is doing
- I know c++ now
- flash is slow even on AIR
- sockets on PHP works pretty well
- HTML5 won’t be replacing Flash any time soon
- people are afraid to do something different at work until someone does something new
- don’t try to do everything by yourself

Anyway, at the end, everything went well, personally the result was really good.

If you read this post before 29th of March, you can still go check it out at Hoxton Square.

Vote in HexoSearch Vote

Comments

Catching up

Again, I didn’t update my blog for a long time.
So to catch up, here goes what happened in my life in the last months.

At beginning of November I started working at unit9 (http://www.unit9.com) a interactive media company based in London.

As first project, I did Guinness Bring it to Life (http://www.bringittolife.tv)
It’s a project that integrates Google Earth plug-in, Flash, Javascript, Facebook, and lot of other technologies.
Basically, you can build your planet with different terrains on Google Earth plug-in and bring life to your new planet.

Last week I went to play Carling in Kent with some friends.
It was amazing, much exciting than watching someone playing. You should play it when you have chance.

And, this week, I made a installation at unit9, my very first one, that I’ll explain on next post.

Vote in HexoSearch Vote

Comments

My 3rd FWA!

Yeah!! My 3rd FWA.
Now I have my name listed on FWA’s profile!

1st FWA: Sony Recyou (Non-grid)
2nd FWA: Panasonic Wave (Non-grid)
3rd FWA: Adhemas Batista website

Check it out there!

Vote in HexoSearch Vote

Comments

Adhemas.com I’m Selling Colors

Released couple weeks ago, I programmed the portfolio website for Adhemas Batista.
He is a Brazilian illustrator based in Los Angeles – US.

Vote in HexoSearch Vote

Comments

Flash App on iPhone is crap

I went today for Adobe Back from MAX conference here in London. It’s like a mashup of what they showed at Adobe MAX LA.

Well, here is the note I took, and I’m really disapointed about Flash app in iPhone…

Flash app on iPhone:

- It’s a “static” app. Only SWFs packed in the app can be loaded. No SWFs from outside can be loaded;
- You can load images, sound, text from outside;
- No H.264, RTMPT, PixelBender…;
- No access to Mic / Camera;
- No access to Native API like Maps;
- The packed file size is at least 2.7mb because they have to bundle all the functionalities because the compiler doesn’t know what is being used or not;

Flash Embed in HTML
- You can assign a priority to swfs during embed, so in a page with 2 banners and a main swf, can assign main swf a higher priority for performance;

Flash Catalyst
- easy integration of Photoshop/Illustrator design with Flash, using Catalyst.
- good for prototyping and IAs
- skinning components easy
- you can create a Flex Project directly from Catalyst, but the Flex Project can’t be loaded in Catalyst
- you can create just a Library Project so you can change components skins easily

Flash Pro CS5
- Text Framework integrated (http://labs.adobe.com/technologies/textlayout/)
- AS3 snippets for designers, creates simple interactive code as Keyboard / Mouse interaction
- Can save FLA or a uncompressed FLA format, that is a bunch of XML’s and assets inside a folder.
- The uncompressed file format is good to change the assets without opening the FLA file

Flash Builder
- You can easily create Flash Project and select a FLA file
- Better integration with back-end stuff, WebServices / AMF (CF, PHP, Java)
- Code generator for WebService / AMF
- Network monitor, to monitor webservices and AMF
- Easily create CMS, selecting the data origin, can be set to edit or only ready the data

Flash Distribution
- Monetization, using Adobe ID, sell Flash / AIR products
- Apps supports Ads
- Frameworks to make easier integrations with social network.

Vote in HexoSearch Vote

Comments (1)

Drag and Drop between Flash and HTML

A long time I didn’t code anything in JS… and I just had an insight.
I don’t know if it’s new but at least it’s interesting for me how we can integrate Flash and HTML contents.
This is just a simple ugly test to drag something from Flash and drop on HTML.

The demo is in this link:http://www.hellokeita.in/xp/DragDrop/

Vote in HexoSearch Vote

Comments (6)

« Previous entries Next Page » Next Page »