How to make the new Array start at the same position as the previous and randomise only the newObjec

So i am currently trying to make 5 boxes/ships (3Blue and 2 Green)appear  in a random position(1st-Gree,2nd- Blue,3rd-blue,4th-Green,5th-Green or in some other random way) i the upper corner of the stage.Make them move down.Then make a new 5 boxes and position them in the same starting position as the previous 5 and make only them get randomised (not with the previous 5,what it is doing at the moment).And do this while they are moving down.  so the code so far i have is this :
import flash.events.Event;
var shipCount:Number;
var shipCount2:Number;
var shipArray:Array = new Array();
var shipArrayPosition:Array = new Array();
var counter: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 gap = 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 the code in the Ship and Ship2 class does -> only: this.y += 3
and how to make them stay at one position.Not to move in any X position when the new 5 are added

This one is more efficient yet because it removes ships that moved out of view:
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
var numShips:int = 5;
var shipCount:int = 3;
var shipArray:Vector.<Sprite> = new Vector.<Sprite>();
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);

Similar Messages

  • When I restart my computer and hold the option key after creating a bootable usb with windows 7 and partitioning only the original partition shows up. Not the windows one or the bootable usb.

         Okay so first things first this isn't the newest macbook pro. When I open about my mac and go to system report it says it is a Macbook Pro 3,1 and the Boot Rom Version say MBP31.0070.B07. Originally when starting up Boot Camp Assistant there where only two options, the "create windows 7 bootable usb" was not there at all. So after some editing and helpful tutorials I was able to get the option show up and created a bootable usb with windows 7 and downloaded the support software onto a separate flash drive. Finally I did the last step and created a second partition for windows. Once the process is complete my computer automatically restarts.
         This is where the problem is. Once my computer makes the booting up sound it doesn't load up windows it gets stuck on a apple logo as if it's trying to reastart normally and can't. So I shut down and this time I hold down the option key during start up. It brings up the main partition and some recovery thing but no windows partiton and no bootable usb.
         I forgot to mention that I am running OS X 10.9.3. Okay any body want to help me out? Iv'e been at this for hours and can't get an inch closer to having windows. Please and thank you!
    P.S. If I missed a discussion that answer my question just point me to it. Iv'e been looking for a while, but who knows i might have missed one.

    The only known way to make it work on an external drive is by first installing Windows onto an internal drive, then cloning the install to an external Thunderbolt drive. Thunderbolt is seen as an extension of the internal bus, so Windows doesn't see it as an external device.

  • In ios 6 I could choose an artist on the music app and see all his albums in a list. Now, with ios 7, it shows all the songs from every album, making it EXTREMELY hard to see all the albums. Is there a way to minimize this view and see only the albums?

    Hello!
    I need some help with the music app in ios 7...
    In ios 6, I could choose an artist from the "srtists" view and it would show me all his albums as a list. Now, in ios 7, when I choose an artist, it shows me every song underneath every album, making it impossible to see al the albums at once! Is there anyway to minimize this view so I could see only the albums' titles as a list?
    It is VERY annoying. I would very much appreciate any help on this! 
    Thank you

    Exactly!
    This is all about the experience and accessibility. I don't even mind if the new desing is beautiful or not, but if I find myself, like you, avoiding looking for my music, my experience becomes frustrating. I have about 35 albums of a single artist and I used to love going over them and choose the right thing for me, especially being on the road a lot, and now I have to think twice about even entering his name.
    I really hope Apple will take those kind of things into consideration when they issue updates for ios 7, and maybe also give us back the goole search which was embeded into the spotlight search (which is really not that big of a request).
    And for your 4s - get the new iphone, it's MUCH better

  • HT4623 i done the new iphone update on my iphone 4 - it has crashed and now has the apple logo on. please help

    I done the update, it then said to plug into itunes - once i plug it in it crashed and now just has the apple logo on. it wont load switch on or off. Please help!!

    Restart computer. Open iTunes on computer. Connect iPhone to computer with USB Cable. Hold both home and power buttons until iTunes recognizes iPhone in Recovery Mode. This usually takes about 20 seconds of holding both buttons. Click the Restore button of iTunes.

  • Copy array and sort the numbers in the new array

    Hi!
    I have an array containing some digits where some of the digits are zeros. I want to copy the digits to another array but the zeros (well, I actually want to copy the zeros as well but I want to have them in the end of the new array).
    I suppose I need an if-statement that checks if the old array contains any zeros and in that if-statement copy the content to the new array and put the zeros in the end.
    This is my code so far and I don�t know how to go on from here:
    int[] new_array = new int[array.length];
              for (int i = 0; i < array.length; i++)
                   if (array[i] > 0)
                        new_array[i] = array;
                        new_array = array;
                   System.out.print(new_array[i] + " ");

    Roxxor wrote:
    I think I know how to do it but only if I can catch the digits bigger than zero.
    My code below just checks if there are positive digits and if there are, the whole old array is copied to the new one.Yes. Don't do that, you can see it's wrong.
    So my problem is that I don�t know how to catch the digits bigger than zero and copy them. Is there any built in java keyword that catches signs, number etc?
    if (array>=0)
         new_array[i] = array[i];
         new_array = array;
    Yes, there is such a keyword. And you are already using it correctly in your code. You are already testing if the array entry is bigger than zero. Your only problem is, you don't know what to do when it is. But now you've been given two hints about what to do.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to make a new file folder on screen?

    How to make file folder on screen?
    How to make a new window in browser?

    me1965 wrote:
    How to make file folder on screen?
    How to make a new window in browser?
    Don't know what OS you have so this info is for ICS.
    To make a folder on screen, long press on one app and drag and drop it on top of another app.  You will kinda see both apps there now and when you touch it a folder will open up and you can choose one of the apps.  You will also now be given a chance to name the folder.
    To open a new window in the chrome browser, tap on the menu button (the 3 verticle dots in the upper right hand corner of the screen) and click "new tab"
    If you have a different OS, let us know and someone will post the answer to your questions.

  • A have a white screen how to make a new installation of my computer

    A have a white screen how to make a new installation of my computer

    More details would help...what have you done to get to a white screen?  Were you in the process of reinstalling Mac OS X?  Or something else?
    In general, to reinstall Mac OS X, restart the Mac and hold the Command and R keys.  From the Utilities drop down select Install Mac OS X and the system will download the installer.  You w I'll then follow the instructions to install.
    By the way, you posted in the iMac PPC forum, this belongs in Yosemite from what you show on your info line, I will ask for relocation.

  • How to make a "new photo to publish" be considered "published" without actually publishing it?

    how to make a "new photo to publish" be considered "published" without actually publishing it?
    I have some photos that are really just stubs that represent the other "real" photos to publish.
    I don't want to have to do a mock export/rendering of them just to make them appear published.
    Any ideas?
    Rob

    In one of my plugins I have a requirement to download and add photos from the remote server and populate the newly created published collection in Lightroom.  In this routine, I use the following code to add the images to a published collection using the method provided by Don above.
    [code]
    catalog:withWriteAccessDo('createcollection', function()
         newcollection = v:createPublishedCollection(h.title)
         newcollection:setRemoteId(h.id)
    end)
    catalog:withWriteAccessDo( 'NPGSetUpdates', function()
         newphoto = catalog:addPhoto(newpath)
         newcollection:addPhotoByRemoteId(newphoto,p.id,p.url,true)
    end)
    [/code]
    The biggest thing here is that adding a photo like this requires the code to reside within the withWriteAccessDo block.

  • HT4759 How to make a new icloud?

    How to make a new i cloud ??

    If you want to change to a new iCloud accout you'll have to delete the account, create a new account with the other ID, and migrate your data to the new account.
    Before deleting the account, if you have any photos in photo stream that are not in your camera roll or backed up somewhere else save these to your camera roll or you will lose them.  To do this, open the photo stream album in the thumbnail view, tap Edit, tap all the photos you want to save, tap Share, then tap Save to Camera Roll.
    Once this is done, go to Settings>iCloud, scroll to the bottom and tap Delete Account. When prompted about what to do with the iCloud data, be sure to select Keep On iPhone.  Next, set up a new iCloud account using a different Apple ID (if you don't have one, tap Get a Free Apple ID at the bottom).  Then turn iCloud data syncing for contacts, etc. back to On, and when prompted about merging with iCloud, choose Merge.  This will upload the data to the new account.

  • I bought the pack for students adobe creative cloud, already made the payment three days ago but when opening programs like photosop and illustrator puts the trial period has expired, how I can make them work?

    I bought the pack for students adobe creative cloud, already made the payment three days ago but when opening programs like photosop and illustrator puts the trial period has expired, how I can make them work?

    Hello Ibonedm,
    Sol 1. Please try sign out from Creative cloud Desktop App and quit it.
    1. Launch Creative Cloud application manager.
    2. Click the gear icon in the upper-right corner and select Preferences.
    3. In the Preferences menu, under General, click the Account tab.
    4. Click Sign Out from Creative Cloud.
    Then re-sign in and launch Photoshop CC 2014 and check.
    Sol 2. Check your Hosts file.
    Windows
    1. Choose Start > Run, type %systemroot% \system32\drivers\etc, and then press Enter.
    2. Locate Hosts file and move it to Desktop
    3. Right-click the hosts file and select Open. Select Notepad for the application to open the hosts file.
    4. Back up the hosts file: Choose File > Save As, save the file as hosts.backup, and then click OK.
    5. Search the hosts file for entries that reference activate.adobe.com (for example, 127.0.0.1 activate.adobe.com) and delete these entries.
    6. Save and close the file and move it back to Etc folder.
    Mac OS
    1. Log in as an administrator to edit the hosts file in Mac OS.
    2. In a Finder window, choose Go > Go To Folder.
    3. Type /etc.
    4. Select the hosts file and move it on Desktop  open it.
    5. Back up the hosts file: Choose File > Save As, save the file as hosts.backup, and then click OK.
    6. Search the hosts file for entries that reference activate.adobe.com (for example, 127.0.0.1 activate.adobe.com) and delete these entries.
    7. Move Hosts file back to etc folder
    8. Save and close the file.
    Then try launching Photoshop CC 2014 or Illustrator CC 2014
    If prompt for License this software, please click on it and sign in with the Adobe ID and Password which you have used to purchase the subscription and check if you can activate and use the products.
    Please respond , if any issue.
    All the best
    Loveneesh.

  • I've recently started to use Numbers but when I try to sync to iCloud it asks me to create a new iCloud account. Problem is I already have one and that's the one I want to use. Looks like I have the same situation on my iphone. Any guidance? Thanks.

    I've recently started to use Numbers on my macbook pro but when I try to sync to iCloud it asks me to create a new iCloud account. Problem is I already have one and that's the one I want to use.
    Looks like I have the same situation on my iphone.
    The only option I'm being given is to create an lCloud account.
    Any guidance? Thanks.

    The last thing you want is a second iCloud account. Try logging out and back in in System Preferences. If that doesn't work, I'd get AppleCare on the line.
    Jerry

  • I got the new iPhone5 back in Dec, I hooked it up to my computer for the 1st time this wk.  It deleted all new data added since Dec (notes,contacts,texts,pics, info in apps) and reverted back to all my old data.  How can I retrieve all the lost data??

    I got the new iPhone5 back in Dec, I hooked it up to my computer for the 1st time this wk.  It deleted all new data added since Dec (notes,contacts,texts,pics, info added to apps) and reverted back to all my old data (literally uploaded all of my old texts and 1400 old pics and deleted anything new).  How can I retrieve all the lost data?? Please help!!

    SkyDaughter29 wrote:
    My current situation: I have soooo many texts on my iphone and I haven't deleted many because I need the information contained in them for future reference and for legal purposes.  I would really like to find a means and way to save them other than on the phone itself. I've done searches for various apps yet I'm not finding what I think I would need.  It appears Apple does not sync the texts between the iphone and my MacBook Pro.
    Try the computer apps PhoneView (Mac) or TouchCopy (Mac & PC):
    http://www.ecamm.com/mac/phoneview/
    http://www.wideanglesoftware.com/touchcopy/index.php
    Best of luck.

  • I just bought a new Retina Display macbook pro, and I plugged in my iPod touch (4th gen) into the new computer, but it will not show up, even after I typed in the passcode. How do I get my iTouch to sync with my new computer without restoring my itouch?

    I just bought a new Retina Display macbook pro, and I plugged in my iPod touch (4th gen) into the new computer, but it will not show up, even after I typed in the passcode. How do I get my iTouch to sync with my new computer without restoring my itouch?

    iOS: Device not recognized in iTunes for Mac OS X

  • Ok, my former computer crashed and i have a new one. i would like to sync my ipod with the new one, but it wont allow me to with out removing all of the data on it. How can i fix this?

    ok, my former computer crashed and i have a new one. i would like to sync my ipod with the new one, but it wont allow me to with out removing all of the data on it. How can i fix this?

    See Recover your iTunes library from your iPod or iOS device.
    tt2

  • How do I eliminate the message when starting up PC - Apple Sync Notifier.exe – Entry Point Not Found – The procedure entry point sqlite3_wal_checkpoint could not be located in the dynamic link library SQLite3.dll.

    Getting the massage when starting up PC - Apple Sync Notifier.exe - Entry Point Not Found - The procedure entry point sqlite_wal_checkpoint could not be located in the dynamic link library SQLite3.dll.  How do I eliminate this message?

    I'd first try uninstalling and reinstalling your MobileMe control panel, dc. Does that clear the message up?

Maybe you are looking for