Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.


Results 1 to 8 of 8

Thread: Starfield is in front - urgent

  1. #1

    Starfield is in front - urgent


    Could u please help me?
    My starfiels is in front of everything.
    What i need to change so that it is behin everything.

    please help

    Attached Files Attached Files

  2. #2
    ok i dont have flash on this computer but my first question is are you using any actionscript depths on the stars and just leaving the rest?

  3. #3
    Change the depth of the starfield.

  4. #4
    you need to put your stars in a movieclip and then swapDepths of everything else to be above it

    I don't really use deplicateMovieClip so the easy way was not quite working

    but i think the following should do it or point you in the right direction

    _root.hp = 100;
    var stars = 150;
    var maxSpeed = 16;
    var minSpeed = 2
    //create and position stars
    for (var i = 0; i<stars; i++) {
     var mc = holder.attachMovie("star", "star"+i, i);
     mc._x = random(Stage.width);
     mc._y = random(Stage.height);
     mc.speed = random(maxSpeed-minSpeed)+minSpeed;
     var size = random(2)+0.6*(random(4));
     mc._width = size;
     mc._height = size;
    holder.onEnterFrame = function() {
     for (var j = 0; j<stars; j++) {
      var mc = this["star"+j];
      if (mc._x>0) {
       mc._x -= mc.speed;
      } else {
       mc._x = Stage.height;
       mc.speed = random(maxSpeed-minSpeed)+minSpeed;
       mc._x = random(Stage.width);
     if (paused == false) {
      _root.pause._visible = false;
     } else {
      _root.pause._visible = true;
    var numEnemy = 3;
    _root.score = 0;
    var fire = false;
    //attach pause
    //make pause invisible
    _root.pause._visible = false;
    //make pause variable
    var paused = false;
    //sound variables
    var sound_on=true;
    //get sounds
    var laser=new Sound();
    var explode=new Sound();
    var music=new Sound();
    //define a listener
    var listener = new Object();
    listener.onKeyUp = function() {
     var code = Key.getCode();
     if (code == 80) {
      if (paused == false) {
       paused = true;
      } else {
       paused = false;
    //add shooting sound
    var shoot=new Sound();
    //add explosion sound
    var explode=new Sound();
    function moveHero(speed) {
     //check if key is down
     if (Key.isDown(Key.UP)) {
      _root.hero._y -= speed;
     } if (Key.isDown(Key.LEFT)) {
      _root.hero._x -= speed;
     } if (Key.isDown(Key.DOWN)) {
      _root.hero._y += speed;
     } if (Key.isDown(Key.RIGHT)) {
      _root.hero._x += speed;
     if (Key.isDown(Key.SPACE)) {
      if (fire == false) {
    var i = 1;
    function fireBullets() {
     if (i==10){
     fire = true;
     //start sound
     //name bullets
     var newname = "bullet"+i;
     _root.attachMovie("bullet", newname, i*100);
     _root[newname]._y = _root.hero._y+13;
     _root[newname]._x = _root.hero._x+55;
     _root[newname].onEnterFrame = function() {
      if (paused == false) {
       var bullet_speed = 9;
       this._x += bullet_speed;
       if (this._x>555) {
       for (var h = 1; h<=numEnemy; h++) {
        if (this.hitTest(_root["enemy"+h])) {
         //play explode
    function Enemys() {
     for (j=2; j<=numEnemy; j++) {
      var name = "enemy"+j;
      _root.enemy1.duplicateMovieClip(name, j+10);
    music.onSoundComplete = function() {

  5. #5
    I think he could just make the depth a very high number and it would work.

    starfield._depth = 1000000;
    Not entirely sure though.

  6. #6
    im havnt really worked to much with action script depth but if im not mistaken i believe that if you put a depth on an object in action script and the rest is left alone it will put the actionscript element in front of anything that uses a lower depth such as the basic stage depth.

  7. #7
    Depths in AS2 can cause alot of head aches my advice is search around on Google for a depth managing class for as2, to help you manage the depths of display objects.

  8. #8
    Quote Originally Posted by zerdec View Post

    Could u please help me?
    My starfiels is in front of everything.
    What i need to change so that it is behin everything.

    please help

    Oh damn you made a new thread for this. Neways i posted a solution on your previous thread. Here go check it out.


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Home About kirupa.com Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012