Packageorg.ffilmation.engine.core
Classpublic class fEngine
InheritancefEngine Inheritance flash.events.EventDispatcher

The fEngine class is the main class in the game engine.

Use the fEngine class to create and attach game scenes to your game.

You can also use it to load external swfs containing media you want to add to you scenes.

Once the scenes are created you can go from one to another using the methods in the fEngine class. The class handles all the drawing and screen refreshing.


Example
The following code sets a basic isometric application with one scene
  // Create container
  var filmationTest:Sprite = new Sprite()
  addChild(filmationTest)
  filmationTest.x = 0
  filmationTest.y = 100
  
  // Create engine
  var film = new fEngine(filmationTest)
  
  // Create scene and listen to load events
  var scenel = film.createScene(new fSceneLoader("western.xml"),800,400)
  scenel.addEventListener(fScene.CHANGESTAT, actionHandler)
  scenel.addEventListener(fScene.LOAD, loadHandler)

  function actionHandler(evt:Event) {
    trace("EVENT "+evt.target.stat)
  }
    function loadHandler(evt:Event) {
   // Scene is loaded and ready
  
   // Create a camera and make it active
   var cam = scenel.createCamera()
   scenel.setCamera(cam)
  
   // Render
   scenel.render()
   film.showScene(scenel)
  }  
    



Public Properties
 PropertyDefined by
  bumpMapping : Boolean
[static] This property enables/disables bumpmapping globally.
fEngine
  characterShadows : Boolean
[static] This property enables/disables shadow projection of characters
fEngine
  container : Sprite
fEngine
  objectShadows : Boolean
[static] This property enables/disables shadow projection of objects
fEngine
  shadowQuality : int
[static] This property defines the quality at which object and character shadows are rendered
fEngine
Public Methods
 MethodDefined by
  
fEngine(container:Sprite)
Constructor for the fEngine class.
fEngine
  
createScene(retriever:fEngineSceneRetriever, width:Number, height:Number, renderer:fEngineRenderEngine = null, prof:fProfiler = null):fScene
This method creates an scene from an XML definition file.
fEngine
  
This method frees all resources allocated by an scene.
fEngine
  
hideScene(sc:fScene, destroyRender:Boolean = true):void
Hides an scene.
Hiding an scene does not disable it.
If you hide an scene all the Sprites and graphic resources are destroyed, and so are Mouse Events attached to them.
fEngine
  
loadMedia(src:String):*
This method loads an external media file.
fEngine
  
showScene(sc:fScene):void
Makes visible one scene in the Engine.
fEngine
Public Constants
 ConstantDefined by
  MEDIALOADCOMPLETE : String = "enginemedialoadcomplete"
[static] The fEngine.MEDIALOADCOMPLETE constant defines the value of the type property of the event object for a enginemedialoadcomplete event.
fEngine
  MEDIALOADERROR : String = "enginemedialoaderror"
[static] The fEngine.MEDIALOADERROR constant defines the value of the type property of the event object for a enginemedialoaderror event.
fEngine
  MEDIALOADPROGRESS : String = "enginemedialoadprogress"
[static] The fEngine.MEDIALOADPROGRESS constant defines the value of the type property of the event object for a enginemedialoadprogress event.
fEngine
  VERSION : String = "1.3.2"
[static] Just in case you want to display it
fEngine
Property detail
bumpMappingproperty
bumpMapping:Boolean  [read-write]

This property enables/disables bumpmapping globally. Please note that for the bumpMapping to work in a given surface and light, the surface will need a bumpMap definition and the light must be defined as bumpmapped. Beware that only fast computers will be able to handle this in realtime

Implementation
    public static function get bumpMapping():Boolean
    public function set bumpMapping(value:Boolean):void
characterShadowsproperty 
characterShadows:Boolean  [read-write]

This property enables/disables shadow projection of characters

Implementation
    public static function get characterShadows():Boolean
    public function set characterShadows(value:Boolean):void
containerproperty 
public var container:Sprite
objectShadowsproperty 
objectShadows:Boolean  [read-write]

This property enables/disables shadow projection of objects

