Share 'LifeCycle' on Delicious Share 'LifeCycle' on Facebook Share 'LifeCycle' on Google Bookmarks Share 'LifeCycle' on Twitter

  1. LifeCycle workflow
  2. Principle of operation
    1. Differences between LifeCycle and I10N
    2. Comparison Flex and LifeCycle
  3. Setting up LifeCycle
  4. Setting up a component adapter
    1. Component adapter
    2. The LifeCycle adapter hooks
    3. Register the adapter
  5. Setting up a component
    1. Implementing the life cycle methods
    2. Invalidating the component
    3. Immediately validating the component
    4. Partial invalidation
    5. Full invalidation
    6. Adding and removing components from the display list
    7. Creating nested components
  6. LifeCycleView
  7. Example application
    1. LifeCycle service instance
    2. The main application
    3. The component
    4. The adapter
    5. The example SWF
  8. Comments (117)
  9. Leave a Comment

LifeCycle

LifeCycle provides a ready-made component life cycle implementation. If you know Flex, LifeCycle is an alternative to the Flex’s component life cycle.

Read the LifeCycle introduction to get familiar with the meanings of Invalidation & LifeCycle.

LifeCycle workflow

The chart shows the simplified workflow of LifeCycle. The LifeCycleAdapter is not shown for complexity reasons. Click to enlarge.

Principle of operation

The working principle of LifeCycle is basically the same as that of Invalidation. The very heart of LifeCycle is an internal configuration of I10N. All the functionalitiy of I10N is also available in LifeCycle.

In order to get familiar with LifeCycle, you need to read first the Invalidation documentation. The document here mostly describes the differences between I10N and LifeCycle.

LifeCycle is connected between your component on the left and I10N on the right side.

You work with LifeCycle the same way as with I10N. You create a component specific adapter, implement some life cycle methods in your component that can be called by the adapter and finally register component and adapter with LifeCycle.

Differences between LifeCycle and I10N

While you use I10N to create your own custom life cycle, the LifeCycle system can be used without the need of any configuration and out of the box.

  • You need to add phases to I10N. LifeCycle already consists of three phases.
  • With I10N you are free to invalidate components from everywhere at any time. LifeCycle restricts invalidations to be allowed only under certain circumstances.

  • A particular I10NAdapter has only one invalidation method, parameterized with the phase name to invalidate for. A LifeCycleAdapter has three methods, one for each phase.
  • A particular I10NAdapter has only one validation hook, parameterized with the phase name to validate for. A LifeCycleAdapter has three validation hooks, one for each phase.
  • A LifeCycleAdapter provides an init hook, an I10NAdapter does not.

Comparison Flex and LifeCycle

The Flex live cycle methods are described in the document About creating advanced MX components. It might help you to get more familiar with LifeCycle when you already know Flex.

Generally, LifeCycle and Flex are very similiar, and LifeCycle is far more restrictive and predictable in usage.

Validation phases

Flex LifeCycle
CommitProperties (top-down) Validation (top-down)
Measurement (bottom-up) Defaults calculation (bottom-up)
Display list update (top-down) Rendering (top-down)

Invalidation methods

Flex LifeCycle
invalidateProperties() invalidate(property)
invalidateSize() invalidateDefault(property)
invalidateDisplayList() scheduleRendering(property)

Validation methods

Flex LifeCycle
createChildren() onInit()
commitProperties() onValidate()
measure() calculateDefaults()
updateDisplayList() onRender()

Externalization of invalidation

Flex allows you to invalidate any component from everywhere and at any time. When implementing LifeCycle for a component, it is recommended not to externalize the invalidation functionality. A client using a LifeCycle component never should know about internal invalidation features. Instead, a component should be invalidated only by their property setters.

Invalidation for secondary phases

Flex allows a component to invalidate another component for all validation phases. LifeCycle does not. A component can only be invalidated for the first phase. Only the component decides whether validation in further phases is necessary. The component may invalidate for those phases (only) during the validation of the first phase.

Especially, you are not allowed to invalidate anything being in the rendering phase. You need to make sure that any calculation and invalidation is done before entering this phase.

