First, a confession. I was kind of a dick to Mike Chambers about his and Christian Cantrell’s Flash JavaScript Integration Kit last week. To me, I find the whole use of Flash and JavaScript talking is ridicolous in terms of using it for AJAX like functionality; Flash has asyncronous XML and so does JavaScript; why mix the two?
Additionally, the only project I ever had in the past that required Flash talk to JavaScript was kind of stupid anyway; I had Flash controlling Windows Media Player videos since the content was already in a million dollar content management system, and Flash video was out of the question (meaning I couldn’t sell them on it). So, although I managed to get it to work with fscommand’s to JavaScript (since using getURL to control volume of a WMV file through JavaScript didn’t work because getURL was refreshing the page), I still thought it was stupid, and the only point of every using JavaScript and Flash was if you needed to hack some functionality in.
…of course, I got paid good money on the project, money which I 2 years later quickly passed back to the IRS (wtf?). Regardless, it was a project I did, and needed functionality for and successfully implemented. Would it have been better to have MC’s(get it?) integration kit back then? Yep; switch statements with fscommand and watches on _root blow when dealing with AS2 and trying to be OOP.
We have a need for Fileupload in our current project. Remembering my pains of the past, I quickly downloaded their kit to see if it’d integrate into our workflow better, and low and behold yes. I can’t get it to work in an ARP command (I think because commands are local variables, kept around only by the activation object, and this is causing issues…?), but it works great in our main class.
So, since Yamago’s YamzBrowser is AS1 and uber-haxorish with FlashVars initing SWF’s, I’d rather just use the necessary JavaScript to let JSP tell us what’s up, and either JavaScript back, or LocalConnection back; works on another project, so cool, we’re just making the JavaScript and Flash cleaner this project.
This is the 2nd project in my lifetime that’s required hardcore JavaScript and Flash interaction; and I’m getting paid for both… that kind of solidifies the need for what Mike & Christian created and confirms it’s validity… oops, I’m an idiot, and my technology bigotry comes through loud and clear. Sorry guys, I was wrong.
One problem, though, is the Wiki docs currently have the FlashTag write to the document. This ends up replacing your current webpage with the Flash embedding. Since my team is mainly Flash, we managed to figure out a better way (which to a web-head, I’m sure there’s an even better way, but this way works pimp).
We load the Flash into a div tag instead, which I’ve done many times in the past to better control positioning and styles. So, while the Wiki (currently) says this:
<script type="text/javascript"> // The arguments below are path, width, height, and Flash Player version. var tag = new FlashTag('/path/to/flashContent.swf', 300, 300, '7,0,14,0'); tag.addFlashVar('lcId', uid); tag.write(document); </script>
To put it in a div tag instead, we did:
<script type="text/javascript"> var tag = new FlashTag('/path/to/flashContent.swf', 300, 300, '7,0,14,0');
tag.addFlashVar('lcId', uid);
myDiv = document.getElementById("flash_div");
myDiv.innerHTML = tag.toString(); </script>
And the div looks like:
<div id="flash_div" style="width: 600px; height: 600px;"></div>
It works damn good; thanks guys!
Unfortunately I’m tied to using JS Flash communication for a desktop app that uses DRM’d windows media. So while I agree why mix the two, there are times when you have to. These desktop apps are what my company do, there’s no way around it. I have to talk to JS from the Flash UI in order to get data, control the windows, play video, etc.
Glad to see you ended up finding a use for it. :)
I recently used the integration kit to create a Flash template for MovableType that passes the id of the post to a Flash-based blog. Since my app is fullscreen, I was disturbed to see a swf load in when the kit was called, creating a scrollbar in the browser. Other than that, I think the kit is pretty cool, and like you I agree it’s needed.
No worries, Jesse. Mike and I are pretty thick-skinned by now, so we don’t take much personally. I’m glad you (and others) are finding the kit useful. I’m not sure why you were having issues with the FlashTag (it’s not supposed to behave that way), but I’ll look into it.
Christian
hi,
I sort of have the same problem you had Jesse. Iam developing a player in flash that controls a Window media player component. And the JS to AS part works fine. But the opposite doesnt ‘just stops the player’. So how did u use fscommand, with flash tag. pleeeese help. Im loosin it here