| Package | com.soma.model |
| Class | public class BackgroundManager |
| Implements | IDisposable |
Author: Romuald Quantin - www.soundstep.com
Information:
Blog page - SomaUI
How does it work - Soma Protest
Project Host - Google Code
Documentation - Soma ASDOC
Class version: 2.0
Actionscript version: 3.0
Copyright:
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied.
See the License for the specific language governing rights and
limitations under the License.
The Original Code is Soma.
The Initial Developer of the Original Code is Romuald Quantin.
Initial Developer are Copyright (C) 2008-2009 Soundstep. All Rights Reserved.
Usage:
The BackgroundManager handles backgrounds in a Sprite layer underneath the site and provides an easy way to load, display and hide backgrounds.
The backgrounds can automatically be loaded and/or instantiated from the XML Site Definition (nodes children of a backgrounds node).
The global background manager instance is accessible using:
Soma.getInstance().background
Soma.getInstance().background.container
Soma.getInstance().background.currentBackground
<video id="myVideo" url="video/video.flv" x="50" alpha=".5" verticalCenter="0" volume="0" />
<image id="myImage" file="image.png" scaleX=".5" scaleY=".5" blendMode="multiply" ratio="ratio_in"/>
<bitmap id="myBitmap" linkage="AssetClassNameBitmap" x="170" y="170" blendMode="multiply" scaleX=".3" scaleY=".3"/>
<movieclip id="myMovieClip" linkage="AssetClassNameMovieClip" x="170" y="280" scaleX=".3" scaleY=".3"/>
new BackgroundEvent(BackgroundEvent.SHOW, "myBackgroundID").dispatch();
new BackgroundEvent(BackgroundEvent.HIDE, "myBackgroundID").dispatch();
Soma.getInstance().addEventListener(BackgroundEvent.TRANSITION_IN, eventHandler);
Soma.getInstance().addEventListener(BackgroundEvent.TRANSITION_OUT, eventHandler);
See also
| Property | Defined by | ||
|---|---|---|---|
| baseUI : BaseUI
[read-only]
Get the BaseUI instance used if BaseUI properties have been found in the XML (such as ratio, alignX and so on).
| BackgroundManager | ||
| container : Sprite [read-only]
Get the Sprite container that contains the backgrounds, this container is by default on the index 0 in the display list (added to the main class).
| BackgroundManager | ||
| currentBackground : DisplayObject [read-only]
Get the current background displayed, returns a DisplayObject but you can cast the value returned to the proper type, example for a video node:
<video id="myVideo" url="video/video.flv" x="50" alpha=".5" verticalCenter="0" volume="0" />
var video:SomaVideo = Soma.getInstance().background.currentBackground as SomaVideo;
video.volume = .5;
| BackgroundManager | ||
| loader : SomaLoader
[read-only]
Get the SomaLoader instance used to load the backgrounds.
| BackgroundManager | ||
| parser : NodeParser
[read-only]
Get the NodeParser instance used to parse the nodes and instantiate the backgrounds.
| BackgroundManager | ||
| REPLAY_BACKGROUND_VIDEO : Boolean = true [static] Default value whether or not a background video will be played from the start when displayed.
| BackgroundManager | ||
| TRANSITION_EASING : Function [static] Default easing equations used to hide and show the background.
| BackgroundManager | ||
| TRANSITION_IN_TIME : Number = 2 [static] Default time value in seconds used to show a background (alpha tween).
| BackgroundManager | ||
| TRANSITION_OUT_TIME : Number = 2 [static] Default time value in seconds used to hide a background (alpha tween).
| BackgroundManager | ||
| Method | Defined by | ||
|---|---|---|---|
|
Creates a BackgroundManager instance, the global BackgroundManager instance is accessible using Soma.getInstance().background.
| BackgroundManager | ||
|
dispose():void
Disposes the BackgroundManager instance.
| BackgroundManager | ||
|
getBackgroundByID(id:String):DisplayObject
Get a background in the container using its attribute id from the XML node.
| BackgroundManager | ||
|
hide():void
Method called from the BackgroundEvent.HIDE command to hide the current background displayed.
| BackgroundManager | ||
|
show(id:String):void
Method called from the BackgroundEvent.SHOW command to show a background using its id from the XML node.
| BackgroundManager | ||
|
start():void
Entry point of the BackgroundManager, it will create (and load) the backgrounds from the children nodes of the backgrounds node from the XML Site Definition.
| BackgroundManager | ||
| baseUI | property |
baseUI:BaseUI [read-only]Get the BaseUI instance used if BaseUI properties have been found in the XML (such as ratio, alignX and so on).
Implementation public function get baseUI():BaseUI
| container | property |
container:Sprite [read-only]Get the Sprite container that contains the backgrounds, this container is by default on the index 0 in the display list (added to the main class).
Implementation public function get container():Sprite
| currentBackground | property |
currentBackground:DisplayObject [read-only]Get the current background displayed, returns a DisplayObject but you can cast the value returned to the proper type, example for a video node:
<video id="myVideo" url="video/video.flv" x="50" alpha=".5" verticalCenter="0" volume="0" />
var video:SomaVideo = Soma.getInstance().background.currentBackground as SomaVideo;
video.volume = .5;
public function get currentBackground():DisplayObject
| loader | property |
loader:SomaLoader [read-only]Get the SomaLoader instance used to load the backgrounds.
Implementation public function get loader():SomaLoader
| parser | property |
parser:NodeParser [read-only]Get the NodeParser instance used to parse the nodes and instantiate the backgrounds.
Implementation public function get parser():NodeParser
| REPLAY_BACKGROUND_VIDEO | property |
public static var REPLAY_BACKGROUND_VIDEO:Boolean = trueDefault value whether or not a background video will be played from the start when displayed.
| TRANSITION_EASING | property |
public static var TRANSITION_EASING:FunctionDefault easing equations used to hide and show the background.
| TRANSITION_IN_TIME | property |
public static var TRANSITION_IN_TIME:Number = 2Default time value in seconds used to show a background (alpha tween).
| TRANSITION_OUT_TIME | property |
public static var TRANSITION_OUT_TIME:Number = 2Default time value in seconds used to hide a background (alpha tween).
| BackgroundManager | () | constructor |
public function BackgroundManager()Creates a BackgroundManager instance, the global BackgroundManager instance is accessible using Soma.getInstance().background.
| dispose | () | method |
public function dispose():voidDisposes the BackgroundManager instance. Removes listeners and destroys backgrounds, loader, parser and container.
| getBackgroundByID | () | method |
public function getBackgroundByID(id:String):DisplayObjectGet a background in the container using its attribute id from the XML node.
Parametersid:String |
DisplayObject — A DisplayObject instance.
|
| hide | () | method |
public function hide():voidMethod called from the BackgroundEvent.HIDE command to hide the current background displayed.
| show | () | method |
public function show(id:String):voidMethod called from the BackgroundEvent.SHOW command to show a background using its id from the XML node.
Parametersid:String — Attribute id of the XML node asset (in backgrounds node in the XML Site Definition).
|
| start | () | method |
public function start():voidEntry point of the BackgroundManager, it will create (and load) the backgrounds from the children nodes of the backgrounds node from the XML Site Definition.