Measurement/Calculation phase

The Flex measurement pass is in LifeCycle called “Defaults calculation” and has a broader meaning. Not only default sizes need to be calculated here but values for any property not set yet.

Setting up LifeCycle

You simply create an instance of LifeCycle and have done. There can be multiple instances of LifeCycle but it is recommended to only create a sole instance. It is up to you to manage the instance using a global, a singleton, monostate or pooling pattern.

SetupLifeCycle.as
1
2
3
4
5
6
7
8
9
10
11
package lifecycle.lifecycle {
  import flash.display.Sprite;
  import org.as3commons.ui.lifecycle.lifecycle.LifeCycle;

  public class SetupLifeCycle extends Sprite {
    public function SetupLifeCycle() {
      var lifeCycle : LifeCycle = new LifeCycle();
      lifeCycle; // suppress ide warning for unused variable ;-)
    }
  }
}

Setting up a component adapter

LifeCycle is designed to work with independent components or display objects. You don’t need to extend a base class or implement a specific interface for your component. To anyhow let LifeCycle communicate with your component you need to create and register a component adapter. This adapter must be a subclass of the base adapter LifeCycleAdapter and is therefore known by LifeCycle. On the other hand, the adapter knows the component interface and can delegate the LifeCycle callbacks to your component.

Component adapter

For a component adapter you extend LifeCycleAdapter. You then have to override the five (or some of them) protected life cycle methods. You may refer to all of the base adapter properties e.g. the property _displayObject, which points to the component registered together with the apdater in LifeCycle or the property _nestLevel, which returns the display list depth of the display object.

SimpleAdapter.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package lifecycle.lifecycle {
  import org.as3commons.ui.lifecycle.lifecycle.LifeCycleAdapter;

  public class SimpleAdapter extends LifeCycleAdapter {
    override protected function onInit() : void {
      Dummy(displayObject).init();
      Dummy(displayObject).createChildren();
    }

    override protected function onValidate() : void {
      Dummy(displayObject).validate();
    }

    override protected function onMeasure() : void {
      Dummy(displayObject).measure();
    }

    override protected function onUpdate() : void {
      Dummy(displayObject).update();
    }
  }
}

import flash.display.Sprite;
internal class Dummy extends Sprite {
  internal function init() : void {
    // init something e.g. styles or listeners
  }
  internal function createChildren() : void {
    // create and add children
  }
  internal function validate() : void {
    // set properties to children
    // schedule calls to measure and update
  }
  internal function measure() : void {
    // calculate (default) size of the component
  }
  internal function update() : void {
    // draw something or arrange children
  }
}

The LifeCycle adapter hooks

onInit()

When it is invoked

  • Once for a component
  • Right after the component has been registered with LifeCycle – if the component already has been added to the display list.
  • Immediately after the component has been added to the display list – if the component was not in the display list the time it has been registered with LifeCycle.

Purpose

  • Set up initial property values
  • Set up general event listeners
  • Perform display list related operations such as calculating styles that depend on parent components or the display list depth of the component
  • Create and add all sub components

onValidate()

When it is invoked

LifeCycle triggers the onValidate() callback of a LifeCycle adapter whenever the component has been invalidated beforehand for the validation phase (first phase).

Purpose

  • Check and update properties
  • Set properties to children or other objects (which will probably invalidate them again for the first phase)
  • Invalidate the component for the calculation or/and the rendering phase.

onCalculateDefaults()

When it is invoked

Whenever the component has been invalidated beforehand for the defaults calculation phase (second phase).

Purpose

  • Calculate values for all properties not set yet
  • Update properties
  • Set properties to children or other objects (which will probably invalidate them again for the first phase)
  • Invalidate the component for the rendering phase. You cannot invalidate the component here for the defaults calculation phase again.

onRender()

When it is invoked

Whenever the component has been invalidated beforehand for the rendering phase (third phase).

Purpose

  • Execute the update of the component’s appearance.
  • Perform some drawings.
  • Layout children.
  • You cannot invalidate the component here for any of the phases. The component already must have set all properties before entering the rendering phase.

