Flash Builder VideoDisplay Memory Leak Fix
So it turns out the VideoDisplay and VideoPlayer components that come with Flash Builder 4 contain a nasty memory leak. After a few hours of trial and error I managed to figure out a fix for it.
1) Copy and paste the ActionScript from the VideoDisplay component into a class of your own.
2) Update all event listeners to use weak references.
addEventListener(EVENT.TYPE, FUNCTION, false, 0, true)
3) Add the following line of code to the bottom of the"removedFromStageHandler" function.
removeChild(videoGateway);
Profile your application and you should notice the memory leak is gone.
Good luck!
No commentsAnimator vs. Animation 3 uses vCam AS3
Alan Becker, the animator behind the viral hit "Animator vs. Animation," has just released the third episode of the series. I'm thrilled to say that Alan leveraged the vCam AS3 in his latest masterpiece. Go check it out and fear The Chosen One.
1 commentVCam AS3 1.1
I finally had some time to revisit the vCam AS3. I removed a bunch of unnecessary code. Please try out the new version and send me any bugs you find.
Thanks!
Download vCam AS3 1.1 (Requires Flash CS3 and Actionscript 3)
7 commentsDispatch DOM events from Flash embed object via AS3.
I've been working on a new Flash app recently. I ran into an interesting scenario where and I needed external ui components to monitor the app changes. After some trial and error I came up with the following:
The first step is to download a nifty class called EmbedObject here. It allows you to get the ID of the Flash embed object.
The next step is to create a class that will dispatch the event using an ExternalInterface call.
package {
import flash.external.*;
import com.asorg.browser.*;
public dynamic class JSEventDispatcher{
public static function dispatchEvent(event:String):void{
var script_js:XML = <script>
<![CDATA[
function(id,event){
var flashObject = document.getElementById(id);
var evObj = document.createEvent(\'Events\');
evObj.initEvent(event, true, true);
flashObject.dispatchEvent(evObj);
}
]]>
</script>
ExternalInterface.call(script_js, EmbedObject.getId(), event);
}
}
}
The JSEventDispatcher class has a static method called dispatchEvent. Embedded JavaScript gets a reference to the Flash embed object associated with the SWF and dispatches your event.
When you want to dispatch an event from your SWF you would simply call:
JSEventDispatcher.dispatchEvent('yourEvent');
The last step is to setup an event listener on your page that listens for the event.
<script language="JavaScript"type="text/javascript">
function addListeners(){
var flashObject = document.getElementById(\'yourEmbedObjectID\');
flashObject.addEventListener(\'yourEvent\',eventHandler,false);
}
function eventHandler(e){
alert(\'fired\')
}
</script>
NOTE! Be sure that the Flash object is instantiated before you attach the listener.
There you have it. Now your embed object will dispatch events sent by your SWF!
No commentsParallax Scrolling
You can easily achieve parallax scrolling in Flash CS4. Using the vCam AS3, apply different Z positions to your movieclips. Then tween the camera and publish your movie. How easy is that?
Here is a test I ran (Flash Player 10 Required):
Artwork by Tim Allen 10 comments
Depth-of-Field experiment
Many of you have been asking for a depth-of-field feature for the vCam AS3. I've been running some experiments recently with Flash CS4 and it appears to be feasible. There is however a bug in CS4 that causes timeline based tweens to be deleted whenever you apply a filter using ActionScript. I've submitted a bug report to Adobe. The depth-of-field feature won't be of much use until this bug is worked out because all your precious tweens will be removed when the vCam attempts to apply the filter to your timeline instances.
It's important to note that all of the blurring and motion you see in the animation below is being handled by the vCam.
Here is the result of my test (Flash Player 10 Required):
Flash CS4 Issues
I've made a minor change to the vCam AS3 that should fix a problem when applying filters in CS4.
1 commentvCam AS3 Interactive
Note: Just released Beta 1.1.
Introducing vCam AS3 Interactive. The original vCam AS3 uses the BitmapData class to optimize performance during playback. When you view the vCam AS3 swf you are watching a bitmap transformation of the stage. While this is ideal for animation projects, it causes problems when you want to incorporate buttons or interactive elements into your presentation. I had a request this weekend for an interactive version of vCam AS3. This version will allow you to add interactive elements. However, you will notice a performance difference especially when applying the blur filter. The vCam AS2 already supports interactive elements since it does not use the BitmapData class for optimization.
 Download vCam AS3 Interactive
 Thanks tisi!
8 commentsFlash vCam AS3
Announcing vCam AS3 v1.1 for Flash! For those who aren't familiar with vCam, I'll offer a brief explanation. In 2005, Sham Bhangal and Dave Dixon released the original vCam or "virtual camera" for Flash. Let's say a Flash developer is working on an animation and wants the animation to pan from left to right. Without the vCam, the developer would have to create tweens for each layer in the timeline. Using the vCam, however, the developer can animate a single vCam instance on the timeline to create the same pan. Simply place the vCam on the left side of the stage and create a motion tween to the right side of the stage. Publish out the file and the scene pans with a single tween! The original vCam can also be used to adjust size and add color transformations.
Now vCam AS3 brings a new array of options with added features including:
- Rotation
- Blur
- Brightness/Contrast
- Hue/Saturation
- and more!
Sham and Dave were very generous and offered the original vCam free of charge. Therefore I am also offering this new version for free. Have fun all!
Version 1.1 has been optimized and the bitmap data processing has been removed.
Download vCam AS3 v1.1 FLA (Requires Flash CS3 and Actionscript 3)
*** Note: A bug in Flash CS3 causes stage.stageHeight to be -100 the actual stageHeight if the bandwidth profiler is open. Either close the profiler or view the SWF outside flash.
The animation below shows the vCam AS3 in action:
Artwork by Josh Menas | Composited by Tim Allen 73 comments
