vegui. fx. class.js

Summary
Effect manager
constructor
Initializes the manager at the set interval, note that this does not start the interval timer, it just sets the speed.
Activates the fx timer if any effects are currently active
Stops the fx timer
Adds an effect to a certain vegui element.
a certain effect for the element with the submited element index
This is the function that is repeatedly called by the fx timer.
The base object for any effect
constructor
Check if effect type exists in an array that collides with this array.
Initialize effect
halt()
fades the target element out, gradually reducing its transparency value to 0
extends VegUIEffect
concstructor
Execute effect
fades the target element in, gradually increasing its transparency value to 100
extends VegUIEffect
constructor
Executes effect
Adds a shadow effect to a specified vegUI element
extends VegUIEffect
executes effect
halt()
Adds a scaling effect to a vegui element that lets it either grow into view or shrink out of view.
extends VegUIEffect
executes/processes the effect
halts the event

Constants

Effect types

VUI_FX_FADEINfades the element in
VUI_FX_FADEOUTfades the element out
VUI_FX_SHADOWadds a shadow to the element
VUI_FX_SCALEgrow or shrink an element

VegUIFXManager

Effect manager

Summary
constructor
Initializes the manager at the set interval, note that this does not start the interval timer, it just sets the speed.
Activates the fx timer if any effects are currently active
Stops the fx timer
Adds an effect to a certain vegui element.
a certain effect for the element with the submited element index
This is the function that is repeatedly called by the fx timer.

Properties

Object Properties

TimerInterval , the fx interval
intervalint, interval speed (ms)
effectNumint, number of active effects
EffectsArray, holds active effects
ManagerVegUIManager element that the fx manager belongs to

Functions

VegUIFXManager

function VegUIFXManager(Manager)

constructor

Parameters

VegUIManager ManagerVegUI manager object

initialize

Initializes the manager at the set interval, note that this does not start the interval timer, it just sets the speed.

Paramters

int intervalfx timer interval (ms)

Example

// initialize the fx manager's effect interval to run at 50 ms

FX.init(50);

start

this.start = function()

Activates the fx timer if any effects are currently active

Returns

nullif Timer is already running
int0, if no effects are queued

See Also

stop

stop

this.stop = function()

Stops the fx timer

Returns

int0

effect_add

this.effect_add = function(Element,
Effect,
onhalt)

Adds an effect to a certain vegui element.  Effects are added as objects

Parameters

VegUIElement Elementthe vegui element that the effect should hook on
VegUIEffect Effectthe effect
<function onhalt>if submitted this function will be called when the effect is done

Code example

FX.effect_add(myNode, new VegUIFxFadeOut(2000));

Returns

VegUIEffectthe effect object

effect_pop

this.effect_pop = function(eleIdx,
type)

a certain effect for the element with the submited element index

Parameters

int eleIdxelement index of the vegui element
int typeeffect type

Example

// add fade out effect to myNode
FX.effect_add(myNode, new VegUIFxFadeOut(2000));

// remove fade out effect from myNode
FX.effect_pop(myNode.eleIdx, VUI_FX_FADEOUT);

poll

this.poll = function()

This is the function that is repeatedly called by the fx timer.  It polls the Effects array for any active effects and executes them

private function

VegUIEffect

The base object for any effect

Summary
constructor
Check if effect type exists in an array that collides with this array.
Initialize effect
halt()

Properties

Object Properties

ElementVegUIElement, the element this effect is affecting
typeint, effect type
ManagerVegUIFXManager, FX manager that controls this effect
isPassivebool, if true the effect will be executed when it is created and will not be added to the processing loop of the fx engine

Functions

VegUIEffect

function VegUIEffect()

constructor

collides

this.collides = function(Effects,
cancelOther)

Check if effect type exists in an array that collides with this array.  When effects collide it means that they can not be affecting the same target at the same time, and one will have to be canceled

Parameters

Array effectsthe array holding the effect objects
bool cancelOtherif true the effect in the effects array will be canceled if false 1 will be returned

Returns

int1 if there were coliding effects and cancelOther was false

init

this.init = function(Element,
Manager)

Initialize effect

Parameters

VegUIElement Elementelement this effect is affecting
VegUIFXManager ManagerManager that controls this effect

halt_effect

this.halt = this.halt_effect = function(noOnHalt)

Alias

halt()

Halts this effect, effectivly removing it

Parameters

bool noOnHaltif true <onhalt> will not be called

VegUIFXFadeOut

fades the target element out, gradually reducing its transparency value to 0

Hierarchy

extends VegUIEffect

Inherits all properties and methods from VegUIEffect

Example

// add fade out effect to myNode with a duration of 1000 ms

FX.effect_add(myNode, new VegUIFXFadeOut(1000));

// add fade out effect to myNode with a duration of 1000 ms and
// stop the effect when a transparency of 50% is reached

FX.effect_add(myNode, new VegUIFXFadeOut(1000, 50));

Properties

Object Properties

fadeSpeedint, speed of fading (ms)
limitint, effect will stop when this amount of transparency is reached

Functions

VegUIFXFadeOut

function VegUIFXFadeOut(fadeSpeed,
limit)

concstructor