onCleanUp()

When it is invoked

After the component has been unregistered from LifeCycle.

Purpose

Remove all foreign references and event registrations to make the component eligible for garbage collection.

onAddedToStage(), onRemovedFromStage()

See the I10N documentation.

Register the adapter

You register your component together with its LifeCycle adapter anywhere in your code. It is recommended to do this in the constructor of the component since the component needs to know this adapter in order to trigger the LifeCycle system. Nevertheless, you need to manage the single LifeCycle instance on your own. In the following example this instance is passed to the constructor of the component.

SimpleRegistration.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package lifecycle.lifecycle {
  import flash.display.Sprite;
  import org.as3commons.ui.lifecycle.lifecycle.LifeCycle;

  public class SimpleRegistration extends Sprite {
    public function SimpleRegistration() {
      var lifeCycle : LifeCycle = new LifeCycle();
      addChild(new Component(lifeCycle));
    }
  }
}

import flash.display.Sprite;
import lifecycle.lifecycle.SimpleAdapter;
import org.as3commons.ui.lifecycle.lifecycle.LifeCycle;

internal class Component extends Sprite {
  private var _lcAdapter : SimpleAdapter;
  public function Component(lifeCycle : LifeCycle) {
    _lcAdapter = new SimpleAdapter();
    lifeCycle.registerDisplayObject(this, _lcAdapter);
  }
}

Setting up a component

The component communicates with LifeCycle using its component adapter. So it is necessary to store the adapter reference in a component variable. To finish the setup we only need to implement the life cycle methods that are called by the associated adapter.

Implementing the life cycle methods

The life cycle methods are those methods that are called within the component adapter’s callbacks onInit(), onValidate(), onCalculateDefaults(), onRender(), onCleanUp(). The purpose of the methods is already discussed in the LifeCycle adapter section. Its entirely free how to implement these methods. Using a custom namespace is possible as well as passing a random number of arguments. The only thing is that that the adapter may reach the method.

function myInitMethod() : void {
  // do something
}

function myValidationMethod() : void {
  // do something
}

function myCalculateDefaultsMethod() : void {
  // do something
}

function myRenderMethod() : void {
  // do something
}

function myCleanUpMethod() : void {
  // do something
}

Invalidating the component

See the Invalidation documentation for information on invalidating a component in general. In difference to I10N you use a distinct invalidation method for each validation phase.

  • invalidate(property), invalidates the component so that its validation method gets called during the next validation cycle.
  • invalidateDefaults(property), invalidates the component so that its calculate defaults method gets called during the next validation cycle.
  • scheduleRendering(property), invalidates the component so that its render method gets called during the next validation cycle.

There are some restrictions that apply to the situations when invalidation is allowed or not:

  • You can invalidate for a secondary phase only within a validation method of the same component.
  • You can not invalidate a component for a secondary phase from within another component.
  • You can not invalidate anything within the rendering phase.
  • You can not invalidate for the calculate defaults phase within this phase.
public function set color(color : uint) : void {
  _color = color;
  _lifeCycleAdapter.invalidate("color");
}

public function set text(text : String) : void {
  _text = text;
  _lifeCycleAdapter.invalidate("text");
}

function validate() : void {
  if (_lifeCycleAdapter.isInvalid("text")) {
    _lifeCycleAdapter.scheduleRendering("text");
  }
 
  if (_lifeCycleAdapter.isInvalid("color")) {
    _lifeCycleAdapter.scheduleRendering("background");
  }
}

It’s a good practise to invalidate a component right in its constructor (without passing arguments) to get the component running through the validation phases initially. This call is not scheduled automatically by LifeCycle.

public function MyComponent() {
  _lifeCycleAdapter = new MyComponentAdapter();
  LifeCycleService.register(this, _lifeCycleAdapter);
  _lifeCycleAdapter.invalidate();
}

function validate() : void {
  trace (_lifeCycleAdapter.isInvalid("text")); // true;
  trace (_lifeCycleAdapter.isInvalid("color")); // true;
}

