Copy link to clipboard
Copied
This question was posted in response to the following article: http://help.adobe.com/en_US/as3/mobile/WS948100b6829bd5a6-19cd3c2412513c24bce-8000.html
1 Correct answer
yes, you can use pooling with any object and advantageously use pooling with any object that's used more than once.

Copy link to clipboard
Copied
Very interesting, although this class only deals with Sprites, how can I make it so that the pool can accept any type of object?
Copy link to clipboard
Copied
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);
}
}
Copy link to clipboard
Copied
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 .
Copy link to clipboard
Copied
using pooling with starling is no different than using pooling without starline. the code i suggested needs no change except to use the class instances and names that you want to pool.
Copy link to clipboard
Copied
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)?
Copy link to clipboard
Copied
yes, you can use pooling with any object and advantageously use pooling with any object that's used more than once.
Copy link to clipboard
Copied
Okay then I think I have to inject the ScreenNavigatorItem class of feathers UI.
Is there anyone out there who did this before?
Copy link to clipboard
Copied
Unfortuantely this seems not to work with a complete screen object. I tried to "remember" a DisplayObjet and then push it back:
public var memScreenInstanceList:DisplayObject;
I did it very simple without all the sophisticated incremantal stuff (for testing). The "cached" version of the screen/DisplayObject has lost design parts and lost eventlisteners. I tried it hardcoded in "feathers.controls.ScreenNavigatorItem.as".
Any suggestions here?
Copy link to clipboard
Copied
copy and paste your problematic pool class code.

Copy link to clipboard
Copied
Thanks kglad!
Copy link to clipboard
Copied
you're welcome.

