“Be inspired, enjoy your work, keep learning and never forget to play.” — gskinner

Where is as2 _root in as3?

Posted: October 27th, 2008 | Author: Ivan Valadares | Filed under: Actionscript3, Best Practices, Code | 6 Comments »

If you remember in as2 we had _root which let us access to methods and variables in the root of the project and refer to absolute paths, I thought that as3 didn’t have _root propriety, but I was wrong. root property can be useful if you want to share some value to all the classes in the project, add events to main class that call methods declared inside the class where we are working on or call generic methods declare in root class.

To use root propriety the class that you are working on most extend a DisplayObject (Sprite,MovieCLip,etc…) because you have to add the class to the parent class. And note, you can’t use the root propriety in the constructor method, because the addChild haven’t been process yet! Well let’s stop writing and see some code:

Main.as

In the Main class I’m declaring a variable named myValue which I did the proper sets and get. I am declaring two classes, in one of them I will set the value at the Main class and in the other I will get that value back. I’m also creating a movieClip just for test purposes.

ExampleClass.as

In ExampleClass I’m setting myValue that is propriety of the Main class with some text and I’m tracing the movieClip that I create in the Main Class.

AnotherClass.as

In AnotherClass I’m tracing the myValue propriety. So the result should be:
[object MovieClip]
This value is inside the Main Class

So it works ok, you only have to be carefull not refer root inside the constructor method, have the certain that you already addChild the class when you are referring to root and that the class extends a display object. If you do that, you can too have access to stage propriety, let’s check the next example:

ExampleClass.as

The result should be or stage width.

Another way to access to main proprieties, methods, etc… is with static members. In the next example I’m declaring a static property in the main class and setting and trace the value of it in the example class.

Main.as

ExampleClass.as

The result should be “Hello Word!”, if you didn’t know this, read some books about object oriented programming and static members.

Another way to do the same thing is to pass the instance of main class as an argument to the other classes.

Main.as

Example.as

There are still another ways to access to the Main class code. I don’t know which techniques are more correct, I usually use them all depending in what I need. I hope I help someone. :)


Interview with Alex Karpovich (Alternativa3D)

Posted: October 7th, 2008 | Author: Idoru | Filed under: Interviews | Tags: , , | 75 Comments »

Following our tradition of getting the makers of the most used 3D engines out there we landed an interview with Alex Karpovich, from Alternativa3D.

Read the rest of this entry »


FOTB 08 #3

Posted: October 3rd, 2008 | Author: Idoru | Filed under: FOTB 08, Flash on the Beach | Tags: , | 4 Comments »


Flash on the beach is over! It's always a mix of joy and sadness. This year's been terrific, with great talks, great parties and amazing people!

So here's my final day's reviews:

Rob on Away3D: It started with a little background on the platform and some early demos that described the problems that Away3D had to solve, and why they started  it in the first place, with stuff like Triangle Caching allowing some of the demos to have over 100 000 polygons on screen and still maintain quite acceptable frame rates! The he showed us a few amazing demos of current usage of Away3D including a RPG called Dragon Wars that was mind-blowing, overall very cool presentation.

Nicolas Lierman on AIR Analytics: This presentation focused on showing all that data that we collect from our sites and applications in meaningful ways and gave us a little technical and personal background on the AIR Analytics application.

André Michelle Make some noise: As always with André the presentation was energetic and ended with a rave, but this year he gave us a big technical insight on how the achieves his results.

Koen de Weggheleire - This was one of the coolest sessions in FOTB, Koen talked about Matrices and how they work, and i finally got it!

Mario Klingemann: What can I really say about Mario's session, it was impressive to say the least, this time he focused heavily on the concept part of manipulating pixels, and by not going into code he managed to provide us with the how he does it.

Jonathan Harris: I had seen Jonathan before at a TED talk, online that is, and was blown away when I found that he'd be at FOTB '08. He went through his life experience explaining each endeavor and showing us amazing examples, that you just can't help but to fall in love with.
To close his session he delivered a speech to the community about how he feels us, an eye opener!

And to finalize I won a FOTB 08 Jacket and that's just cool!

It was amazing as always, living up to the Hype and there's a lot of it! And I hope to you guys here next year!


FOTB ‘08 Day #2

