How to give an element of ObjectPooled of the properties of a class

Currently, I'm trying to create an infinite effect of mobile Objects.The problem is when I change the var myNewBox:Box = new Box(); with

var myNewBox:Box = pool_Box.getSprite () as a box;. It seems that I can't use the properties in the class Box() and with my code doesn't do not what it was ment to do.

(getSprite() is the purpose of pooling of the class)

To be more precise box() is a simple MovieClip of a black square with a single prorertie public var passedCenter:Boolean = false; and ot based on this value, I create an object

So, the main class looks like this:

When I try to use the Objectpooling.

public function Main()
                    {
                              var item:Box = new Box();
                              item.x = stage.stageWidth + item.width;
                              item.y = 40;
                              addChild(item);
                              myArray.push(item);
                              myRandomEffectNumber = getNextRandomNum();// set the starting effect 
                              stage.addEventListener(Event.ENTER_FRAME, everyFrame);
                    }

private function everyFrame(ev:Event):void
                    {
                              for(var i:int = 0; i< myArray.length; i++)
                              {
                                        myBox = myArray[i];
                                        myBox.x -=3;

                                        if(myBox.x <= stage.stageWidth && !myBox.passedCenter)
                                        {
                                                  myBox.passedCenter = true;
                                                  var myNewBox:Box = pool_Box.getSprite() as Box;
                                                  myNewBox.x = stage.stageWidth + myNewBox.width + myNewBox.width * 0.5;

                                                  switch (myRandomEffectNumber)
                                                  {
                                                            case 1 :
                                                                      myNewBox.y = effect_1();
                                                                      break;
                                                            case 2 :
                                                                      myNewBox.x = stage.stageWidth + myNewBox.width + myNewBox.width * 0.25; // we cahnge the was number so we create faster the elements
                                                                      myNewBox.y = effect_2();
                                                                      break;
                                                            case 3 : 
                                                                      myNewBox.y = effect_3();
                                                                      break;
                                                            default :
                                                                      trace("SWITCH ERROR");
                                                                      break;
                                                  }


                                                  addChild(myNewBox);
                                                  myArray.push(myNewBox);
                                        }

                                        if(myBox.x < -50 )
                                        {
                                                  bulletsArray.splice(i, 1);
                                                  removeChild(b);
                                                  pool_Box.returnSprite(b);
                                        }
                              }

So what happends is that ! myBox.passedCenter never are they assigned to of myNewBox:Box = pool_Box.getSprite () as a box or at least, it acts like it.


but when a replacement = pool_Box.getSprite () myNewBox:Box area with siple var myNewBox:Box = new Box();


                  if(myBox.x < -50 )
                                        {
                                                  removeChild(myBox);
                                                  myArray.splice(i, 1);
                                        }

It works very well

If anyone can help?

When you return the boxes to the pool, you are resetting their values?

Tags: Adobe Animate

Similar Questions

  • How to give more relevance to one of the column in multi-column data store

    Hi gurus,

    When using multi-column datastore necessary to give more importance to one of the other column. How can we achieve the same?
    SQL > create table test_sh4 (text1, text2 clob clob);

    Table created.

    SQL > alter table test_sh4 Add (Text3 clob);

    Modified table.

    SQL > start
    2 ctx_ddl.create_preference ('nd_mcd', 'multi_column_datastore');
    3 ctx_ddl.set_attribute
    4 ("nd_mcd",
    5 "columns."
    6 ' replace (Text1, "", "") nd, Text1 text1, replace (Text1, "", "') nd, Text1 text1');
    7 ctx_ddl.set_attribute ('nd_mcd', 'separator', 'new line');
    8 ctx_ddl.create_preference ('test_lex1', 'basic_lexer');
    9 ctx_ddl.set_attribute ('test_lex1', 'spaces', ' /--------|-_ + "");
    10 end;
    11.

    PL/SQL procedure successfully completed.

    SQL > create index IX_test_sh4 on test_sh4 (Text3)
    indexType is ctxsys.context
    parameters
    ("nd_mcd of the data store
    lexer test_lex1')
    / 2 3 4 5 6

    Index created.
    Here, while querying how can I give more relevant for the text1 Text2 column as column?

    I gave an example below. I added some data to your example. You had tags and columns duplicated in your multi_column_datastore, so I fixed it those. I removed the newline delimiter and added a section with sections of field group and add this section to the index settings group. Allows you to search in each section of field and apply different fats. You can apply weights by multiplying by a value entre.1 and 10 or several times multiplier to reduce or increase the score for a particular section.

    SCOTT@orcl_11gR2> -- table structure you provided:
    SCOTT@orcl_11gR2> create table test_sh4 (text1 clob,text2 clob);
    
    Table created.
    
    SCOTT@orcl_11gR2> alter table test_sh4 add (text3 clob);
    
    Table altered.
    
    SCOTT@orcl_11gR2> -- added data:
    SCOTT@orcl_11gR2> insert all
      2  into test_sh4 (text1, text2, text3)
      3    values ('testword', 'word2', 'word3')
      4  into test_sh4 (text1, text2, text3)
      5    values ('word4', 'testword', 'word5')
      6  into test_sh4 (text1, text2, text3)
      7    values ('test word', 'word2', 'word3')
      8  into test_sh4 (text1, text2, text3)
      9    values ('word4', 'test word', 'word5')
     10  select * from dual
     11  /
    
    4 rows created.
    
    SCOTT@orcl_11gR2> -- fixed duplicate column names and tags and
    SCOTT@orcl_11gR2> -- removed newline delimiter and
    SCOTT@orcl_11gR2> -- added section group with field sections:
    SCOTT@orcl_11gR2> begin
      2    ctx_ddl.create_preference ('nd_mcd', 'multi_column_datastore');
      3    ctx_ddl.set_attribute
      4        ('nd_mcd',
      5         'columns',
      6         'replace (text1, '' '', '''') nd1,
      7          text1 text1,
      8          replace (text2, '' '', '''') nd2,
      9          text2 text2');
     10    ctx_ddl.create_preference ('test_lex1', 'basic_lexer');
     11    ctx_ddl.set_attribute ('test_lex1', 'whitespace', '/\|-_+');
     12    ctx_ddl.create_section_group ('test_sg', 'basic_section_group');
     13    ctx_ddl.add_field_section ('test_sg', 'text1', 'text1', true);
     14    ctx_ddl.add_field_section ('test_sg', 'nd1', 'nd1', true);
     15    ctx_ddl.add_field_section ('test_sg', 'text2', 'text2', true);
     16    ctx_ddl.add_field_section ('test_sg', 'nd2', 'nd2', true);
     17  end;
     18  /
    
    PL/SQL procedure successfully completed.
    
    SCOTT@orcl_11gR2> -- added section group to index:
    SCOTT@orcl_11gR2> create index IX_test_sh4 on test_sh4 (text3)
      2  indextype is ctxsys.context
      3  parameters
      4    ('datastore     nd_mcd
      5        lexer          test_lex1
      6        section group     test_sg')
      7  /
    
    Index created.
    
    SCOTT@orcl_11gR2> column text1 format a10
    SCOTT@orcl_11gR2> column text2 format a10
    SCOTT@orcl_11gR2> column text3 format a10
    SCOTT@orcl_11gR2> -- without weighting:
    SCOTT@orcl_11gR2> select score (1), t.* from test_sh4 t
      2  where  contains
      3             (t.text3,
      4              'testword',
      5              1) > 0
      6  /
    
      SCORE(1) TEXT1      TEXT2      TEXT3
    ---------- ---------- ---------- ----------
             6 testword   word2      word3
             6 word4      testword   word5
             3 test word  word2      word3
             3 word4      test word  word5
    
    4 rows selected.
    
    SCOTT@orcl_11gR2> -- with weighting:
    SCOTT@orcl_11gR2> select score (1), t.* from test_sh4 t
      2  where  contains
      3             (t.text3,
      4              '(testword within text1) * 10 or
      5            (testword within nd1)     *  5 or
      6            (testword within text2) * .5 or
      7            (testword within nd2)     * .1',
      8              1) > 0
      9  order  by score (1) desc
     10  /
    
      SCORE(1) TEXT1      TEXT2      TEXT3
    ---------- ---------- ---------- ----------
            48 testword   word2      word3
            20 test word  word2      word3
             2 word4      testword   word5
             1 word4      test word  word5
    
    4 rows selected.
    
  • How to activate my Windows 7 OS when the properties of the computer does not open?

    How to activate my windows operating system 7 and the properties of my computer is not open how to open that

    Original title: activate windows

    How to activate Windows 7 manually (activate by phone)
     
    1) click Start and in the search for box type: slui.exe 4
     
    (2) press the ENTER"" key.
     
    (3) select your "country" in the list.
     
    (4) choose the option "activate phone".
     
    (5) stay on the phone (do not select/press all options) and wait for a person to help you with the activation.
     
    (6) explain your problem clearly to the support person.
     
    http://support.Microsoft.com/kb/950929/en-us

  • How rea total no element is available in the block details

    I use Forms 10 G.
    I have a block of details, and it is a tabular format.
    I have 10 record in the block.

    I use this post for an insertion request not in the block of details...
    *: mySno: = get_block_property ('mydetail_block', CURRENT_RECORD); *

    How can I count the number of records are in the block of details?
    Declare
      i  pls_integer := get_block_property('mydetail_block',CURRENT_RECORD);
      max  pls_integer ;
    Begin
      go_block('mydetail_block');
      Last_Record ;
      max := get_block_property('mydetail_block',CURRENT_RECORD);
      message('max records: || max);
      Go_record( i ) ;
    End;
    

    François

  • How I can center element then which are the same across platforms

    I like a basic layout that work very well in a desktop or laptop without floats to the left in a smart phone.

    What can I do so that they are all centered.

    http://www.dankeithwilliams.com/Gregory/gregory_art1.html

    Any help is greatly appreciated, but is it possible please you as simple as possible. I'm more of a Visual that say a person of coding.

    Thanks in advance

    Because of the limit realestate available on smaller screens, I tend to use the full width of the screen for my basic page layout. This is why floating becomes an option out of place.

  • How can I make in bulk changes to the properties of the Page?

    I have a small site, only 26 pages and realized that I had forgotten to insert code of ligation and to change the legacy of character settings in the properties of the page for each of them.

    I would like to be able to change the properties of the page for all pages in a single action. I can open each page in a short time because my site is not that big. But what happens if I had 50 pages?

    Is it possible to apply changes to the page properties of multiple pages with a single action? Can there be?

    Thank you

    Hello Bull_Garlington,

    To change the settings for legacy of character on all pages you can make the necessary change in the attached master page, and then this parameter will also apply to other pages in the Appendix.

    Let me know if this helps.

    Kind regards

    Ankush

  • How to create a new sequence based on the properties of the images?

    I thought there was a way to have the first automatically creates a new sequence based on the properties of the images rather than having to manually choose the predefined sequence.

    For example, I cancelled out of dialog sequence preset and imported a video I want to change. Rather than manually choose a predefined sequence, I would like to say first to create the sequence for me by looking at metadata (resolution, fps, etc) and creating the correct order for that specific item.
    I have CS4; Was it a new feature introduced in CS5?
    Thank you!

    Yes.  It's new for CS5.

    -Jeff

  • How do the properties of the list of all sprites or the cast members?

    How can I create a list of all the properties of all of the sprites in a movie or all the properties of all members of the distribution of certain types?
    During development, this is for documentation purposes. The main objective is to properties such as size, position, policies and behavior attached (if 'all' is not really needed).

    Any suggestions are welcome.

    Arman

    on GetABigListOfSpriteProps
    start_frame = (the frame)

    big_list =]

    Repeat with n_frame = 1 to (the lastFrame)
    go n_frame

    Repeat with n_sprite = 1 to (lastChannel)
    If (sprite (n_sprite) game = 0) then
    next rehearsal
    end if

    If (sprite (n_sprite) .startFrame< n_frame="" )="">
    next rehearsal
    end if

    sprite_props = [:]
    sprite_props.addProp (#channel, n_sprite)
    sprite_props.addProp (#startFrame, sprite (n_sprite) .startFrame)
    sprite_props.addProp (#endFrame, sprite (n_sprite) .endFrame)
    sprite_props.addProp (#loc, .loc sprite (n_sprite))
    sprite_props.addProp (#rect, sprite (n_sprite) .rect)
    sprite_props.addProp (#width, sprite (n_sprite) .width)
    sprite_props.addProp (#height, sprite (n_sprite) .height)
    sprite_props.addProp (#member, sprite (n_sprite) .member)
    sprite_props.addProp (#name, sprite (n_sprite). member.name)
    sprite_props.addProp (#type, sprite (n_sprite). member.type)

    case (sprite (n_sprite). member.type) of

    #text, #field:
    sprite_props.addProp (#font, sprite (n_sprite). member.font)

    #bitmap:
    sprite_props.addProp (#depth, sprite (n_sprite). member.depth)

    cases of termination

    sprite_behaviours =]

    Repeat with n_behaviour = 1 to the sprite (n_sprite). scriptList.count
    sprite_behaviour = [:]
    sprite_behaviour.addProp (#member, sprite (n_sprite) .scriptList [n_behaviour] [1])
    sprite_behaviour.addProp (#name, sprite (n_sprite) .scriptList [n_behaviour] [1] .name)
    sprite_behaviour.addProp (#properties, value (sprite (n_sprite) .scriptList [n_behaviour] [2]))

    sprite_behaviours. Add (sprite_behaviour)
    end repeat

    sprite_props.addProp (#behaviours, sprite_behaviours)

    big_list. Add (sprite_props)

    end repeat

    end repeat

    go start_frame

    return big_list
    end

  • How to import in the video editor of first elements 13 clips with the tag structure or the person, location and the structure of the event organizer?

    How to import in the video editor of first elements 13 clips with the tag structure or the person, location and the structure of the event organizer?

    senior50

    On what computer operating system is your first items 13 running? And you have updated 13 to 13.1 still using Help Menu/implementation of an open project? If this isn't the case, please consider this.

    Now to your question immediately.

    I would consider placing your files for organizing items (person, place or event) in albums that you create in the organizer of items for each. Then,

    (a) the content of the album of the opening of the first elements add multimedia/Organizer.

    or

    (b) by selecting your album in the elements Organizer, select the photos in the album you want, then right click anywhere in a selection and Edit with Premiere elements editor selection?

    Have you been there and done that yet?

    Please examine, consider, give more details, and we can then decide what.

    Thank you.

    RTA

  • How to find an element ID (primary key)

    Hello

    How to find the ID of an element when you have the item already?

    For example, in my table of data, I have two columns - one for the primary key (ID), and the other matches the element.

    I can find an element with the given ID but not vice versa.

    Is there a way to find the ID of the item?

    Thank you. : D

    Okay, it's very basic and probably does not work in the real world for the reasons I have explained above, but for your example, you can use the following query:

    SELECT THE ID
    FROM someTable
    WHERE itemName = "hat".

    That would give you the ID, but it can return multiple rows of data if there are several elements called "hat" in the table.

    Who help me?

  • How to save a password changed in Firefox? I rescued him, but then I changed the password and it doesn't give me an option to save the new password. Help, please. Thank you!

    How to save a password changed in Firefox? I rescued him, but then I changed the password and it doesn't give me an option to save the new password. Help, please. Thank you!

    The Web site may use autocomplete = off to prevent Firefox to record the name and the password.

    You can remove autocomplete = off with a bookmarklet to register the name and the password of Firefox.

  • Siri will not stop me give a military even if time the "time of 24 hours' has been disabled in my settings.  How do I change AM/PM?

    Siri will not stop me give a military even if time the "time of 24 hours' has been disabled in my settings.  How do I change AM/PM?

    What you have for country & region and what default language.

  • How to give a default file path

    Hi all

    How to give a default path for a vi... It should take path to the deffault d without a prompt and writing the desired string to this place... I gud get default file path option... but later realized that there is no file created in this place

    Thank you

    Here you go...

    Sorry I made the error I said others...

    The VI attached is in LV 8.0 (so that only I could save)...

  • How to change an element from a 2D array?

    I have searched the forums for something similar, but couldn't find anything. My apologies if this seems trivial, but I'm not a specialist of LabVIEW and my project includes a large number of disciplines so sometimes when I'm working on LabVIEW related tasks now and then I need a refresher.

    Basically, I am changing - replaces not - one element in a 2D array. Thus, for example, if I have the 2D table:

    A

    1 2 3 4

    B

    1 2 3 4

    C

    1 2 3 4

    I'm dividing element 3 of 1000.

    I suspect that, like so many LabVIEW, it would be very easy for someone who already knows how do...

    Index of the item that you want to modify (using the table to index), make the change, right hand index to help replace array element.

    If you are concerned about performance, use the element in place.

    http://www.NI.com/white-paper/6211/en/

  • How to change the color of the elements of cluster using the reference

    Hello

    I have cluster with 10 LEDS, each LED represents a test within my program, based on success or failure, I want to change the color of each LED, I use the cluster as input reference to test subvi.

    Is there a method to change the color of the induvidual elements?

    Thanks in advance.

    Can be used with any wire Ref properties are determined by the class of the wire Ref itself.

    Generic refs are geneirc properties.

    The FTA to obtain the properties of the elements within the cluster, you will need to tell LV class is a cluster. The same for the items in the cluster.

    Please consider this nugget on the help of control references. Don't worry about understanding everytihing that I wrote in this nugget, since it was written to be entertaining at all levels. Find the section where I show

    How to cast Ref nums as of specific types.

    Ben

Maybe you are looking for