October 30, 2008
The below class serves as Garbage Collection utility for AS3. You can use it to prevent your applications from memory leakage.
package{
import flash.events.TimerEvent;
import flash.system.System;
import flash.utils.Timer;
public class GCUtil {
private var _timer:Timer;
public function GCUtil(interval_sec:uint = 60) {
_timer = new Timer(interval_sec*1000);
startGC(interval_sec);
}
public static function doGC():void {
System.gc();
}
public function startGC(interval_sec:uint):void {
if (interval_sec > 0) {
_timer.delay = interval_sec*1000;
if (!_timer.running) {
_timer.addEventListener(TimerEvent.TIMER, handleTimer);
_timer.start();
}
} else {
stopGC();
}
}
public function stopGC():void {
if (!_timer.running) {
_timer.removeEventListener(TimerEvent.TIMER, handleTimer);
_timer.stop();
_timer.delay = 0;
}
}
private function handleTimer(te:TimerEvent):void {
doGC();
}
}
}
6 Comments |
Flex | Tagged: as3, Flex, garbage collection, gc, leakage, mange, memory, using, util |
Permalink
Posted by nsdevaraj
October 29, 2008
I am glad to announce the first Step for basic requirements of E-Learning using Flex has been achieved.
Basic Requirements met:
- All Flash player versions starting from Flash Player version 6 to 10, should be loaded. (For support of old elearning courses).
- Without any memory leak due to loading multiple swf files.
- Ability to navigate to any particular lesson (SWF).
- XML Support for loading swf files into a lesson.
- PreLoader for showing the loading status of individual SWF files
- Ability to detect events of SWF files (eg: totalframes, swf playing etc.,)
See the demo of loading a number of animations. The source files include floader.mxml, ForcibleLoader.as and XML
2 Comments |
Flex | Tagged: as3, avm1movie, dynamic, e-learning, elearning, enterframe, flash, Flex, IViewCursor, using, XML |
Permalink
Posted by nsdevaraj
October 16, 2008
Overcome restrictions on an AVM1 SWF file loaded by an AVM2 SWF file:
While trying to control AVM1Movie (Flash Player 8, 9, 10 or older) from flex, we will get the below error message: ”Property stop not found on flash.display.AVM1Movie and there is no default value. ”
To overcome this problem, ForcibleLoader class converts them into latest player versions on runtime. The below is an working example for how to control AVM1Movie from Flex.
<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute” initialize=”init()”>
<mx:Script>
<![CDATA[
private var swfURL:String = "AVM1Movie.swf";
private var libMC:MovieClip = new MovieClip();
private function init():void{
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfComplete);
var fLoader:ForcibleLoader = new ForcibleLoader(loader);
fLoader.load(new URLRequest(swfURL));
swfContainer.addChild(loader);
}
private function swfComplete(event:Event):void{
libMC = event.currentTarget.content as MovieClip;
libMC.gotoAndStop(1);
}
]]>
</mx:Script>
<mx:UIComponent id=”swfContainer”/>
<mx:NumericStepper id=”slide” change=”{libMC.gotoAndStop(slide.value)}”/>
</mx:Application>
32 Comments |
Flex | Tagged: 6, 7, 8, as3, avm1movie, avm2movie, controller, example, flash, Flex, forcibleloader, load, Movieclip, swf |
Permalink
Posted by nsdevaraj
October 4, 2008
The below is the code to load flash library asset (using linkage name) on Flex.
<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” creationComplete=”onCreationComplete()” >
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
private function onCreationComplete():void{
var swfLoader:Loader = new Loader();
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onSWFLoadComplete);
swfLoader.load(new URLRequest("flash.swf"));
}
private function onSWFLoadComplete(event:Event):void{
var tempClass:Class = event.target.applicationDomain.getDefinition("libraryAsset") as Class;
var movieClip:MovieClip = new tempClass() as MovieClip;
var uiComp:UIComponent = new UIComponent();
uiComp.addChild(movieClip);
addChild(uiComp);
}
]]>
</mx:Script>
</mx:Application>
2 Comments |
Flex | Tagged: applicationDomain, as3, Class, flash, Flex, getDefinition, library, linkage, linkage name, Movieclip, UIComponent |
Permalink
Posted by nsdevaraj