Immediately validating the component

A call to the validateNow() of the associated adapter will immediately validate the component – if the component has been invalidated beforehand. This can be useful when necessary properties of the component are calculated during the validation and we need these properties right away.

You are not allowed to call validateNow() during a running validation cycle. This also means, you can’t set up nested calls to validateNow().

_lifeCycleAdapter.validateNow();

Partial invalidation

Often we don’t want to update a component entirely but only in parts. We can manage partial invalidations using properties that get passed to the invalidation methods. Being later in a validation method (validate, calculateDefaults, render) we can test the life cycle adapter if a property has been invalidated or not. See the Invalidation documentation for information on invalidating properties.

function set color(color : uint) : void {
  _color = color;
  _lifeCycleAdapter.invalidate("color");
}

function set text(text : String) : void {
  _text = text;
  _lifeCycleAdapter.invalidate("text");
}

function validate() : void {
  trace(_lifeCycleAdapter.isInvalid("color")) // true
  trace(_lifeCycleAdapter.isInvalid("text")) // true
  trace(_lifeCycleAdapter.isInvalid("test")) // false
 
  _lifeCycleAdapter.scheduleRendering("background");
  _lifeCycleAdapter.invalidateDefaults("size");
}

function calculateDefaults() : void {
  trace(_lifeCycleAdapter.defaultIsInvalid("size")); // true
  trace(_lifeCycleAdapter.defaultIsInvalid("color")); // false
}

function render() : void {
  trace(_lifeCycleAdapter.shouldRender("background")); // true
  trace(_lifeCycleAdapter.shouldRender("border")); // false
}

Full invalidation

See the Invalidation documentation for information on full component invalidation.

function test() : void {
  _lifeCycleAdapter.invalidate(); // everything will be invalid
  _lifeCycleAdapter.invalidate("test");
}

function validate() : void {
  trace (_lifeCycleAdapter.isInvalid("test")); // true
  trace (_lifeCycleAdapter.isInvalid("hoho")); // true
  trace (_lifeCycleAdapter.isInvalid("everything")); // true
}

Adding and removing components from the display list

It is safe to add or remove a component from the display list at any time with LifeCycle. If you invalidate a component and remove the component from the display list the same time, the validation will happen the component is added again. Vice versa, if you invalidate a component not in the display list, the validation will happen after the component is added again.

AddRemoveFromDisplayList.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package lifecycle.lifecycle {
  import flash.display.Sprite;
  import flash.utils.setTimeout;
  import org.as3commons.ui.lifecycle.lifecycle.LifeCycle;

  public class AddRemoveFromDisplayList extends Sprite {
    private var _component : Component;
   
    public function AddRemoveFromDisplayList() {
      var lifeCycle : LifeCycle = new LifeCycle();
      _component = new Component(lifeCycle);
      addChild(_component);
      setTimeout(update1, 1000);
    }
   
    private function update1() : void {
      trace ("update1");
      _component.invalidate();
      removeChild(_component); // not updated in this frame
      setTimeout(update2, 1000);
    }

    private function update2() : void {
      trace ("update2");
      addChild(_component); // update in this frame
    }
  }
}

import flash.display.Sprite;
import org.as3commons.ui.lifecycle.lifecycle.LifeCycle;
import org.as3commons.ui.lifecycle.lifecycle.LifeCycleAdapter;


internal class Component extends Sprite {
  private var _lcAdapter : ComponentAdapter;
  public function Component(lifeCycle : LifeCycle) {
    _lcAdapter = new ComponentAdapter();
    lifeCycle.registerDisplayObject(this, _lcAdapter);
  }
  public function invalidate() : void {
    _lcAdapter.invalidate();
  }
  public function update() : void {
    trace ("UPDATE");
  }
}

internal class ComponentAdapter  extends LifeCycleAdapter {
  override protected function onValidate() : void {
    Component(displayObject).update();
  }
}

The trace:

update1
update2
UPDATE

Creating nested components

Parent-child dependencies