Posted: October 1st, 2008 | Author: Idoru | Filed under: FOTB | Tags: | No Comments »

FOTB 08 Day #2

Ok so here we are at day #2 of FOTB '08 and today was inspiring to say the least, I chose to go a bit more on the inspiring side and less on the technical part and it paid off brilliantly. This is clearly one of the areas I feel myself lacking and I feel like I've learned quite alot!

Mike Downey on AIR - Mike's session about how to pitch and sell AIR applications was an eye opener and consolidated a lot of concepts I already had.
He told us about the Lighthouse project that is meant to give out a hand to developers, and companies, in pitching AIR applications and they might even help you prototype it! Also he spoke about the AIR marketplace and how it can boost your app, good stuff!

Adobe Townhall Meeting - So every year the Adobe teams comes together and answers our questions. There were plenty of questions this year but I'll leave you with the most exciting answers: Flash is coming to the iPhone!!! And AIR is coming to mobile!

Jam Session - This was one of the coolest sessions in the conference, with André Michelle, Carlos Ulloa, Ralph Hauwert, Mario Klingemann, Joa Ebert where they showed off amazing stuff they've been working on, I'll try and refer you to a better post as soon as find one!

GSkinner - This year Grant went more on the how to handle your workflow and solve programming problems, and eye opener.

Hoss - Hoss was amazing, with an energetic presentation of his work and telling us to focus on the user eXperience instead of everything else, because in the end that's all that matter, plus nudity!

So that was it for day two, I attended a few more sessions but i didn't see them as relevant as they were more for inspiration.


FOTB 08 Day 1

Posted: September 29th, 2008 | Author: Idoru | Filed under: FOTB 08 | Tags: | 2 Comments »

So we're at the end of day #1 over at FOTB '08, and as expect it was full of amazing and enticing talks.

Here's a small overview of what I attended:

Keynote with Richard Galvan: We were shown the new functionalities on CS4, nothing really new but it was still nice to see them there live, then the presentation shifted focus to the mobile and cross platforms. So all and all nothing really new or that we weren't expecting. And oh we've learned about FOTBm (flash on the beach in Miami!!).

Dr Woohoo: This was a first time for me since I didn't make it last year, and boy was I impressed, did you know that you can hook up flex/flash to panels and control all the cs3/cs4 applications through it? Amazing!

Carlos Ulloa: As always Carlos delivers! This time he started us off by talking about methodologies and team workflow and then proceeded to show us off his latest project in the making, a 3d racing sim game in PV3d! And boy was I blown away!

Geoff Stearns: The developer for the Youtube Video Player, gave us a simple, yet tight, overview of the problems he encountered and how he overcame them, interesting session that validated my assumptions and decisions on a recent project i finished.

TInk: As always with Tink he's a great speaker with a very pragmatic approach to his stuff and he demo'ed a cool animation framework for Flex that looked very very sexy. Ps: Expect an interview over at daily with him ;) .

And that was it off to the inspiring session!


Download Adobe Flash CS4 Trial

Posted: September 29th, 2008 | Author: Ivan Valadares | Filed under: Flash 10 | 34 Comments »

Adobe Web Site Download

Object-based animation
Gain complete control over individual animation attributes with object-based animation, which applies tweens directly to objects instead of to keyframes. Easily make changes to motion with Bezier handles.

3D transformation
Animate 2D objects through 3D space with exciting new 3D translation and rotation tools, which allow you to animate along the x, y, and z axes. Apply local or global transformation to any object.

Procedural modeling with Deco and Spray Brush
Turn symbols into instant design tools. Apply symbols in a variety of ways: Quickly create kaleidoscope-like effects and apply fills using the Deco tool, or randomly spray symbols across any defined area using the Spray Brush.

Metadata (XMP) support
Add metadata to SWF files using the new XMP panel. Quickly assign tags for enhanced collaboration and better mobile experiences.

Authoring for Adobe AIR
Deliver interactive experiences to the desktop with new integrated capability to publish to the Adobe® AIR™ runtime. Reach even more audiences across more devices — web, mobile, and now the desktop.

XFL support
Open content from Adobe InDesign® or After Effects® software and retain file integrity. With the cross-application XFL format, easily import content for further development in Adobe Flash®.

