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

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


Dreaming in Flash at The Tech Labs

Posted: July 7th, 2008 | Author: Idoru | Filed under: Actionscript3, Adobe AIR, Dreaming in Flash, News, Papervision3d, Tutorial | Tags: , , , | 14 Comments »

We're proud to announce that Dreaming has published a few tutorials over at The Tech Labs, these tutorials are exclusive and can be accessed at: http://www.thetechlabs.com/

They include an air contact manager, and two sound equalizer how-tos with one of them showing how to get those cool pv3d equalizers.

Enjoy!


Giving Flex Builder a Library (SWC)

Posted: February 27th, 2008 | Author: Idoru | Filed under: Actionscript3, Adobe Flex, Tutorial | 3 Comments »

Have you ever wondered why Flex doesn't have a nice library like Flash IDE?
You'd love to use Flex but not having that nice little library there puts you off?
Well here's how we do it:
First create your FLA file, then create all the items you want inside (they don't need to be on stage just library will do), be sure to tick 'export for actionscript' and 'export in firstframe', also you can change the base class to something else that will add functionality to your movieclip.
Then in export preferences, tick 'export swc'.
Ok so now we have a nice little SWC file, how do we get it into Flex? Easy :)
Open project properties, go to Build Path > Library Path and add your SWC file.
That's it!
Congratulations now you have auto complete goodness on your AS3 Flex Builder application :)
Just keep in mind that these elements will be exported in the initial load of your website, so if you want to preload them be sure to use the preloader.


Customized actions for FLVPlayback Component

Posted: January 22nd, 2008 | Author: ruffy | Filed under: Actionscript3, Components, Events, Tutorial, WorkAround | 1 Comment »

If you need a standard flash videoplayer, then the FLVPlayback component is the right thing for you.

Just create a new FLA and drag&drop a FVLPlayback component from the components library into a movieclip in your library, export it for actionscript and compile the SWC.

All the functionallity stuff is already handled by adobe. But that's where I got stuck for quite some
time. I needed a player, that used the forwardButton and backButton for switching the videos (and not seeking forward and back).

The answer was really simple: Just override the functions once the component loaded its skin:




Auto-Generate Getters and Setters in Flex Builder

Posted: December 21st, 2007 | Author: Tiago Bilou | Filed under: Actionscript3, Tutorial | 4 Comments »

I've been writing a lot of getters and setters lately (and spending way too much time doing that...), so I googled for some sort of plug-in for Eclipse/Flex Builder and found a great resource called Project Dash Here's a nice script to use with Dash to generate getters and setters for your variables ;)

  1. Inside FlexBuilder goto Help->Software Updates->Find and Install (if you ran into an error about retrieving "feature.xml" delete the site.xml file in your Flex Builder directory)
  2. add the remote update url ; update and restart
  3. when you restart you should see a Scripts menu and a Project in your workplace called Eclipse Monkey Examples
  4. Create a new file (with a .js extension) in the scripts folder inside the Eclipse Monkey Examples
  5. Write you monkey script in there (copy and paste the script to generate the getters and setters into the new file)

References:
Post with script to generate Getters and Setters


Taking a snapshot of an flv

Posted: December 3rd, 2007 | Author: Idoru | Filed under: Actionscript3, Bitmap, Tutorial, Video, WorkAround | 2 Comments »

Following my last post on 9-Slice items, here comes another nice one on Bitmap.draw() and the security sandbox.
Many people know the solution to this one, but i just found myself looking for it for too long, so here it goes :)

If you want to take a snapshot of a running Video object, you can't, you'll be alerted by the flash player that you are violating
the sandbox security. So how do we do it?
Easy as pie :)

video.attachNetStream( null );
bitmapData.draw( video );
video.attachNetStream ( myNetStreamObject );

Three very simple lines of code but that are hard to come by.


Automating the Build Process – Part 1

Posted: November 30th, 2007 | Author: Tiago Bilou | Filed under: Actionscript3, Adobe Flex, SVN, Tutorial | 4 Comments »

Improving the work flow in the development of Flash applications is something that has been in my mind for some time now, specially after seeing some presentations on the subject at Max Barcelona.

Usually the applications are not big, and are developed by a single programmer in less than a month, so they are manageable, but when a big one come along chaos is installed.

Read the rest of this entry »


Actionscript 3 Preloader

Posted: November 13th, 2007 | Author: Idoru | Filed under: Actionscript3, Code, Tutorial | 19 Comments »

Hey,

So recently i've come to a problem, how do i create a preloader for my 
website if i only use Eclipse as development enviornment?
There is no main timeline per se, nor can i choose where to export my assets, 
so after some digging i came up with  this solution:

The main file:

And the preloader file:

Essentially what i'm doing here is instructing the compiler to add a frame
with myPreloader as a factory and calling my main file from it.
Should you have any questions feel free to ask, here is the swf.


(As2) swapDepths Vs (As3) setChildIndex

Posted: November 6th, 2007 | Author: Ivan Valadares | Filed under: Actionscript2, Actionscript3, Tutorial | 7 Comments »

AS2 was an anarchy language, if you need to put a movieClip visually above all the things in the stage, you can do movieClip.swapDepths(this.getNextHighestDepth()). So it works, but in reality your are swapping your movieClip with a movieClip that didn’t exist, so in AS3 you can’t do that but we have setChildIndex method. You Can do setChildIndex(numChildren-1)

AS2
AS2
AS3
AS3


Filling MovieClips with patterns

Posted: November 5th, 2007 | Author: Ivan Valadares | Filed under: Actionscript3, Code, Tutorial | No Comments »

Tinting a MovieClip is not a new thing, we see a lot of Web sites doing that, example: In a t-shirt selling store, you choose a shirt and then you can choose it color. But yesterday me and Pedro were talking that it could be nice to fill shapes with patterns, so it quite simple:

Example