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

The MXMLLoader Class > Dynamic load MXML In Flex Builder 3

Posted: April 24th, 2008 | Author: Ivan Valadares | Filed under: Actionscript3, Adobe Flex, Code, Events, WorkAround | 16 Comments »

First of all I don’t really use flex to do flex stuff and I’m not a big fan of flex. But in my latest project I had to build with flex an interface witch would be always diferent (a dynamic interface). In the beginning we thought in parsing some type of XML, but if we are in flex why not parse MXML? I took a look over the internet and I only found MXMLLoader component v0.01, witch didn’t compile on flex builder 3 and was really in the beginning. So there it is, as XMMLLoader class for flex builder 3. You just have to instantiate the class with the mxml :

You can access objects by name:

Or by id:

And have access to component events like:

The class with an example:

mxml-loader.zip

Example swf


Load an external flex swf into a flash project and communicate with him.

Posted: April 15th, 2008 | Author: Ivan Valadares | Filed under: Actionscript3, Adobe Flex, Code, Events | 6 Comments »

Loading the swf is easy; you can make a normal loader and load it. And now the tricky part, if the swf is a swf flash file you can call the function you want, but in flex, because it have 2 frames, (first frame is just for loading), you need to wait until frame 2 is available, you can’t also access directly to a swf, you have to refer application before, so there’s the code:

you can also add Event Listener's to myClip.application , like myClip.addEventLIstener(“ON_CHANGE”,function), so by this way you can embed flex swf into an flash application and communicate with him by calling function and receiving events.


Global Mouse_Down Event

Posted: March 29th, 2008 | Author: Ivan Valadares | Filed under: Actionscript3, Code, WorkAround | 4 Comments »

A time ago I had I little problem, I was doing an application and it had some severed changes, at some point I hasn’t capable of detect some mouse down events because I had a lot of sprites inside of sprites inside of movieClips with lots of event listeners and so on. So I and Hugo found this solution. Basically you put a generic mouse down event on stage and pass an array of objects with the name of the display object you want to catch the event and the name of the function you want to call. One good thing is that you can catch more than one event at the same time even if the displayObjects are in front of another displayObjects.

Note: this is really bad programming, if you can don’t use it, use only in severe cases.

globalmousedown.swf

globalmousedown.zip


hitTestObjects

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

This function can be used to test a hit between a displayObject with an amount of displaysObjects (Array). It will return the displayObject where the biggest contact area occurred. Note: it uses the bounding boxes.

hittestobjects.swf

hittestobjects.zip


Get the name of all Xml nodes and Attributes

Posted: March 13th, 2008 | Author: Ivan Valadares | Filed under: Actionscript3, Code | 13 Comments »

How many times do we have an XML that comes from a webservice or from a source 
that we don't know. In these times getting that xml to a file can be cumbersome (imagine that you have authentication). So how about a nice little way to see all the node and attribute names in that xml, here's how:

Take this xml as an example:
file

For this file we'd get something like:
NODE NAME: Mouse
NODE NAME: ScreenSaver
ATTRIBUTE OF ScreenSaver NAME: desc
NODE CHILD OF ScreenSaver NAME: Active
ATTRIBUTE OF Active NAME: desc
NODE CHILD OF ScreenSaver NAME: File
ATTRIBUTE OF File NAME: desc
NODE CHILD OF ScreenSaver NAME: Time
ATTRIBUTE OF Time NAME: desc
ATTRIBUTE OF Time NAME: min
ATTRIBUTE OF Time NAME: max
ATTRIBUTE OF Time NAME: unit

Hope this helps you out.


Image Sequencer

Posted: March 6th, 2008 | Author: Ivan Valadares | Filed under: Actionscript3, Code, Components, Demo | 3 Comments »

To solve the problem of the image sequence I already know the solution, some time ago me and Pedro did something like this. This time I made two different versions, a class version (project in flex 3) and a component to flash cs3. With this solution, you can keep your images outside the project and manipulate them like a movieClip.

Arguments and Parameters

folder -> images folder.
filename -> first part of filename (ex: image1.jpg ), it should be "image".
type -> extension of the filename (jpg,png).
startImageNum-> first image number.
endImageNum->last Image numer.

For the class (ImageSequencer.as) version use:

For the component version:
Run “ImageSequencer.xmp” to install component. Run flash cs3, go to Windows > Components > Standard Components, drag ImageSequencer to the stage and fill the Parameters.

Methods,Events,Properties:

Flash Component and Example
Class File and Example


HLS to RGB & RGB to HLS

Posted: November 19th, 2007 | Author: Ivan Valadares | Filed under: Actionscript3, Code | 2 Comments »

HLS color scheme can be awful to work with bitmapData, today we discover that motion tracking mechanisms can be improved using HLS, so there's a class for converting RBG to HLS and vice-versa.


ColorUtils.as


Actionscript 3 Preloader

Posted: November 13th, 2007 | Author: Idoru | Filed under: Actionscript3, Code, Tutorial | 21 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.


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


Double-faced Plane (or Cube with depth=1) in Papervision3D

Posted: October 11th, 2007 | Author: nuno | Filed under: Actionscript3, Code, Experiments, Papervision3d, Tutorial | 5 Comments »

Today I had my first experiments with Papervision3D and after some time playing around I wanted to try having a double-faced Plane() with a different material on each face.

Its likely that a better way to do this exists, but one way to emulate a double-faced Plane() is to have a Cube with depth = 1, and hiding all but the front and back faces. Here's a and the code.

The hint to do this was from ldoru and the car in the images too!

 Update:  I would not longer use such an approach to achieve a double-faced Plane() with a different material on each face. I would recommend using a DisplayObject3D with two normal one-face planes inside it.