The majority of nested components will have a parent-child dependeny. Properties set to the parent are evaluated and delegated to its children. This is the default case and very well covered by all explanations already made in this document.

  • Parent receives new property value
  • Parent invalidates
  • Within parent’s validate method, parent sets the property on its child
  • The child invalidates
  • Both are rendered
public function set property(property : String) : void {
  _property = property;
  _adapter.invalidate("property");
}

function init() : void {
  _child = new Child();
  addChild(_child);
}

function validate() : void {
  if (_adapter.isInvalid("property")) {
    _child.property = property;
  }
}

function render() : void {
  ...
}

We do not set this property directly to the child within the set property method, since the child might not be created yet. Using LifeCycle, a child should be created in the initialization phase of the component, which is triggered by the according onInit() hook of the component’s life cycle adapter.

Child-parent dependencies

Examples are autosized components such as a button, that aligns to its label size or a layout container, that has the size of its children.

Flex deals with this dependency by providing a invalidateParentSizeAndDisplayList method. Whenever a component size changes, the component invalidates its parent component, and the parent decides if it should update or not. Flex can do this because all of the objects that Flex allows are subclasses of UIComponent. LifeCycle instead does not make assumptions on parents and solves the problem differently and more independently.

  • If a parent depends on a property of its child, the child should dispatch a change event to that the parent is listening.
  • Whenever such an event is received, the parent invalidates and later validates.

If both, parent and child, implement LifeCycle, the event must be dispatched before the rendering phase is entered. Otherwise the parent will try to invalidate, which will cause an error since further invalidations are not allowed during the rendering phase as already described. The rendering phase is the place where only updates to the display list may occur and all properties need to be brought in a valid state beforehand.

The child can therefore dispatch the change event at three places:

  • Outside of the running validation cycle
  • Within the first validation phase (validation)
  • Within the second validation phase (defaults calculation)

There should actually be no case a property depends on the result of the rendering of a component so that the event cannot be dispatched before rendering the component. However, if this happens, move the rendering to the defaults calculation method and set an internal flag that the component is already rendered.

Example: The autosize button depends on the label’s size. The label’s size depends on its text and formatting rules.

  • Button listens to the label’s size change event
  • Label text changes
  • Within its validate method, the label invalidates for the calculate defaults phase
  • Within the defaults calculation method, the label measures the current size using the TextField.getLineMetrics() method. The label updates its width and height properties and dispatchs a change event
  • The button receives the event and invalidates
  • Within its validate method, the button reads the label’s size and updates its own size accordingly
  • Both are rendered

LifeCycleView

LifeCycle contains an example UI base class called LifeCycleView that already implements the LifeCycleAdapter. The class hides all LifeCycle aspects from its subclasses and instead offers protected methods you can invoke or override as you like. You may use this class to right away create components from or to study the code.

Example application

The example shows the set up of LifeCycle for a component (including adapter) and the main application.

LifeCycle service instance

We simply extend LifeCycle and create a singleton we can refer to from our classes.

LifeCycleService.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package lifecycle.lifecycle.boxexample {
  import org.as3commons.ui.lifecycle.lifecycle.LifeCycle;

  public class LifeCycleService extends LifeCycle {
    private static var _instance : LifeCycle;
   
    public static function start() : void {
      _instance = new LifeCycle();
    }
   
    public static function get instance() : LifeCycle {
      return _instance;
    }
  }
}

The main application

The main class creates and registers adapter and selector, adds a list of boxes to the stage and modifies different properties on the boxes several times.