Inverse kinematics with the Bones tool
Create chain-like animation effects with a series of linked objects, or quickly distort a single shape using the new Bones tool.

Motion editor
Experience detailed control over keyframe parameters, including rotation, size, scale, position, filters, and more, using the new motion editor. Refine easing control with graphical displays similar to those in After Effects.

Motion presets
Jump-start your project with prebuilt animations that can be applied to any object. Select from dozens of presets or create and save your own. Share presets with others to save animation time.

H.264 support
Encode to any format recognized by the Adobe Flash Player runtime with Adobe Media Encoder, the same tool found in other Adobe video products and now with support for H.264.


FOTB ‘08 Plan

Posted: September 29th, 2008 | Author: Idoru | Filed under: FOTB 08 | Tags: | No Comments »

One more year, one more FOTB, as always the hype is up for the best flash event of the year, and I'll be there. And since plenty of people are doing it I thought I'd share my schedule plan:

Monday

Richard Galvan - Keynote
Carlos Ulloa - The best way to predict the future is to invent it
Here I'm a bit undecided between Branden Hall and Mike Jones
Geoff Stearns - Youtube Lessons Learned
Richard Lord - Creating particle effects with Flint
Eric Natzke - Beyond the knowledge: The Art of Play
James Paterson - Modulating a Lot

Tuesday

Aral Balkan or Mike Downey still to decide
Adobe - Town Hall Meeting
Grant Skinner - Things every actionscript developer should know
GMUNK
Lee Brimelow - Platform Jiu-Jitsu
Nando Costa - Motion Graphics, one frame at a time
Robert Hodgin - The best 8 to 12 hours of my life.

Wednesday

Rob Bateman - Finding Away3d
Nicolas Lierman or Seb Lee-Delisle
André Michelle or Doug McCune (this is going to be a though choice)
Mario Klingemann - Here be Pixels
Jonathan Harris - The art of surveillance and self-exposure.

So that's it for me, although i do foresee some changes here and there depending on how much I feel like going for the inspiration rather than the technical part.

Hope to see you guys there and remember look for the guy in the daily papervision3d t-shirt ;)


Flex Bindings in AS3 Projects

Posted: July 29th, 2008 | Author: Tiago Bilou | Filed under: Actionscript3, Tutorial | 31 Comments »

Since 99.9% of the work we do is Flash, we pretty much use flex builder to develop Actionscript Projects. One of the things I really wanted to have was bindings. Here's how to use Flex Bindings in Actionscript only projects.

Remember that the Flash framework (textfields, movieclips, sprites, etc) doesn't dispatch the data-binding event. This means that pretty much the only things you can bind are variables.

Make sure you add the flex framework.swc to your project Library Path to have access to the mx.binding.util class.

ChangeWatcher:

Acts like the watch on AS2. It watches a variable for changes and when something happens fires an event. Make sure you call the canWatch to ensure that you can watch it!

There are 3 ways to specify the second parameter, the chain.

  1. A String containing the name of a public bindable property of the host object.

    ChangeWatcher.watch(this, "myvar", handler)

  2. An Object in the form: { name: property name, access: function(host) { return host[name] } }. The Object contains the name of a public bindable property, and a function which serves as a getter for that property.

    ChangeWatcher.watch(this, { name:"myvar", getter: function():String { return "something" }}, handler);

  3. A non-empty Array containing any combination of the first two options. This represents a chain of bindable properties accessible from the host. For example, to watch the property host.a.b.c, call the method as: watch(host, ["a","b","c"]

BindingUtils.bindProperty

Works pretty much the same way as the watch, but instead of having to handle and event it allows you to immediately bind two properties one-way.
The first two parameters are for the the target, the second parameters are the triggers.

BindingUtils.bindProperty( this, "va1", this, "var2");

you can also use the same syntax for the chain.

References:

Language References
Another Tutorial


Convert string date to Date type

Posted: July 16th, 2008 | Author: Ivan Valadares | Filed under: Actionscript3, Code | 1 Comment »

var d:Date = new Date(Date.parse(MM/DD/YYYY));

Christmas day
var d:Date = new Date(Date.parse(12/24/2008));


Get difference between two dates in days

Posted: July 16th, 2008 | Author: Ivan Valadares | Filed under: Actionscript3, Code | 2 Comments »