Skip to main content
This topic has been closed for replies.
Correct answer kglad

Is it possible to pool a complete ScreenNavigatorItem so it would result in a very cool page caching engine? What I have is:

var someDetails:ScreenNavigatorItem = new ScreenNavigatorItem(ItemDetails,,null);

this.nav.addScreen(PERSON_DETAILS,someDetails);

"someDetails" would have been pooled. This UI could have been completely reused (except the dynamic data parts)?


yes, you can use pooling with any object and advantageously use pooling with any object that's used more than once.

1 reply

December 11, 2012

Very interesting, although this class only deals with Sprites, how can I make it so that the pool can accept any type of object?

kglad
Community Expert
Community Expert
December 11, 2012

replace IntroView with any class name you want to pool:

public class IntroView_Pool {

              private static var pool:Vector.<IntroView>;

              public static function init(poolSize:int):void {

                     pool = new Vector.<IntroView>(poolSize);

                     for(var i:int=0;i<pool.length;i++){

                           pool = new IntroView();

                     }

              }

              public static function retrieveF():IntroView {

                     if (pool.length>0) {

                           return pool.pop();

                     } else {

                           // this branch should not execute. 

                           return new IntroView();

                     }

              }

              public static function returnF(view:IntroView):void {

                     pool.push(view);

              }

       }

Participant
December 25, 2012

Does somenone knows how this would work with Starling and

- import feathers.controls.Button;

- import feathers.controls.Header;

- import feathers.controls.Label;

- import feathers.controls.Screen;

- import feathers.controls.TextInput; ...on different Screens of ScreenNavigator? I tried it but got no result or error message .