BoxLifeCycleExample.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package lifecycle.lifecycle.boxexample {
  import flash.utils.setTimeout;
  import flash.display.Sprite;

  public class BoxLifeCycleExample extends Sprite {
    private var _box1 : Box;
    private var _box2 : Box;
    private var _box3 : Box;
    private var _box4 : Box;
   
    public function BoxLifeCycleExample() {
      LifeCycleService.start();
     
      _box1 = new Box("Box1");
      addChild(_box1);

      _box2 = new Box("Box2");
      _box2.x = 120;
      _box2.backgroundColor = 0x333333;
      _box2.borderColor = 0x999999;
      _box2.backgroundColor = 0x999999;
      _box2.borderColor = 0x333333;
      addChild(_box2);

      _box3 = new Box("Box3");
      _box3.x = 240;
      _box3.backgroundColor = 0xCC0000;
      _box3.borderColor = 0x550000;
      addChild(_box3);
      _box3.backgroundColor = 0x3366CC;
      _box3.borderColor = 0x002244;

      _box4 = new Box("Box4");
      _box4.x = 360;
      addChild(_box4);
      _box4.backgroundColor = 0x3366CC;
      _box4.borderColor = 0x002244;
      _box4.backgroundColor = 0xCC6633;
      _box4.borderColor = 0x442200;
     
      setTimeout(update, 1000);
    }
   
    private function update() : void {
      _box1.backgroundColor = 0x990099;
      _box1.borderColor = 0x330033;
      _box1.backgroundColor = 0x009900;
      _box1.borderColor = 0x003300;

      _box2.backgroundColor = 0x999999;
      _box2.borderColor = 0x333333;
      _box2.backgroundColor = 0x333333;
      _box2.borderColor = 0x999999;

      _box3.backgroundColor = 0x3366CC;
      _box3.borderColor = 0x002244;
      _box3.backgroundColor = 0xCC0000;
      _box3.borderColor = 0x550000;

      _box4.backgroundColor = 0xCC6633;
      _box4.borderColor = 0x442200;
      _box4.backgroundColor = 0x3366CC;
      _box4.borderColor = 0x002244;
    }
  }
}

The component

Whenever a property changes, the component calls the invalidate() method of its adapter.

Box.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package lifecycle.lifecycle.boxexample {
  import flash.display.Sprite;

  public class Box extends Sprite {
    private var _adapter : BoxAdapter;
    private var _backgroundColor : uint;
    private var _borderColor : uint;

    public function Box(boxName : String) {
      name = boxName;
      _adapter = new BoxAdapter();
      LifeCycleService.instance.registerDisplayObject(this, _adapter);
      _adapter.invalidate();
    }

    public function set backgroundColor(backgroundColor : uint) : void {
      _backgroundColor = backgroundColor;
      _adapter.invalidate();
    }

    public function set borderColor(borderColor : uint) : void {
      _borderColor = borderColor;
      _adapter.invalidate();
    }
   
    public function init() : void {
      trace ("INIT", name);
      _backgroundColor = 0xCCCCCC;
    }

    public function validate() : void {
      trace ("VALIDATE", name);
     
      if (!_borderColor) _adapter.requestMeasurement();
      if (!_backgroundColor) _adapter.requestMeasurement();
     
      _adapter.scheduleUpdate();
    }

    public function measure() : void {
      trace ("MEASURE", name);
     
      _borderColor = 0x999999;
      _backgroundColor = 0xCCCCCC;
    }

    public function update() : void {
      trace ("UPDATE", name);
      drawBox();
    }
   
    private function drawBox() : void {
      with (graphics) {
        clear();
        lineStyle(1, _borderColor);
        beginFill(_backgroundColor);
        drawRect(0, 0, 100, 100);
      }
    }
  }
}

The adapter

The adapter delegates calls to its validation hooks to the appropriate component validation methods.

BoxAdapter.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package lifecycle.lifecycle.boxexample {
  import org.as3commons.ui.lifecycle.lifecycle.LifeCycleAdapter;

  public class BoxAdapter extends LifeCycleAdapter {
    override protected function onInit() : void {
      Box(displayObject).init();
    }
   
    override protected function onValidate() : void {
      Box(displayObject).validate();
    }

    override protected function onMeasure() : void {
      Box(displayObject).measure();
    }

    override protected function onUpdate() : void {
      Box(displayObject).update();
    }
  }
}

The example SWF

BoxLifeCycleExample.swf

As the console shows, although we have modified the boxes several times, before they were added to the stage or after that or even at both times, all life cycle methods were executed only onces per component.

