# Starfield

**URL:** <https://forum.kirupa.com/t/starfield/5347>\
**Category:** flash\
**Created:** [September 8, 2002, 5:50pm UTC](https://forum.kirupa.com/t/starfield/5347 "2002-09-08T17:50:33Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [September 8, 2002, 5:50pm UTC](https://forum.kirupa.com/t/starfield/5347/1 "2002-09-08T17:50:33Z")

</div>

Hi all,  
I’ve been trying to find some way to get a realistic starfield (where the stars seem to zoom by you) in Flash for some time. I have tried everything from tweens to simple AS. For some reason, my limited scripting knowledge prevents from creating a good enough effect that I see on sites such as [Robertpenner.com](http://Robertpenner.com). Is there a simpler way to accomplish that effect without having to use motion tweens?

Cheers!  
Kirupa ☹

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 8, 2002, 7:16pm UTC](https://forum.kirupa.com/t/starfield/5347/2 "2002-09-08T19:16:32Z")

</div>

Yeah, a much easier and simpler way.

You take about 1/2 (of an ounce) of weed, a large rolling paper, roll up a nice spliff, dip in honey, find a lighter and smoke it. Ensure windows and doors are shut also.

About half way through it you’ll find that you can accomplish pretty much anything you want, you’ll see the best graphics and effects ever on your screen, that you made!!

hope that helps!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 8, 2002, 8:36pm UTC](https://forum.kirupa.com/t/starfield/5347/3 "2002-09-08T20:36:02Z")

</div>

If you mean zoom by you - this may help, although may be a bit too fast - more of a warp effect.

Found it floating around on the net…

Also, I’ve written a tutorial for the games section. How do I get it to you. I used the template. I’ll have another look at the Tutorials forum - it was prob. obvious but I missed it.

Heres the fla

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 9, 2002, 7:35am UTC](https://forum.kirupa.com/t/starfield/5347/4 "2002-09-09T07:35:29Z")

</div>

> \*Originally posted by RageW0lf \*  
> \*\*Yeah, a much easier and simpler way.

You take about 1/2 (of an ounce) of weed, a large rolling paper, roll up a nice spliff, dip in honey, find a lighter and smoke it. Ensure windows and doors are shut also.

About half way through it you’ll find that you can accomplish pretty much anything you want, you’ll see the best graphics and effects ever on your screen, that you made!!

hope that helps! \*\*  
😛 That’s definitely advanced, RageWolf.

And Kir, why don’t you try the perspective tutorial? Could be exactly what you want…

pom :asian:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 9, 2002, 7:38am UTC](https://forum.kirupa.com/t/starfield/5347/5 "2002-09-09T07:38:47Z")

</div>

Wow, I’ve just checked Robert Penner’s movie, it’s wild… :x

pom :asian:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 9, 2002, 10:40am UTC](https://forum.kirupa.com/t/starfield/5347/6 "2002-09-09T10:40:53Z")

</div>

hrmmm i’ve had it up on my site all the time…but because u never looked at it! :’( u couldn’t know that…hehe just joking

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 9, 2002, 10:43am UTC](https://forum.kirupa.com/t/starfield/5347/7 "2002-09-09T10:43:05Z")

</div>

oh its in the experiments section at my site… [http://www.bezzanet.zzn.com](http://www.bezzanet.zzn.com)

Tell me if thats what your looking for…i think its called stars or something like that…🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 9, 2002, 9:35pm UTC](https://forum.kirupa.com/t/starfield/5347/8 "2002-09-09T21:35:46Z")

</div>

Thanks a lot for the replies. Flex that is pretty much exactly what I had been looking for. Thanks 🙂 Same to you bezza. Pom, your tutorial is what got me back on the zooming star thing. After reading your tutorial, I decided to give that effect one last shot.

Cheers!  
Kirupa :rambo:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2002, 9:20am UTC](https://forum.kirupa.com/t/starfield/5347/9 "2002-09-10T09:20:09Z")

</div>

Nice work guys!  
Flex \>\> Very cool effect.  
Bezzer \>\> What’s your method? Tweens or code? And strange thing: your stars appear quickly and then slow down, whereas it should be the opposite 🙂

Here’s something based on the perspective tutorial (the engine is not mine, it’s [Keith Peter’s](http://www.bit-101.com/lab.html). Make a large scene, a black background, and create a movie clip of a small dot with the linkage name “dot” and enter this cide (Flash MX):

```auto
/ *********************
 Variables definition
   - fl: focal length
   - zspeed: dot speed
********************* /
fl = 200;
zspeed = 40;

/ *********************
 _root enterFrame
   - creates a new dot
     every 150 ms
********************* /
onEnterFrame = function () {
	if (getTimer()-start>150) {
		start = getTimer();
		makeBox();
	}
};

/ *********************
 Functions definition
   - makeBox: creates a new dot
      . (x,y): absolute coordinates (before scaling)
   - boxMove: moves the box :)
      . check the perspective tutorial
********************* /
function makeBox() {
	box = attachMovie("dot", "dot"+(++i), i);
	box.num=i;
	box._x=100000;
	box.x = random(4000)-2000;
	box.y = random(3000)-1500;
	box.z = 2500;
	box.xspeed = Math.sin(xangle+=.2)*1;
	box.yspeed = Math.sin(yangle+=.5)*1;
	box.onEnterFrame = boxMove;
};
function boxMove() {
	this.z -= zspeed;
	this.x += (270-_xmouse)*.05;
	this.y += (200-_ymouse)*.05;
	this.x += this.xspeed;
	this.y += this.yspeed;
	this.scale = fl/(fl+this.z);
	this._x = this.x*this.scale+270;
	this._y = this.y*this.scale+200;
	this._xscale = this._yscale=this.scale*100;
	this._alpha = (2500-this.z)*.1;
	if (this.z<-fl/2) {
		removeMovieClip(this);
	}
};

```

Enjoy. 🙂

pom :asian:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2002, 4:22pm UTC](https://forum.kirupa.com/t/starfield/5347/10 "2002-09-10T16:22:53Z")

</div>

Wow, that is pretty amazing. So simple, yet so complex.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2002, 5:26pm UTC](https://forum.kirupa.com/t/starfield/5347/11 "2002-09-10T17:26:00Z")

</div>

… and so CPU consuming, unfortunately. But hey, you can’t have an omelette without breaking eggs (French saying, nevermind).

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2002, 5:32pm UTC](https://forum.kirupa.com/t/starfield/5347/12 "2002-09-10T17:32:44Z")

</div>

Makes sense, it didn’t seem to consume too much of my resources, unless I just wasn’t paying enough attention.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2002, 5:39pm UTC](https://forum.kirupa.com/t/starfield/5347/13 "2002-09-10T17:39:34Z")

</div>

Decrease 150 and you should see… and if you don’t, congratulations, you assembled a great computer 🙂

pom :asian:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 10, 2002, 5:46pm UTC](https://forum.kirupa.com/t/starfield/5347/14 "2002-09-10T17:46:41Z")

</div>

I kept decreasing 150 by 50 until I got to 1, still no lagging. I even opened up and use other programs and it all ran smoothly.

I guess my comp is having a good day. It is a 700Mhz with 128Mb Ram, so its not incredible. I built it about a year ago:)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 11, 2002, 6:22am UTC](https://forum.kirupa.com/t/starfield/5347/15 "2002-09-11T06:22:59Z")

</div>

:x :x :x Must be my comp then… Darn laptops really suck. Does it look better with more stars?

pom :asian:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 11, 2002, 6:27am UTC](https://forum.kirupa.com/t/starfield/5347/16 "2002-09-11T06:27:56Z")

</div>

It looks much better with more stars:)

Sorry to stray Ilyas, but do you know how to reset the getTimer() function? I could easily look for it on the web, but hey, figured I would ask you.

I want something to pause for about 3 seconds and have it start again, but it has to loop around so when it starts over again, I want the timer to be reset. Do you know how to do that?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 11, 2002, 6:31am UTC](https://forum.kirupa.com/t/starfield/5347/17 "2002-09-11T06:31:41Z")

</div>

getTimer can’t be reset, it is the time elapsed since the beginning of the clip. All you’ve got to do is work with time spans (I hope all those words exist in English…).

```auto
timeStart=getTimer();
if (getTimer()-start<3000){
   // do what you want
} else {
  // timeStart=getTimer();
}

```

What are you trying to do? If I may ask 🙂

pom :asian:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 11, 2002, 6:44am UTC](https://forum.kirupa.com/t/starfield/5347/18 "2002-09-11T06:44:06Z")

</div>

All those words exist in english:) I don’t really understand what to do with that code. Maybe because it is almost 3am here.

This is what I am trying to do…  
[swf=“[http://www.8ballcreations.com/lostinbeta/colorFadeFooter.swf](http://www.8ballcreations.com/lostinbeta/colorFadeFooter.swf) height=60 width=300”][/swf]

See how the first time it delays? Well I want it to do that each time instead of just the first.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 11, 2002, 6:53am UTC](https://forum.kirupa.com/t/starfield/5347/19 "2002-09-11T06:53:50Z")

</div>

I don’t see a delay… but I do understand what Pom is talking about. Perhaps if I show my methods it will make more sense to you… don’t know yet. 🙂

I use oldtimer newtimer

somewhere in the beginning of my movie I place

oldtimer=getTimer();

Then I just keep reseting oldtimer when I need to. The timer itself is arbitrary once you’ve asigned it to a variable. from then on your just subtracting times. so…

lets say you delay the root timeline.

newTimer=getTimer();  
if(newTimer-oldTimer\<4000){  
gotoAndPlay(6);  
}else{  
oldTimer=newTimer;  
gotoAndPlay(10);  
}

you’re just setting up a loop where it waits to go forward until the difference between oldTimer and newTimer is a certain amount. When that does happen, the playhead moves to the next frame after the oldTimer is set to the newTimer amount.

The next time this is checked… the oldTimer is bigger than it was in the beginning… and consiquently set to be used for the same difference equation.

* * *

to be tricky, if I were going to do this many times and possibly to many different objects… I’d set it up as a function rather than frame script.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 11, 2002, 7:00am UTC](https://forum.kirupa.com/t/starfield/5347/20 "2002-09-11T07:00:57Z")

</div>

Hey david,

Thanks, that worked perfectly! I know have a 1 framed, no movie clip random gradient generator!

[Next page](https://forum.kirupa.com/t/starfield/5347.md?page=2)
