Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Object pooling

Explorer ,
Dec 11, 2012 Dec 11, 2012

This question was posted in response to the following article: http://help.adobe.com/en_US/as3/mobile/WS948100b6829bd5a6-19cd3c2412513c24bce-8000.html

TOPICS
ActionScript
1.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 25, 2012 Dec 25, 2012

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

Translate
Guest
Dec 11, 2012 Dec 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 11, 2012 Dec 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);

              }

       }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 25, 2012 Dec 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 .

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 25, 2012 Dec 25, 2012

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 25, 2012 Dec 25, 2012

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)?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 25, 2012 Dec 25, 2012

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 25, 2012 Dec 25, 2012

Okay then I think I have to inject the ScreenNavigatorItem class of feathers UI.

Is there anyone out there who did this before?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 25, 2012 Dec 25, 2012

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 26, 2012 Dec 26, 2012

copy and paste your problematic pool class code.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 05, 2013 Jan 05, 2013

Thanks kglad!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 05, 2013 Jan 05, 2013
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines