How to take the new start of table in the same position as the previous and only randomize the newObjec

So I'm trying to do 5 boxes/ships (3Blue and 2 Greens) appear in a random position (1-Gree, 2nd - blue, blue-3rd, 4th-green, green-5 or some other random way) I have the corner of the stage. Bring down. Make a new 5 boxes and position them on the same position the previous 5 and only get randomized (not with the 5 previous, it does at the moment). And that then they move down.  so far code I have is:

import flash.events.Event;

var shipCount:Number;

var shipCount2:Number;

var shipArray:Array = new Array();

var shipArrayPosition:Array = new Array();

var count: int = 0

var positionsX:Array = ["50" "100", "150", "200", "250"]

addEventListener (Event.ENTER_FRAME, everyFrame)

function everyFrame(ev:Event):void {}

counter ++

If (counter % 70 == 0) {}

doShips()

}

positionShips()

trace (shipArray.length)

}

function doShips() {}

shipCount = 3;

shipCount2 = 2;

var distance = 10;

for (var i: int = 0; i < shipCount; i ++) {}

var s = new ship;

shipArray.push (s);

s.x = s.width/2 + (s.width* i) + gap * I

addChild (s)

shipArrayPosition.push (s);

}

for (var j: int = 0; j < shipCount2; j ++) {}

s = new Ship2.

shipArray.push (s);

}

var array: Array = new Array();

While (shipArray.length > 0) {}

var: index: uint = Math.floor (Math.random () * shipArray.length);

Array.push (shipArray [index]);

shipArray.splice (index 1);

}

shipArray = array;

shipsArray has been randomized

for (var k: int = shipArray.length - 1; k > = 0; k-) {}

shipArray [k] .x = positionsX [k]

addChild (shipArray [k])

}

}

function positionShips() {}

for (var i: int = shipArray.length - 1; i > = 0; i--) {}

shipArray [i] .moveDown (//what) code in the class of the ship and Ship2-> only: this.y += 3

}

}

and how to stay in one position. Must not move in any position x when the 5 new are added

It is even more effective, because it removes the ships that moved out of sight:

import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;

var numShips:int = 5;
var shipCount:int = 3;
var shipArray:Vector. = new Vector.();
var counter:int = 0
var positionsX:Array = [];

init();

function init():void
{
          // populate positions
          for (var i:int = numShips - 1; i >= 0; i--)
                    positionsX.push(50 * i);

          addEventListener(Event.ENTER_FRAME, everyFrame);
}

function everyFrame(e:Event):void
{
          counter++
          if (counter % 70 == 0)
                    doShips();
          positionShips();
          trace(shipArray.length);
}

function doShips():void
{
          var gap = 10;
          var s:MovieClip;
          var shipsLine:Sprite = new Sprite();
          shipsLine.cacheAsBitmap = true;
          addChild(shipsLine);
          shipArray.push(shipsLine);
          shuffle(positionsX);
          for (var i:int = numShips - 1; i >= 0; i--)
          {
                    s = i < shipCount ? new Ship() : new Ship2();
                    s.x = positionsX[i] + gap;
                    shipsLine.addChild(s);
          }
          shipsLine.y = -shipsLine.height;
}

function shuffle(a:Array):void
{
          for (var i:int = a.length - 1; i >= 0; i--)
          {
                    var r:int = Math.floor(Math.random() * (i + 1));
                    var t:Object = a[r];
                    a[r] = a[i];
                    a[i] = t;
          }
}

function positionShips():void
{
          for each (var shipLine:Sprite in shipArray)
          {
                    shipLine.y += 3;
                    // remove line that moved out of stage
                    if (shipLine.y > stage.stageHeight + shipLine.height)
                    {
                              removeChild(shipLine);
                              shipArray.splice(shipArray.indexOf(shipLine), 1);
                    }
          }
}

Tags: Adobe Animate

