Starfield

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. Is there a simpler way to accomplish that effect without having to use motion tweens?

Cheers!
Kirupa :frowning:

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!

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

*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! **
:stuck_out_tongue: That’s definitely advanced, RageWolf.

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

pom :asian:

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

pom :asian:

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

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

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

Thanks a lot for the replies. Flex that is pretty much exactly what I had been looking for. Thanks :slight_smile: 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:

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 :slight_smile:

Here’s something based on the perspective tutorial (the engine is not mine, it’s Keith Peter’s. 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):

/*********************
 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. :slight_smile:

pom :asian:

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

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

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

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

pom :asian:

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:)

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

pom :asian:

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?

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…).

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

What are you trying to do? If I may ask :slight_smile:

pom :asian:

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 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.

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. :slight_smile:

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.

Hey david,

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