For 36 View of a Bridge at Ingenuity Fest 09 Cleveland OH
So as it happens, after most client meeting (client used very very loosely). It turns out the first way I was thinking about how to build this app wasn't exactly how it was originally vision. Honestly I was a little relieved, because what the new idea is made more sense to create. The only problem, how to pull it off?
The Change in Plans
So initially, there is a collection of videos. They play in a certain order. As they play people vote on their favorites. When ALL videos are finished playing though, the player reads the new amount of votes and rearranges the videos in the new popular order. Here is a demo video I made earlier:
This wasn't too bad. Hold the list and most popular votes in a MySQL database and just have Flash communicate to that through PHP. I'm sure I'll be able to use this code in the future somewhere.
New Plan, the videos play. Whenever a person votes on a video on the table, that video is then moved up to the next queue spot in the playlist and the list on the table readjust accordingly. It doesn't sound that hard. Its just one sentence. But there are a few stepping stones.
- The Voting Flash and the Video Playing Flash are 2 separate Flash files
- Those Flash files are on Separate Computers to take load off the flash trying to play HD videos
- Communication to MySQL via PHP is only one way, MySQL can't tell Flash when it's been updated from MySQL
Well, I believe there is a solution to any problem. One just needs to figure it out. So I started with just the first issue. Two separate SWF files, how can they actively communicate together?
Thats it! and looking at the details, check it out. They can communicate on 2 different domains. Which got me thinking immediately, hey the 2 computer are on the same network. They should be able to talk over the network. Solved.
But wait! After 2 hours of trying and coding and recoding. It just wasn't working. Looked a little more into it, yeah, cannot communicate across a network to other computers. So back to the drawing board for me.
So I Googled. I scoured. I twittered (thank you alpaykasal for the suggestion of .txt method but I would still be in passive communication and not active). I don't even know what I was looking at when I was thinking about TUIO. How does that data get into Flash?
Active communication that Flash gets and sends information. You can create events that work around the data. A common thing is to create an XML feed from the socket and parse it in Flash. Now that sounds, well that sounds like the right track to me.
Thank the net for PHP! Did you know you can make one of these sockets with PHP? I didn't. And wait, I spent how much time getting PHP running on both computers? Too much, but it looks like its finally going to be worth it.
Well, I was mostly right. The PHP install I did just wasn't playing nice. So time for a little reinstall, but this time with a little help: WAMP. OMG, Windows/Apache/MySQL/PHP all installed, all working, all good to go (best server setup package EVER). And with the help of running through a little tutorial from Kirupa. The Flash was talking to each other. I tried it on the separate computers, once I set Apache to trust each other, communication over the network. App is once again running. And what the heck, since I already have it MySQL is still taking a talley of the most voted on videos for data gathering sake. Any data is good data.
- Flash App Development time: 3hrs
- Testing Connection, Server installing and Debugging Everything time: 14hrs
- Bacardi 151 consumed: 1/2 bottle
- Seeing you app finally work the way you want: priceless
My favorite part is when I told our company's resident code genius,
he gave me a respectful congratulatory nod and said 'Your gettin good at this S*$#'
A little experimenting can go a long way.
I gets tricky to record but hopefully I can get a new video demo. If not, we'll just have to wait till Ingenuity Fest.