A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: repeating/duplicating images with scripting to make a field of grass

  1. #1
    Senior Member
    Join Date
    Jul 2000
    Posts
    843

    repeating/duplicating images with scripting to make a field of grass

    i'm trying to create a field of rye grass that scrolls by continously. I think it would probably be easier with actionscripting to make the one image of grass duplicate itself many random times in order to make an appearance of a field that scrolls by. i can't figure out how to do this though. help?
    [swf width="300" height="60" background="#FFFFCC"]http://www.geocities.com/armadilo88/newsword.swf[/swf]


    "You can die anytime you want...but to live takes courage."
    -Hiko Seijuro
    Rurouni Kenshin

  2. #2
    Senior Member vatu_leviathan's Avatar
    Join Date
    Sep 2001
    Location
    England
    Posts
    458
    My story begins in nineteen-dickety-two.We had to say 'dickety' cause the kaiser had stolen our word for twenty.I chased the rascal to get it back but gave up after dickety-six miles.

  3. #3
    Senior Member
    Join Date
    Jul 2000
    Posts
    843
    i managed to get it to dupilicate and stuff, but when it duplicates, all of the clones are on the top of the movie, and i cant figure out how to get them to display on the bottom instead of the top. suggestions? i was looking for something like _yposition or something. i dunno i oculdnt figure it out
    [swf width="300" height="60" background="#FFFFCC"]http://www.geocities.com/armadilo88/newsword.swf[/swf]


    "You can die anytime you want...but to live takes courage."
    -Hiko Seijuro
    Rurouni Kenshin

  4. #4
    Senior Member
    Join Date
    Jul 2000
    Posts
    843
    also how do i make it loop around smoothly? it kinda juts around. i really need to play around with the allignment of the cloned MC, but i cant figure out how. plz?
    [swf width="300" height="60" background="#FFFFCC"]http://www.geocities.com/armadilo88/newsword.swf[/swf]


    "You can die anytime you want...but to live takes courage."
    -Hiko Seijuro
    Rurouni Kenshin

  5. #5
    Senior Member vatu_leviathan's Avatar
    Join Date
    Sep 2001
    Location
    England
    Posts
    458
    erm, hard to say as i dont know how you want it to look. best thingto do is just open it up and have a play. if you look at the middle layer, it has all the script. best just to change the values:

    _root["boxx"+count]._x = random(550);
    _root["boxx"+count]._y = random(150);
    _root["boxx"+count]._xscale = random(150);
    _root["boxx"+count]._yscale = random(150);
    _root["boxx"+count]._alpha = random(100);

    this is just telling the clip to appear randomly, but within the defined parameters, eg _x = random(550); says that the x position will be set to anything upto 550 (pixels?). so, if you need all your clips lower down the page, reduce the _y value. as for making it smoother, im not too sure. maybe edit the actual symbol so that it animates right from one side of the stage to the other. also mebs put the script on the MC rather than on a frame, hopefully then will work on every frame (12 a second, depending upon ur movie fps) arther than just when the movie loops. eg:

    onClipEvent (enterFrame) {
    count = 1;
    while (count<100) {
    _root.box.duplicateMovieClip("boxx"+count, count);
    _root["boxx"+count]._x = random(550);
    _root["boxx"+count]._y = random(50);
    _root["boxx"+count]._xscale = random(150);
    _root["boxx"+count]._yscale = random(150);
    _root["boxx"+count]._alpha = random(100);
    count += 1;
    }

    let me know if this looks any better
    lev
    My story begins in nineteen-dickety-two.We had to say 'dickety' cause the kaiser had stolen our word for twenty.I chased the rascal to get it back but gave up after dickety-six miles.

  6. #6
    Senior Member vatu_leviathan's Avatar
    Join Date
    Sep 2001
    Location
    England
    Posts
    458
    oops, should be an extra '}' at the bottom of that code
    My story begins in nineteen-dickety-two.We had to say 'dickety' cause the kaiser had stolen our word for twenty.I chased the rascal to get it back but gave up after dickety-six miles.

  7. #7
    Junior Member
    Join Date
    Apr 2007
    Posts
    1

    duplicating grass

    I'm not sure if this is relevant to your issue with the grass but as they move off of the screen (if they are going by as in someone walking along a path).
    You'll want to remove the movie clips after they move off of the stage.
    if (grass_mc._x > rightStage){
    grass_mc.removeMovieClip();
    }

    (bold items are variables you'd define)

    You want to do this to save processing power and then it might make your animation run more smoothly. Also you may want to look at your frame rate, too high or too low can make your animation look odd.

    I'd also load them up with an array rather than duplicating what is on the stage (removing placed items is more difficult) If you need code for that sort of thing let me know. (I think I get e-mail updates on postings).

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