INIT Box1
INIT Box2
INIT Box3
INIT Box4
VALIDATE Box1
VALIDATE Box2
VALIDATE Box3
VALIDATE Box4
CALCULATE_DEFAULTS Box1
RENDER Box1
RENDER Box2
RENDER Box3
RENDER Box4

VALIDATE Box1
VALIDATE Box2
VALIDATE Box3
VALIDATE Box4
RENDER Box1
RENDER Box2
RENDER Box3
RENDER Box4


117 Comments

  1. bFunc

    15. Juni 2011

    Could you explain a bit deeply cleaning up process when removing component from scene, please?

  2. Jens Struwe

    15. Juni 2011

    Here is a memory test app that might help: LifeCycle Memory Test

    Removing an object from the stage will not clean up life cycle references. You need to explicitely unregister the component from LifeCycle (the same way you have registered it).

    Unregistering a component will:
    - remove the component from the LifeCycle registry
    - remove the component from the update schedule (if contained)

    There are no more reference to the component that could be removed. See/profile the memory test and see what happens when you add to and remove items from LifeCycle.

    (There are some recent changes to the source code regarding performance and memory. Please checkout the most recent version.)

  3. bFunc

    15. Juni 2011

    tnx. Another thing – using LifeCycle with Layouts

    How can be VGroup.layout() method integrated into LifeCycle invalidation queue?

    * for now .layout() doesn’t work without setTimeout
    * for now .layout() cannot do addChild automatically

  4. Jens Struwe

    15. Juni 2011

    Version A) Store the layout in a display object property. Invalidate that display object. Call _layout.layout() when the object is to be validated.
    Version B) Create a fresh new layout whenever the display object that holds the children is to be validated. You may add all items of a container to a layout using myLayout.addAll(container).
    Version C) Feel free to contact me on Skype: kakenbok

  5. bFunc

    14. Dezember 2011

    Hi could you explain please what the right order of initializing nested components?

    The Error: “You cannot invalidate anything from within the render phase.
    The render phase is meant to update the display list according to ………”
    Drives me crazy.
    I have one component that creates huge amount of nested components inside, all components are linked to LifeCycle. What are limitations, what I can not do within ‘render phase’?

    Previous (0.3.2) version of LifeCycle works just perfect, does migrating to 0.3.4 is essential?

  6. Jens Struwe

    14. Dezember 2011

    You are right. This is a false restriction. I have an update that will correct this soon. For know, please remove (or override) the contents of LifeCycleI10NAdapter.onTestInvalidationAllowed().

  7. Benjamin4749

    29. November 2015
  8. marlonramm

    15. März 2016
  9. mattreymond007

    13. April 2016
  10. mellissamarchand

    4. Juni 2016
  11. raymonduvall4

    10. Juni 2016
  12. brodiezapata932

    15. Juni 2016
  13. rubytrott742

    30. Juni 2016
  14. imogenebej

    21. Juli 2016
  15. timmymcsharry98

    17. Oktober 2016
  16. jerroldcyr2

    18. Oktober 2016
  17. devonhollins79

    20. Oktober 2016
  18. jaquelinevasser

    29. Oktober 2016
  19. jonahmack1

    9. November 2016
  20. kelvineok1806803

    11. November 2016
  21. lacynickle21

    11. November 2016
  22. alisiaanthony

    11. November 2016
  23. dongstingley083

    19. November 2016
  24. coleforster

    2. Dezember 2016
  25. catherinefrisina

    3. Dezember 2016
  26. renateweinberg4

    4. Dezember 2016
  27. tomkincade33

    9. Dezember 2016
  28. frankfarrell7

    14. Dezember 2016
  29. hunterbaptiste9

    15. Dezember 2016
  30. lucileketner151

    22. Dezember 2016
  31. donnynobles87

    1. Januar 2017
  32. jxddelores

    3. Januar 2017
  33. alejandrina4143

    10. Januar 2017
  34. bettecady8

    10. Januar 2017
  35. benjaminrlh

    11. Januar 2017
  36. sadiewalsh

    11. Januar 2017
  37. numbersr90

    12. Januar 2017
  38. kiralpe5140

    13. Januar 2017
  39. sherrielevesque

    16. Januar 2017
  40. geribardon8

    18. Januar 2017
  41. gayqxf2657859

    18. Januar 2017
  42. jasonhaskell

    18. Januar 2017
  43. jerrellsilas4

    22. Januar 2017
  44. janinaparer66

    23. Januar 2017
  45. rowenaaddison9

    24. Januar 2017
  46. rodrosie25792

    24. Januar 2017
  47. jareddenovan

    24. Januar 2017
  48. franciscotritt

    24. Januar 2017
  49. stephanrockwell

    25. Januar 2017
  50. nanboyer63889

    25. Januar 2017
  51. clariceconnah

    25. Januar 2017
  52. anitastoddard3

    25. Januar 2017
  53. bryceo82944

    25. Januar 2017
  54. ljctanesha

    25. Januar 2017
  55. denisrow938696

    25. Januar 2017
  56. mikeanna02572

    26. Januar 2017
  57. amy8280300865191

    26. Januar 2017
  58. dawnandersen655

    26. Januar 2017
  59. lorribruner9

    26. Januar 2017
  60. mireyahibbins4

    26. Januar 2017
  61. magdalenabingham

    29. Januar 2017
  62. ulrikedigby2

    8. Februar 2017
  63. jenniferfornacho

    15. Februar 2017
  64. marisagranata2

    22. Februar 2017
  65. rosella76z

    24. Februar 2017
  66. phmpasquale

    26. Februar 2017
  67. alinataverner15

    27. Februar 2017
  68. lauriearreguin8

    1. März 2017
  69. yvonnevandevelde

    4. März 2017
  70. lantaverner585

    6. März 2017
  71. raymundorodarte

    7. März 2017
  72. samlindquist8

    25. März 2017
  73. lateshahulett8

    27. März 2017
  74. wendellfields3

    29. März 2017
  75. deb44r9483439

    29. März 2017
  76. kathibellew471

    14. April 2017
  77. jeffersonsikes0

    15. April 2017
  78. belen43z9009

    15. April 2017
  79. celiablodgett64

    15. April 2017
  80. kandismullagh

    15. April 2017
  81. florencequeale

    15. April 2017
  82. jaxonzsj97691

    15. April 2017
  83. leilaniv78

    15. April 2017
  84. aundreagainer36

    15. April 2017
  85. rondavillegas96

    15. April 2017
  86. mitchboothman8

    15. April 2017
  87. wanda15971824

    15. April 2017
  88. dannyschrantz

    16. April 2017
  89. marshallhanigan

    16. April 2017
  90. tiffaniw54

    16. April 2017
  91. sonyacrummer355

    16. April 2017
  92. latishastead17

    16. April 2017
  93. sallieharris001

    16. April 2017
  94. adrianneblanks

    16. April 2017
  95. flossie13b

    16. April 2017
  96. lavondafossett5

    16. April 2017
  97. florenehelena6

    16. April 2017
  98. pearlenesleeman

    16. April 2017
  99. imogenemccombs

    16. April 2017
  100. maximo6540

    16. April 2017
  101. randalwroe32

    17. April 2017
  102. arnettetherrien

    17. April 2017
  103. brigette5611

    10. Mai 2017
  104. davidadeffell6

    21. Mai 2017
  105. pennylovett

    1. Juni 2017
  106. ulysses11j

    6. Juni 2017
  107. artmacaluso77

    8. Juni 2017
  108. eileen9800

    8. Juni 2017
  109. cooperflick17

    10. Juni 2017
  110. moisestall8

    13. Juni 2017
  111. alexandriamaye

    13. Juni 2017
  112. leticiaposey69

    19. Juni 2017
  113. efrainchadwick2

    25. Juni 2017
  114. revasalamanca8

    10. Juli 2017
  115. nicholasmccloske

    13. Juli 2017
  116. haroldgraebner8

    20. Juli 2017
  117. robby43442

    18. August 2017

Leave a Comment

You have a question or have experienced an issue? Please post it in the forum: http://sibirjak.tenderapp.com/ in order to make the discussion available at a more central place.