A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Stars

  1. #1
    Junior Member
    Join Date
    Jul 2005
    Posts
    2

    Stars

    Hi
    Im trying to have a background picture of a city and make stars in the sky flashing
    can anyone tell me how to do this?
    step by step please =P

  2. #2
    Flashkit Veteran joejoe2288's Avatar
    Join Date
    Apr 2004
    Location
    Hickville, Oregon
    Posts
    2,554
    add this code for the stars
    and just create a small movieclip with a white circle put this mc on the stage and name its instance "star".
    PHP Code:
    stars 200;
    //amount of stars to be created
    starsRandomSize 10;
    //highest size a star can be in pixels
    alphaSpeed 5;
    // how fast the star fades
    function createStars(amountOfStars,starSize) {
    for(
    i=0;i<amountOfStars;i++) {
    _root.duplicateMovieClip("star","star"+i,i);
    swid Stage.width;
    shei Stage.height;
    eval([
    "star"+i])._x random(swid);
    eval([
    "star"+i])._y random(shei);
    eval([
    "star"+i])._width = eval(["star"+i])._height random(starSize)+5;
    eval([
    "star"+i])._alpha random(101);
    eval([
    "star"+i]).rndNum random(2);
    eval([
    "star"+i]).starDown = (eval(["star"+i]).rndNum=0) ? true false;
    }
    }
    createStars(stars,starsRandomSize);
    function 
    changeStarAlpha(speed) {
    for(
    i=0;i<amountOfStars;i++) {
    if(eval([
    "star"+i])._alpha<=30) {
    eval([
    "star"+i]).starDown false;
    }
    if(eval([
    "star"+i])._alpha>=100) {
    eval([
    "star"+i]).starDown true;
    }
    if(eval([
    "star"+i]).starDown) {
    eval([
    "star"+i])._alpha -= speed;
    }else{
    eval([
    "star"+i])._alpha += speed;
    }
    }
    }
    this.onEnterFrame = function() {
    changeStarAlpha(alphaSpeed);
    }; 
    sorry if my code is a little sketchy i am at work right now i will test it later at home if it doesn't work for you
    So tired of all the fighting....

    http://joejoe2288.kawanda.net

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center