Similar Questions

  • How to take the last 7 digits of a varchar column

    How to take the last 7 digits of a varchar2 colum

    COL1

    12345678

    12345

    1234567890123

    1234567

    Out put should be as below

    COL1

    2345678

    12345

    7890123

    1234567

    everything built in function or in any other way please

    Hello

    assuming that the entry contains only numbers, as in the example, the addition of 7 spaces to the left and selecting the 7 last characters toured:

    with dataset as

    (select col1 from column_value

    table

    (dbmsoutput_linesarray

    ("12345678"

    '12345 '.

    '1234567890123'

    "1234567".

    )

    )

    )

    Select col1

    , substr (lpad (", 7,' ') | col1-7) col1_last7

    of the dataset

    /

    COL1 COL1_LAST7

    -------------------- --------------------

    12345678 2345678

    12345 12345

    1234567890123 7890123

    1234567 1234567

    Rob

  • How to take the laboratory test, possible?

    I'm not able to study for vmware.

    I did the course, but the company has not set environment for me and work.

    How to take the laboratory test, possible?

    I need a help from you.

    Thank you

    ________________________________

    Thiago Rodrigues | Network management

    Associate. [email protected]

    Mobile: (011) 6122-0994

    www.DIGISYSTEM.com.br

    Engine certified Manager

    Certified Itil v2 Foundation

    ________________________________

    My VCP410 exam, it is not easy to take the exam without laboratory. Try to get a lab by installing a copy of assessment on VMware Play or work station. I hope this helps.

    Tim

    VCP on vSphere 4

  • How to take the count (*) corresponding to each table in a schema

    Hi all

    could someone please tell me, how can I take the count (*) for all the tables in a schema with the name of the corresponding table.
    I want to choose the table table_name from user_tables and number of rows in the table.

    Thank you
    Afonso

    Try the following script which should run as the owner of the schema:

    SET SERVEROUTPUT ON
    DECLARE
      t VARCHAR2(30);
      stmt varchar2(100);
      cnt number;
    BEGIN
      FOR t IN
      (SELECT table_name FROM user_tables)
      LOOP
        stmt :='select count(*) from ' || t.table_name;
       execute immediate stmt into cnt ;
       dbms_output.put_line(t.table_name || ': ' || cnt || ' rows');
       commit;
      END LOOP;
    END;
    /
    show errors
    
  • How to take the second row under the first line

    Dear Sir

    take my table like that name stock and times

    STOCK Header 2 Header 3
    A20301:3002:00
    A20302:4003:00
    A20303:0204:00
    A20305:0006:00

    the cry of output be like below

    STOCK 1 2 3
    A20300:4000:0201:00

    1 column is

    02:40 - 02:00

    column 2 is

    03:02-03:00

    column 3 is

    05:00 - 04:00

    Kind regards

    Hello

    You can use the analytical function of LEAD (or GAL) to get the difference between hours.

    For the results in the form of 3 columns in 1 line (rather than 1 column on 3 rows) calculates the LEAD in a subquery.  In the same auxiliary request, you can use the function ROW_NUMBER analytic number lines 1, 2 and 3.  The main query then use this value to rotate out of the subquery.

    Depending on your data, your needs and your version of Oracle, it will be something like this:

    WITH got_analytics AS

    (

    SELECT stock

    LEAD (header_2) (PARTITION OF BOUILLON

    ORDER BY header_2

    ) - header_3 AS time_diff

    ROW_NUMBER () (PARTITION OF BROTH

    ORDER BY header_2

    ) AS r_num

    FROM my_table

    )

    SELECT *.

    OF got_analytics

    PIVOT (MIN (time_diff)

    FOR r_num (1, 2, 3)

    )

    ;

    I hope that answers your question.

    If this isn't the case, please post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these data.

    Explain, using specific examples, how you get these results from these data.

    Make sure that your sample data reflect important aspects of your actual data.  For example, in your actual data, you have probably different values in the column actions. Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002#9362002

  • How to take the photo and prepare it in photoshop to bring it to the animation of the character?

    Hello

    I want to take a picture of a Denis and do animation

    How to prepare the image that it will work well in the new CHARACTER ANIMATION software?

    Thank you!

    Pictures tend to look scary when driven by HP, because of the "uncanny valley" effect But if you're brave, here's the general idea:

    (1) open the photo in photoshop, put on another layer

    (2) select the right eye, cut it into a new layer, name it + right eye

    (3) turn the eyeball to this new layer that you can see the underlying face

    (3) command-clicking the icon of the right eye to make the selection of the shape of the eye

    (4) select the face layer and shift + delete to remove the eye, choosing Content-Aware Fill to get skin to fill in where the eye was

    Repeat for each part of the body you want individual control on (see the puppet of model by file > new puppet in Photoshop for all names special to use for the auto-rigging)

  • How to take the configuration to the top of Vcenter server

    Hello

    I intend to build a new server Vcenter 5.0.

    In fact, we have Vcenter server 4.0. I need take Vcenter 4.0 and upload configuration in Vcenter 5.0.

    How to do this? Could you please give the steps how to do and what precautions we need to take.

    Welcome to the community - your vCenetr environment configuration is stored in the vCenter database - save and you will be together - in the guide of upgrade you are given instructions on how to tuse, the migration tool of data to move the databases during upgrade vCenter - http://pubs.vmware.com/vsphere-50/topic/com.vmware.ICbase/PDF/vsphere-esxi-vcenter-server-50-upgrade-guide.pdf

  • How to 'take' the background of a video?

    I would therefore like to take the background of a video and put it in another video. The thing is that I have people who are moving in the video I want to take the background... I am new in after effects so take easy on me and sorry for my bad English.

    See this page for an overview of compositing features do the kind of work you describe:

    Using After Effects | Resources and overview compositing and transparency

    Start here learn After Effects:

    http://Adobe.LY/AE_basics

  • How to take the output of Webservices

    Hi all

    I'm new on JUST I want to know how we're going to take the response of webservices in variable flow to RL fo there is little more easily in the 7 X workflow, but I am facing problem here

    ENTRY:

    option of WebServices (literal value) I enter the WSDL url and calling the funtion there and in demand, I've been taking the value of the flow through var

    and passing to webservice

    < tem:EmployeeLogin > {$ process_data/@company_code} < / tem:EmployeeLogin >


    and iam test there I have put it in xml format

    How will I receive the make variable where I need to go again to the form

    Please help me...

    Set a variable (say ditto) XML web service result.

    Now you can access your name like/process_data/myResult/Envelope/Body/ALL_GetEmpNamefrmIDResponse/ALL_GetEmpNamefrmIDResult

    Seems clear?

    Nith

  • How to take the database waiting for return in redo apply a State of

    Hello

    I have 2 questions on physical standby

    1. I have cancel the roll forward apply on a database of Eve, opened in read-only mode to querry. And how I could do to take the day before to redo apply a State as before? A command that will help me?

    2. in what cases to the primary database redo log is transported to the backup database
    -primary: validation
    -primary: checkpoint
    -primary: Journal of switch


    So thank you

    http://download.Oracle.com/docs/CD/B28359_01/server.111/b28294/protection.htm

    Since you move only protection max max availability all you need is to run:

    SQL > ALTER DATABASE DATABASE SET STANDBY TO MAXIMIZE AVAILABILITY.

  • How to take the sum of a cluster

    Hey Im trying to convert a matlab code in labview and I came across this issue with clusters. can anyone help?

    Let's say that:

    [Pxx, w] is periodogram (mydata, [], [], var]

    Time = Sum(mydata.^2) /length (mydata)

    FREQ = Sum (Pxx)

    Pxx = Pxx * time/frequency

    Pxx = sqrt (Pxx)

    LogLog (w, Pxx)

    I managed to make the PSD of mydata and translate code time labview...

    But how to make the sum of the Pxx which is clearly going to be a cluster of 3 elements (magnitude, df, f0)... Help?

    My point exactly! I therefore decided to unbundle the Psd with the sum of the elements of the array size. He then rebundle with f. and don't know if it will work DT...

  • Custom error Page how AAU take the return URL

    Hi all

    I create a custom error page and I was wondering is there a way to take
    the URL to which the error.

    Example:

    While watching http://my_site.com/sectionA/
    you follow the link to http://my_site.com/sectionB/
    Unfortunately http://my_site.com/sectionB/ does not exist
    and you are redirected to my page http://my_site.com/errorPage/ error

    Is it possible when I'm on http://my_site.com/errorPage/ to know that
    It was who raises the error http://my_site.com/sectionB/

    Thanks in advance,
    Fr. Ilian Iliev

    Is - this site studio?

    Go to the url that was bad, redirected to your section of custom errors, and then in the url, add? IsJava = 1, and then press ENTER. This returns the data that is located behind the page.

    One of the variables I see is called originalSiteRelativeUrl and it seems to contain information you're looking for.

    Give that a try and let us know!

  • How to take the new line

    Is there any character to the newline.

    as '\n' in java.

    guide me.

    Hello

    I tried a sample and it works...

    StringBuffer sb = new StringBuffer ("Hello");
    for (int i = 0; i)<>
    {
    SB. Append ('\n');
    SB. Append ("Hello");

    }

    TxtFld TextField = new TextField();
    txtFld.setText (sb.toString ());
    Add (txtFld);

  • How to take the printer ink cartridges OfficeJet 6700 cart

    I have a printer of HP all-in-one OfficeJet 6700.  When I inserted a new cartridge, there was a false message that says the cartridge was exhausted and cannot print. I tried 3 times with 3 new cartridges with the same result, so I called HP Support. They sent me another printer parts and missing parts had to come from my old printer.  I need to remove the old printer ink cartridges carriage and install it in the HP an Envoy.  I can't seem to understand and am afraid to break if I push or pull to hard.  Does anyone know how to do this?

    HP technicians two first talked on the phone told me there was a lock on the side to get (that I never found).  The third stopped in the middle of our conversation, he looked up and said that HP 6700 printer ink cartridges carriage is not removable.  Thanks for your advice and I hope that this information might help someone else. - Paw - Paw

  • How to take the attributes separately circle

    Hi all

    I need to consolidate the attributes (such as RADIUS, Centre, Center XY) function IMAQ circles detect circles. For example, all positions must be grouped in an array. I couldn't separate them.

    I tried a few things to do. I add my last essay as an attachment. Because I am new to Labview is not a good way. If it is not a good way to do this task, I'd be happy to hear the different methods or modifying the VI would be appreciated

    omersevinc wrote:

    Hi all

    I need to consolidate the attributes (such as RADIUS, Centre, Center XY) function IMAQ circles detect circles. For example, all positions must be grouped in an array. I couldn't separate them.

    I tried a few things to do. I add my last essay as an attachment. Because I am new to Labview is not a good way. If it is not a good way to do this task, I'd be happy to hear the different methods or modifying the VI would be appreciated

    The vi circle IMAQ detect returns an array of clusters. Each cluster contains a cluster of position x and Y information (float single precision), RADIUS (double precision float) and score (double precision float). You can separate these first, getting a single element of the array. In the excerpt below, I use a tunnel indexed in a loop to do this. Then use the Unbundle based on the name to separate the three elements of the cluster. You will need to reuse the Unbundle based on the name out of X and Y from the pole Position. Then just run all the values out of the loop with a tunnel indexed For you. Hope this is what you are looking for.

    Kind regards

Maybe you are looking for

  • Vista 7! ???

    I'm furious!  I bought this POS Dell Studio 1 3 days and spent my whole life trying to get to work right!  It came, of course with Vista...'nuf said.  I've upgraded to 7 and have had nothing else problems since.  I, now, have lost every photo and vid

  • How to install xp after installation disc and erased hard disk is not available?

    My windows xp system was not working, I erased the hard drive! Now I have a computer that does not work!

  • Side Winder will not work with Flight Simulator.

    Original title: Side Winder I installed the ms sidewinder joystick on my win 7 OS sucessfully and it worked fine with a free download of ms Flight. But when I installed ms Flight Simulator 2000. It wouldn't work wih this program. How is it?

  • ASA + no local lan access

    Hi all I have an ASA 5510 configured, when I try to connect to my asa fom the VPN client I can connect but can not reach my internal network. I have attached the running configuration, if anyone has an idea please let know me. Thank you

  • How to copy Internet favorites on a Windows 8?

    When moving to new computers, that I always copied my favorite Internet shortcuts to the Favorites folder. How can I do this in Windows 8?