James

If you get hold of the brilliant animation package:

http://www.alex-uhlmann.de/flash/animationpackage/

You can use it to do stuff like this:

[as]
Stage.align = "TL";
Stage.scaleMode = "noScale";
/*
Note: you need to have all supplied folders, 
except the "docs" folder, located in the same folder 
like this .fla.

The line 
APCore.initialize();
initializes AnimationPackage. See tutorial.htm.
*/
import de.alex_uhlmann.animationpackage.*;
import de.alex_uhlmann.animationpackage.animation.*;
import de.alex_uhlmann.animationpackage.drawing.*;
import de.alex_uhlmann.animationpackage.utility.*;
import com.robertpenner.easing.*;
APCore.initialize();
//
w = Stage.width;
h = Stage.height;
//
points = new Array({x:10, y:10, rot:0}, {x:300, y:10, rot:90}, {x:300,
y:300, rot:180}, {x:100, y:300, rot:90}, {x:100, y:400, rot:0});
path = new Array();
calcPath = function () {
        holder = this.createEmptyMovieClip("holder",
this.getNextHighestDepth());
        holder.lineStyle(1);
        for (i=0; i<points.length; i++) {
                pt = points[i];
                npt = points[i+1];
                if (i == 0) {
                        holder.moveTo(pt.x, pt.y);
                        path.push({x:pt.x, y:pt.y});
                }
                // if rot = 0 draw horizontally right

                if (pt.rot == 0) {
                        // // is next point on same y axes?
                        // // // is next point x greater than this x?
                        if (pt.y == npt.y && npt.x>pt.x) {
                                holder.lineTo(npt.x, npt.y);
                                path.push({x:npt.x, y:npt.y});
                        } else {
                                holder.lineTo(w, pt.y);
                                path.push({x:w, y:pt.y});
                                //draw to edge
                                return;
                        }
                }
                //                           
                // if rot = 90 draw vertically down
                if (pt.rot == 90) {
                        // // is next point on same x axes?
                        // // // is next point y greater than this y?
                        if (pt.x == npt.x && npt.y>pt.y) {
                                holder.lineTo(npt.x, npt.y);
                                path.push({x:npt.x, y:npt.y});
                        } else {
                                //draw to edge
                                holder.lineTo(pt.x, h);
                                path.push({x:pt.x, y:h});
                                return;
                        }
                }
                //                           
                // if rot= 180 draw horizontally left
                if (pt.rot == 180) {
                        // // is next point on same y axes?
                        // // // is next point x less than this x?
                        if (pt.y == npt.y && npt.x<pt.x) {
                                holder.lineTo(npt.x, npt.y);
                                path.push({x:npt.x, y:npt.y});
                        } else {
                                //draw to edge
                                holder.lineTo(0, pt.y);
                                path.push({x:0, y:pt.y});
                                return;
                        }
                }
                //                           
                // if rot = 270 draw vertically up
                if (rot == 270) {
                        // // is next point on same x axes?
                        // // // is next point y less than this y?
                        if (pt.x == npt.x && npt.y<pt.y) {
                                holder.lineTo(npt.x, npt.y);
                                path.push({x:npt.x, y:npt.y});
                        } else {
                                //draw to edge
                                holder.lineTo(pt.x, 0);
                                path.push({x:pt.x, y:0});
                                return;
                        }
                }
        }
};
drawPath = function () {
        AnimationCore.duration_def = 500;
        AnimationCore.easing_def = Circ.easeInOut;
        var ln = path.length;
        var myDraw_mc:MovieClip = this.createEmptyMovieClip("draw_mc",
999);
        var myDrawer:Drawer = new Drawer(myDraw_mc);
        for (var i = 0; i<ln; i++) {
                var pt = path[i];
                var npt = path[i+1];
                var part:Line = new Line(pt.x, pt.y, npt.x, npt.y);
                part.lineThickness = 4;
                part.lineStyle(6, 0x0000ff, 100);
                myDrawer.addChild(part);
        }
        myDrawer.addEventListener("onEnd", this, "finishedPath");
        myDrawer.animate(0, 100);
};
function finishedPath(eventObject:Object) {
        trace("FINISHED");
}
calcPath();
drawPath();
[/as]

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf 
> Of James Marsden
> Sent: 07 March 2006 13:37
> To: Flashcoders mailing list
> Subject: Re: [Flashcoders] Bouncing laserbeam for game
> 
> I haven't heard of that, but it sounds ace!  Might have to 
> have a go...
> 
> 
> Mike Mountain wrote:
> 
> >Cool - you've used fixed mirrors though? The versions of 
> this game I've 
> >played had the rotation of the mirror as part of the puzzle 
> complexity.
> >
> >So you have a selection of mirrors in a toolbox that point 
> at varying 
> >90 degree steps that you drag onto the screen in some kind of maze - 
> >then when you press 'go' the laser draws its way across the 
> screen to 
> >the goal. There'll also be fixed mirrors on the screen that 
> you have to 
> >hit with the laser to complete the level.
> >
> >M
> >
> >  
> >
> >  
> >
> _______________________________________________
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> 
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training 
> http://www.figleaf.com http://training.figleaf.com
> 
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to