Here’s the scenario:
A movie clip (starMC) is centered on the stage. A large background is moved using the arrow keys to give the illusion of traveling through space. There’s a movieclip attached to the starMC that uses the bitmapData class for a motion trail.
I did a version where the starMC moves and the motion trail works, but with this version, where the starMC is static and the background moves, I can’t figure out how to simulate a motion trail based on the motion of the background.
Anyone have any suggestions?
Here’s the AS…
_root.attachMovie(“star”, “starMC”, 10000,{_x:250,_y:250});
_root.attachMovie(“trail_sprite”, “trail_mc”, 8000);
trailbitmap = new flash.display.BitmapData(500, 350, true,0x000000);
_root.createEmptyMovieClip(“trail”, 1);
trail.attachBitmap(trailbitmap, 0);
trail_mc._visible = false;
power = 1.25;
yspeed = 0;
xspeed = 0;
wind = 0;
gravity = 0.5;
upconstant = 0.75;
friction = 0.99;
background.onEnterFrame = function() {
if (Key.isDown(Key.LEFT)) {
xspeed = xspeed+power;
}
if (Key.isDown(Key.RIGHT)) {
xspeed = xspeed-power;
}
if (Key.isDown(Key.UP)) {
yspeed = yspeed+powerupconstant;
}
if (Key.isDown(Key.DOWN)) {
yspeed = yspeed-powerupconstant;
}
xspeed = xspeed*friction;
yspeed = yspeed-gravity;
if (xspeed>15) {
xspeed = 15;
}
if (xspeed<-15) {
xspeed = -15;
}
if (yspeed>15) {
yspeed = 15;
}
if (yspeed<-15) {
yspeed = -15;
}
this._y += yspeed;
this._x += xspeed;
starMC._rotation = starMC._rotation-xspeed;
_root.trail_mc.trail_sprite._rotation = starMC._rotation;
_root.trail_mc.trail_sprite._x = starMC._x;
_root.trail_mc.trail_sprite._y = starMC._y;
_root.trailbitmap.draw(_root.trail_mc);
trail_rectangle = new flash.geom.Rectangle(0, 0, 600, 800);
trail_blur = new flash.filters.BlurFilter(2, 3, 2);
_root.trailbitmap.applyFilter(_root.trailbitmap, trail_rectangle, new Point(0, 0), trail_blur);
};