Implementation
    public static function get objectShadows():Boolean
    public function set objectShadows(value:Boolean):void
shadowQualityproperty 
shadowQuality:int  [read-write]

This property defines the quality at which object and character shadows are rendered

Implementation
    public static function get shadowQuality():int
    public function set shadowQuality(value:int):void

See also

Constructor detail
fEngine()constructor
public function fEngine(container:Sprite)

Constructor for the fEngine class.

Parameters
container:Sprite — An sprite object where the engine will draw your game
Method detail
createScene()method
public function createScene(retriever:fEngineSceneRetriever, width:Number, height:Number, renderer:fEngineRenderEngine = null, prof:fProfiler = null):fScene

This method creates an scene from an XML definition file. The scene starts loading and compiling at this moment, but will not be ready to use yet. You should wait for the scene's LOAD event before making it active

Parameters
retriever:fEngineSceneRetriever — Any class that implements the fEngineSceneRetriever interface
 
width:Number — Width of the viewport, in pixels. This avoids the need of masking the whole sprite
 
height:Number — Height of the viewport, in pixels. This avoids the need of masking the whole sprite
 
renderer:fEngineRenderEngine (default = null) — A renderer class for this scene. If none is specified, a default flash 9 renderer will be used
 
prof:fProfiler (default = null) — If a profiler is passed, the scene will update the profiler with some info that I hope becomes useful to tune the performance of your application

Returns
fScene — A fScene Object.
destroyScene()method 
public function destroyScene(sc:fScene):void

This method frees all resources allocated by an scene. Use this as often as possible and always clean unused scene objects: scenes generate lots of internal Arrays and BitmapDatas that will eat your RAM fast if they are not properly deleted

Parameters
sc:fScene — The fScene you want to destroy
hideScene()method 
public function hideScene(sc:fScene, destroyRender:Boolean = true):void

Hides an scene.
Hiding an scene does not disable it.
If you hide an scene all the Sprites and graphic resources are destroyed, and so are Mouse Events attached to them. You will need to reset the events if the scene is shown again.

Parameters
sc:fScene — The fScene you want to hide
 
destroyRender:Boolean (default = true) — Pass false if you don't want the rendering to be destroyed when you hide the scene. By doing this, the graphics are already available when the scene is shown again
loadMedia()method 
public function loadMedia(src:String):*

This method loads an external media file. Once the media file is loaded, the symbols in that file can be used in you scene definitions. Listen to the engine's MEDIALOADPROGRESS and MEDIALOADCOMPLETE to control the process. The class checks if the media is already loaded to avoid duplicate loads.

WARNING ! If you want to use the engine from within an Adobe AIR application, make sure to execute this line: fEngine.context.allowLoadBytesCodeExecution = true before creating an scene. Otherwise assets won't load into the application security domain and won't work.

Parameters
src:String — Path to the swf file you want to load

Returns
*
showScene()method 
public function showScene(sc:fScene):void

Makes visible one scene in the Engine. Only one scene can be visible at the same time. The current visible scene, if any, will me moved to the invisible scene list.
Showing an scene does not enable it

Parameters
sc:fScene — The fScene you want to activate
Constant detail
MEDIALOADCOMPLETEconstant
public static const MEDIALOADCOMPLETE:String = "enginemedialoadcomplete"

The fEngine.MEDIALOADCOMPLETE constant defines the value of the type property of the event object for a enginemedialoadcomplete event. The event is dispatched when the external media file finishes loading.

MEDIALOADERRORconstant 
public static const MEDIALOADERROR:String = "enginemedialoaderror"

The fEngine.MEDIALOADERROR constant defines the value of the type property of the event object for a enginemedialoaderror event. The event is dispatched when the external media file is not loaded.

MEDIALOADPROGRESSconstant 
public static const MEDIALOADPROGRESS:String = "enginemedialoadprogress"

The fEngine.MEDIALOADPROGRESS constant defines the value of the type property of the event object for a enginemedialoadprogress event. The event is dispatched when there is a progress in loading an external media file, allowing to update a progress bar, for example.

VERSIONconstant 
public static const VERSION:String = "1.3.2"

Just in case you want to display it