Flex to Flash Communication

February 18th, 2009

To celebrate the launch of The NAACP Top 100, I thought I would do a brief tutorial on how to communicate from Flex to Flash.

In short, it’s not too big of a deal. You have to create a MovieClip object in your Flex movie that you will equate with the Flash movie that you load into the Flex. Once you have that object, you can call it’s methods, pass variables, and what not. The only catch is that you need access to the guts of the Flash movie so you know what objects and methods that it contains.

So, in the Flex, create the MovieClip object that you will later construct:

[Bindable]
private var myFlashChild:MovieClip;

Next, you will need a function to call that constructs your MovieClip object using your Flash swf:

private function init():void{
        myFlashChild = flashLoader.content as MovieClip;
}

flashLoader is just a SWFLoader used to load in the external swf that you created with Flash. The MXML for the SWFLoader looks like:

<mx:SWFLoader y=“150″ source=“assets/flash_comm.swf” horizontalCenter=“0″ id=“flashLoader” complete=“init()”/>

The init() method called is what plugs your external Flash swf into your Flex MovieClip object. The external swf needs to finish loading into the Flex before this method is called, which is why the method is called on complete.
Now that your external swf is loaded, you can call the methods that it contains and because we built the Flash, we know that it has a function in it called setTextFromFlex which looks like this:

function setTextFromFlex(myString:String):void{
        readOutTxt.text = myString;
}

So finally from Flex, we can call our function which sends a string of text from our Flex textfield into the Flash function which will then display that text inside of the textfield that is in the Flash:

private function communicateToFlash():void{
        myFlashChild.setTextFromFlex(flexTxt.text)
}

So, the final block of code from Flex will look like this>>

For the Flash, besides naming your components, all you’ll need to do is add this function:

function setTextFromFlex(myString:String):void{
        readOutTxt.text = myString;
}

That’s it. Let me know if you have any questions. Class is dismissed.

source zip >>

Website Soup

January 27th, 2009

Ovrflo Media promo image
Ok, getting the business up and going has been a lot of work and the blog has definitely suffered as a result. BUT NO MORE!!! Here is a recap of some more notable projects I’ve done over the past 9 months.

*Just so everyone knows how the company works, Ovrflo Media is a production house. We may consult on interactive design, but by in large we just build out existing creative. Larger interactive firms concept and pitch the ideas and then reach out to us for the technical construction.

1. HDNA Football >>
This was mainly a sweepstakes site with a couple of different activities people could participate in and possibly win prizes. Most of the games have come to their conclusion, but you can still check out the site if you want. Technically, it was an interesting site to build. It has a .net framework that manages session and what not and the Flash was built to utilize these tools. For example, by tying into the .net framework, we were able to log people out of the Flash site if their session timed out. I would love to give some code examples but unfortunately this project is considered proprietary. :(

2. Jango Geography >>
This was a lot of fun. It is an educational, interactive board game built in Flash using AS3. Jason Fincanon did most of the work. I was more of a project manager on this one. The goal of the site is to educate people about Mangoes and to promote buying them of course. As you play the main board game, you have to answer questions and play various mini-games.

3. NAACP/Blockbuster Top 100 >>
The cool version of this site does not officially launch until sometime in February, I believe. It’s a killer mix of Flash, Flex, PHP, and video. Our primary workload was in the Flex and Flash development. When the full version of the site launches, it will allow people to vote and decide the 100 most influential African American movies of all time. Very cool. I was going to post a tutorial on how to get Flash and Flex to talk to each other, but Fincanon beat me to the punch. In fact, I still might post a tutorial on the “non event” method to talk between Flash and Flex, but until then check out Jason’s tutorial here.

Actionscript Heroes

January 26th, 2009
I want to give a shout-out to www.actionscripthero.org for giving me a shout-out! Be sure to click on the Interviews tab and read some. If you are looking for someone in particular, just filter using their name. Remember, together we can figure it out.

Chris after a couple of days of relentless coding

P.S. My friend Charlie, better known as the Asian Sensation, told me that I looked awful in this picture. For the record, this was taken from Photobooth after a relentless couple of days of coding. … Keepin’ it real.

Check it out >>

Skip Intro

June 10th, 2008

Well, I’ve never been a fan of long, drawn out Flash intros, and I guess no one else is either. Life Hacker just did a blip on how Google is now offering a feature that allows people to skip intros.

Check out the article here.

Drag some pork around.

May 24th, 2008

www.theotherwhitemeat.com/porkand screenshot
Ok, sorry it’s been so long since I posted anything new. Getting the new company off the ground took me out of the loop for a little while, but I digress. Let’s talk about pork or more importantly The National Pork Board.

I recently had a part in bringing a microsite to life that involves getting “life lessons” from a very sensitive butcher. Drag a cut of pork onto the board and then drag an item onto the board as well. Moments later you will gain some sage advise from the butcher himself via a video clip. I promise it’s more fun than I am making it sound.

One thing to note on the programming, I used to always use Robert Penner’s, more than excellent, motion classes in combination with set intervals. However, this time I used the built in Tween Classes which I hardly ever hear people raving about. You know what? They worked great. Not only did they work great, but it eliminated all of the intervals I would have had to keep track of on my own. So you can’t see me, but I’m pouring a 40oz all over my laptop as a sign of respect for the built in tween classes.

Check it out >> http://www.theotherwhitemeat.com/porkand

UPDATE!!!: Site has run it’s course. It can still be seen as a demo though.
Check it out >> Sensitive Butcher