Parameters

int fadeSpeedspeed of fading (ms)
int limiteffect will stopped when this amount of transparency is reached

execute

this.execute = function()

Execute effect

VegUIFXFadeIn

fades the target element in, gradually increasing its transparency value to 100

Hierarchy

extends VegUIEffect

Inherits all properties and methods from VegUIEffect

Example

// add the fade in effect with a duration of 1000 ms to myNode

FX.effect_add(myNode, new VegUIFXFadeIn(1000));

// add the fade in effect with a duration of 1000 ms to myNode, and
// make it stop when a transparency of 50% is reached

FX.effect_add(myNode, new VegUIFXFadeIn(1000, 50));

Properties

Object Properties

fadeSpeedint, speed of fading (ms)
limitint, effect will stop when this transparency value is reached

Functions

VegUIFXFadeIn

function VegUIFXFadeIn(fadeSpeed,
limit)

constructor

Parameters

int fadeSpeedspeed of fading (ms)
int limitstop when limit is reached (min 0, max 100)

execute

this.execute = function()

Executes effect

Hierarchy

extends VegUIEffect

Inherits all properties and methods from VegUIEffect

Example

// add shadow effect to myNode at an off set of 5 pixels on the x axis
// and 10 pixels on the y axis, with an opacity of 50% and the color
// black

FX.effect_add(myNode, new VegUIFXShadow(5,10,50,'#000');

Properties

Object Properties

xint, x offset of the shadow
yint, y offset of the shadow
opacityint, the opacity of the outer shadow
colorstring, color of the shadow (css value)
shadowNodeVegUINode, holds the shadow node

Functions

VegUIFXShadow

function VegUIFXShadow(x,
y,
opacity,
color)

execute

this.execute = function()

executes effect

halt_fx_shadow

this.halt = this.halt_fx_shadow = function(noOnHalt)

Alias

halt()

Parameters

<bool noOnHalt>if true the onhalt event of the effect will not be fired

See Also

<VegUIEffect::halt>

VegUIFXScale

Adds a scaling effect to a vegui element that lets it either grow into view or shrink out of view.

Summary

Hierarchy

extends VegUIEffect

Inherits all properties and methods from VegUIEffect

Example

// First we define the stunt node, the stunt node is the element
// that we will use to visualize the effect

var StuntNode = Manager.get_new(VUI_NODE);

// you can style it whichever way you want but we will just give
// it a white border in our example

StuntNode.T.Css.border = '1px #fff solid';
Manager.build_element(StuntNode);

// add the effect to shrink the node towards the coordinates
// 50,50 in 500 ms. The stunt node will be placed at
// z-index of 1000

FX.effect_add(50,50,500,1,StuntNode,true,1000);

Object Properties

xint, when growing the effect will start from here, when shrinking it will end here (x axis)
yint, when growing the effect will start from here, when shrinking it will end here (y axis)
speedint, scaling time (ms)
StuntNodeTemplateVegUIElement, template that will be used to clone the node that will be shown instead of the target element when unreasonable small sizes are reached
StuntNodeVegUIElement, holds the built StuntNode element while the effect is active
phaseint, the current phase of the effect
scaleTypeint, defines if the effect grows or shrinks the element (0 = grow, 1 = shrink)
useFadebool, if true the stunt node will be faded in/out as it moves
fadeLimitint, fade limit, if useFade is active fadeLimit prevents the fading past a certain value
zint, z index of the stunt node

Functions

VegUIFXScale

function VegUIFXScale(x,
y,
speed,
scaleType,
StuntNodeTemplate,
useFade,
z,
fadeLimit)

execute

this.execute = function()

executes/processes the effect

halt_scale

this.halt_scale = this.halt = function()

halts the event

Alias

halt()

See also

<VegUIEffect::halt>

function VegUIFXManager(Manager)
constructor
this.start = function()
Activates the fx timer if any effects are currently active
this.stop = function()
Stops the fx timer
this.effect_add = function(Element,
Effect,
onhalt)
Adds an effect to a certain vegui element.
this.effect_pop = function(eleIdx,
type)
a certain effect for the element with the submited element index
this.poll = function()
This is the function that is repeatedly called by the fx timer.
function VegUIEffect()
constructor
this.collides = function(Effects,
cancelOther)
Check if effect type exists in an array that collides with this array.
this.init = function(Element,
Manager)
Initialize effect
this.halt = this.halt_effect = function(noOnHalt)
halt()
fades the element out
function VegUIFXFadeOut(fadeSpeed,
limit)
concstructor
this.execute = function()
Execute effect
fades the element in
function VegUIFXFadeIn(fadeSpeed,
limit)
constructor
this.execute = function()
Executes effect
adds a shadow to the element
function VegUIFXShadow(x,
y,
opacity,
color)
this.execute = function()
executes effect
this.halt = this.halt_fx_shadow = function(noOnHalt)
halt()
The base object for any effect
grow or shrink an element
function VegUIFXScale(x,
y,
speed,
scaleType,
StuntNodeTemplate,
useFade,
z,
fadeLimit)
this.execute = function()
executes/processes the effect
this.halt_scale = this.halt = function()
halts the event
Effect manager