pasos para realizar el ejemplo de ruta minima:
1. observar el diseño y los nombres de instancia situados en la sgte imagen:
2. añadir en el fotograma 1 del escenario las sgtes lineas de codigo de actionscript 2:
Código ActionScript :
import flash.geom.ColorTransform; import flash.geom.Transform; import mx.transitions.Tween; import mx.transitions.easing.*; //var box_tween: mx.transitions.Tween = new mx.transitions.Tween(); this.createEmptyMovieClip("box_mb", this.getNextHighestDepth()); this.createEmptyMovieClip("box_mc", this.getNextHighestDepth()); this.createEmptyMovieClip("circle_mc", this.getNextHighestDepth()); circle_mc._x = 600; circle_mc._y = 600; drawCircle(circle_mc, 50, 0x99FF00, 50); function drawCircle(target_mc:MovieClip, radius:Number, fillColor:Number, fillAlpha:Number):Void { var x:Number = radius; var y:Number = radius; with (target_mc) { beginFill(fillColor, fillAlpha); moveTo(x + radius, y); curveTo(radius + x, Math.tan(Math.PI / 8) * radius + y, Math.sin(Math.PI / 4) * radius + x, Math.sin(Math.PI / 4) * radius + y); curveTo(Math.tan(Math.PI / 8) * radius + x, radius + y, x, radius + y); curveTo(-Math.tan(Math.PI / 8) * radius + x, radius+ y, -Math.sin(Math.PI / 4) * radius + x, Math.sin(Math.PI / 4) * radius + y); curveTo(-radius + x, Math.tan(Math.PI / 8) * radius + y, -radius + x, y); curveTo(-radius + x, -Math.tan(Math.PI / 8) * radius + y, -Math.sin(Math.PI / 4) * radius + x, -Math.sin(Math.PI / 4) * radius + y); curveTo(-Math.tan(Math.PI / 8) * radius + x, -radius + y, x, -radius + y); curveTo(Math.tan(Math.PI / 8) * radius + x, -radius + y, Math.sin(Math.PI / 4) * radius + x, -Math.sin(Math.PI / 4) * radius + y); curveTo(radius + x, -Math.tan(Math.PI / 8) * radius + y, radius + x, y); endFill(); } } var box_once: Tween = new Tween(circle_mc, "_y", Regular.easeInOut, 0, (Stage.width - circle_mc._width), 3, true); box_once.onMotionFinished = function() { box_once.yoyo(); } vent._visible=false; closer._visible=false; var initx:Number = vent._x; var inity:Number = vent._y; var zapped:Boolean = false; ventf._visible=false; vent.onPress = function() {vent.startDrag();}; vent.onRelease = function() { vent.stopDrag();}; var menor:Number; var x1:Number; var x2:Number; var x3:Number; var x4:Number; var x5:Number; var x6:Number; var x7:Number; var x8:Number; var reset:Number; //var r1,r2,r3,r4,r5,r6,r7,r8,re,rt:Number; var r1:Number=0; var r2:Number=0; var r3:Number=0; var r4:Number=0; var r5:Number=0; var r6:Number=0; var r7:Number=0; var r8:Number=0; var r9:Number=0; var r10:Number=0; var r11:Number=0; var r12:Number=0; var r13:Number=0; var r14:Number=0; var r15:Number=0; var r16:Number=0; var r17:Number=0; var rt:Number=0; var a:Number; var b:Number; var c:Number; var d:Number; var e:Number; var f:Number; var g:Number; var h:Number; var i:Number; var j:Number; var k:Number; var l:Number; var m:Number; var n:Number; var o:Number; var q:Number; var p:Number; var a21:Number; var b21:Number; var c21:Number; var d21:Number; var e21:Number; var f21:Number; var g21:Number; var h21:Number; var i21:Number; var j21:Number; var k21:Number; var l21:Number; var m21:Number; var n21:Number; var o21:Number; var q21:Number; var p21:Number; var activ:Number; var cont:Number; var colorTrans1:ColorTransform=new ColorTransform(); var trans1:Transform=new Transform(a1); trans1.colorTransform=colorTrans1; var colorTrans2:ColorTransform=new ColorTransform(); var trans2:Transform=new Transform(a2); trans2.colorTransform=colorTrans2; var colorTrans3:ColorTransform=new ColorTransform(); var trans3:Transform=new Transform(a3); trans3.colorTransform=colorTrans3; var colorTrans4:ColorTransform=new ColorTransform(); var trans4:Transform=new Transform(a4); trans4.colorTransform=colorTrans4; var colorTrans5:ColorTransform=new ColorTransform(); var trans5:Transform=new Transform(a5); trans5.colorTransform=colorTrans5; var colorTrans6:ColorTransform=new ColorTransform(); var trans6:Transform=new Transform(a6); trans6.colorTransform=colorTrans6; var colorTrans7:ColorTransform=new ColorTransform(); var trans7:Transform=new Transform(a7); trans7.colorTransform=colorTrans7; var colorTrans8:ColorTransform=new ColorTransform(); var trans8:Transform=new Transform(a8); trans8.colorTransform=colorTrans8; var colorTrans9:ColorTransform=new ColorTransform(); var trans9:Transform=new Transform(a9); trans9.colorTransform=colorTrans9; var colorTrans10:ColorTransform=new ColorTransform(); var trans10:Transform=new Transform(a10); trans10.colorTransform=colorTrans10; var colorTrans11:ColorTransform=new ColorTransform(); var trans11:Transform=new Transform(a11); trans11.colorTransform=colorTrans11; var colorTrans12:ColorTransform=new ColorTransform(); var trans12:Transform=new Transform(a12); trans12.colorTransform=colorTrans12; var colorTrans13:ColorTransform=new ColorTransform(); var trans13:Transform=new Transform(a13); trans13.colorTransform=colorTrans13; var colorTrans14:ColorTransform=new ColorTransform(); var trans14:Transform=new Transform(a14); trans14.colorTransform=colorTrans14; var colorTrans15:ColorTransform=new ColorTransform(); var trans15:Transform=new Transform(a15); trans15.colorTransform=colorTrans15; var colorTrans16:ColorTransform=new ColorTransform(); var trans16:Transform=new Transform(a16); trans16.colorTransform=colorTrans16; var colorTrans17:ColorTransform=new ColorTransform(); var trans17:Transform=new Transform(a17); trans17.colorTransform=colorTrans17; closer.onRelease=function() { lblresul.text="el costo total minimo es"; lblresul.visible=false; vent._visible=false; ventf._visible=false; closer._visible=false; } btnchange.onRelease=function(){ colorTrans1.rgb=0xff0000; trans1.colorTransform=colorTrans1; colorTrans2.rgb=0xff0000; trans2.colorTransform=colorTrans2; colorTrans3.rgb=0xff0000; trans3.colorTransform=colorTrans3; colorTrans4.rgb=0xff0000; trans4.colorTransform=colorTrans4; colorTrans5.rgb=0xff0000; trans5.colorTransform=colorTrans5; colorTrans6.rgb=0xff0000; trans6.colorTransform=colorTrans6; colorTrans7.rgb=0xff0000; trans7.colorTransform=colorTrans7; colorTrans8.rgb=0xff0000; trans8.colorTransform=colorTrans8; colorTrans9.rgb=0xff0000; trans9.colorTransform=colorTrans9; colorTrans10.rgb=0xff0000; trans10.colorTransform=colorTrans10; colorTrans11.rgb=0xff0000; trans11.colorTransform=colorTrans11; colorTrans12.rgb=0xff0000; trans12.colorTransform=colorTrans12; colorTrans13.rgb=0xff0000; trans13.colorTransform=colorTrans13; colorTrans14.rgb=0xff0000; trans14.colorTransform=colorTrans14; colorTrans15.rgb=0xff0000; trans15.colorTransform=colorTrans15; colorTrans16.rgb=0xff0000; trans16.colorTransform=colorTrans16; colorTrans17.rgb=0xff0000; trans17.colorTransform=colorTrans17; }; btnadd.onRelease=function(){ x1=1; x2=2; x3=3; x4=4; x5=5; x6=6; x7=7; x8=8; activ=0; cont=0; menor=1000; reset=1000; r1=0; r2r=0; r3=0; r4=0; r5=0; r6=0; r7=0; r8=0; r9=0; r10=0; r11=0; r12=0; r13=0; r14=0; r15=0; r16=0; r17=0; rt=0; a=parseInt(txta1.text); b=parseInt(txta2.text); c=parseInt(txta3.text); d=parseInt(txta4.text); e=parseInt(txta5.text); f=parseInt(txta6.text); g=parseInt(txta7.text); h=parseInt(txta8.text); i=parseInt(txta9.text); j=parseInt(txta10.text); k=parseInt(txta11.text); l=parseInt(txta12.text); m=parseInt(txta13.text); n=parseInt(txta14.text); o=parseInt(txta15.text); q=parseInt(txta16.text); p=parseInt(txta17.text); a21=a; b21=b; c21=c; d21=d; e21=e; f21=f; g21=g; h21=h; i21=i; j21=j; k21=k; l21=l; m21=m; n21=n; o21=o; q21=q; p21=p; }; btnclean.onRelease=function(){ txta1.text=""; txta2.text=""; txta3.text=""; txta4.text=""; txta5.text=""; txta6.text=""; txta7.text=""; txta8.text=""; txta9.text=""; txta10.text=""; txta11.text=""; txta12.text=""; txta13.text=""; txta14.text=""; txta15.text=""; txta16.text=""; txta17.text=""; colorTrans1.rgb=0xff0000; trans1.colorTransform=colorTrans1; colorTrans2.rgb=0xff0000; trans2.colorTransform=colorTrans2; colorTrans3.rgb=0xff0000; trans3.colorTransform=colorTrans3; colorTrans4.rgb=0xff0000; trans4.colorTransform=colorTrans4; colorTrans5.rgb=0xff0000; trans5.colorTransform=colorTrans5; colorTrans6.rgb=0xff0000; trans6.colorTransform=colorTrans6; colorTrans7.rgb=0xff0000; trans7.colorTransform=colorTrans7; colorTrans8.rgb=0xff0000; trans8.colorTransform=colorTrans8; colorTrans9.rgb=0xff0000; trans9.colorTransform=colorTrans9; colorTrans10.rgb=0xff0000; trans10.colorTransform=colorTrans10; colorTrans11.rgb=0xff0000; trans11.colorTransform=colorTrans11; colorTrans12.rgb=0xff0000; trans12.colorTransform=colorTrans12; colorTrans13.rgb=0xff0000; trans13.colorTransform=colorTrans13; colorTrans14.rgb=0xff0000; trans14.colorTransform=colorTrans14; colorTrans15.rgb=0xff0000; trans15.colorTransform=colorTrans15; colorTrans16.rgb=0xff0000; trans16.colorTransform=colorTrans16; colorTrans17.rgb=0xff0000; trans17.colorTransform=colorTrans17; } btn.onRelease=function() { if(x1==1) { if(a<menor){menor=a;} if(b<menor){menor=b;} if(c<menor){menor=c;} if(menor==a){a21=9999;colorTrans1.rgb=0x0000ff;trans1.colorTransform=colorTrans1;r1=a;} if(menor==b){b21=9999;colorTrans2.rgb=0x0000ff;trans2.colorTransform=colorTrans2;r2=b;} if(menor==c){c21=9999;colorTrans3.rgb=0x0000ff;trans3.colorTransform=colorTrans3;r3=c;} if(menor<999){menor=reset;activ=activ+1;x1=0;} } else if (x2==2) { if(b<menor){menor=b;} if(d<menor){menor=d;} if(e<menor){menor=e;} if(f<menor){menor=f;} if(g<menor){menor=g;} if(h<menor){menor=h;} if(menor==b){b21=9999;colorTrans2.rgb=0x0000ff;trans2.colorTransform=colorTrans2;r2=b;} if(menor==d){d21=9999;colorTrans4.rgb=0x0000ff;trans4.colorTransform=colorTrans4;r4=d;} if(menor==e){e21=9999;colorTrans5.rgb=0x0000ff;trans5.colorTransform=colorTrans5;r5=e;} if(menor==f){f21=9999;colorTrans6.rgb=0x0000ff;trans6.colorTransform=colorTrans6;r6=f;} if(menor==g){g21=9999;colorTrans7.rgb=0x0000ff;trans7.colorTransform=colorTrans7;r7=g;} if(menor==h){h21=9999;colorTrans8.rgb=0x0000ff;trans8.colorTransform=colorTrans8;r8=h;} if(menor<999){menor=reset;x2=0;activ=activ+1;} } else if(x3==3) { if(a<menor){menor=a;} if(d<menor){menor=d;} if(i<menor){menor=i;} if(j<menor){menor=j;} if(k<menor){menor=k;} if(menor==a){a21=9999;colorTrans1.rgb=0x0000ff;trans1.colorTransform=colorTrans1;r1=a;} if(menor==d){b21=9999;colorTrans4.rgb=0x0000ff;trans4.colorTransform=colorTrans4;r4=d;} if(menor==i){i21=9999;colorTrans9.rgb=0x0000ff;trans9.colorTransform=colorTrans9;r9=i;} if(menor==j){j21=9999;colorTrans10.rgb=0x0000ff;trans10.colorTransform=colorTrans10;r10=j;} if(menor==k){k21=9999;colorTrans11.rgb=0x0000ff;trans11.colorTransform=colorTrans11;r11=k;} if(menor<999){menor=reset;x3=0;activ=activ+1;} } else if (x4==4) { if(g<menor){menor=g;} if(i<menor){menor=i;} if(l<menor){menor=l;} if(menor==g){g21=9999;colorTrans7.rgb=0x0000ff;trans7.colorTransform=colorTrans7;r7=g;} if(menor==i){i21=9999;colorTrans9.rgb=0x0000ff;trans9.colorTransform=colorTrans9;r9=i;} if(menor==l){l21=9999;colorTrans12.rgb=0x0000ff;trans12.colorTransform=colorTrans12;r12=l;} if(menor<999){menor=reset;x4=0;activ=activ+1;} } else if (x5==5){ if(j<menor){menor=j;} if(l<menor){menor=l;} if(h<menor){menor=h;} if(m<menor){menor=m;} if(n<menor){menor=n;} if(menor==j){j21=9999;colorTrans10.rgb=0x0000ff;trans10.colorTransform=colorTrans10;r10=j;} if(menor==l){l21=9999;colorTrans12.rgb=0x0000ff;trans12.colorTransform=colorTrans12;r12=l;} if(menor==h){h21=9999;colorTrans8.rgb=0x0000ff;trans8.colorTransform=colorTrans8;r8=h;} if(menor==m){m21=9999;colorTrans13.rgb=0x0000ff;trans13.colorTransform=colorTrans13;r13=m;} if(menor==n){n21=9999;colorTrans14.rgb=0x0000ff;trans14.colorTransform=colorTrans14;r14=n;} if(menor<999){menor=reset;x5=0;activ=activ+1;} } else if (x6==6) { if(f<menor){menor=f;} if(m<menor){menor=m;} if(o<menor){menor=o;} if(q<menor){menor=q;} if(menor==f){f21=9999;colorTrans6.rgb=0x0000ff;trans6.colorTransform=colorTrans6;r6=f;} if(menor==m){m21=9999;colorTrans13.rgb=0x0000ff;trans13.colorTransform=colorTrans13;r13=m;} if(menor==o){o21=9999;colorTrans15.rgb=0x0000ff;trans15.colorTransform=colorTrans15;r15=o;} if(menor==q){q21=9999;colorTrans16.rgb=0x0000ff;trans16.colorTransform=colorTrans16;r16=q;} if(menor<999){menor=reset;x6=0;activ=activ+1;} } else if (x7==7) { if(c<menor){menor=c;} if(e<menor){menor=e;} if(q<menor){menor=q;} if(p<menor){menor=p;} if(menor==c){c21=9999;colorTrans3.rgb=0x0000ff;trans3.colorTransform=colorTrans3;r3=c;} if(menor==e){e21=9999;colorTrans5.rgb=0x0000ff;trans5.colorTransform=colorTrans5;r5=e;} if(menor==q){q21=9999;colorTrans16.rgb=0x0000ff;trans16.colorTransform=colorTrans16;r16=q;} if(menor==p){p21=9999;colorTrans17.rgb=0x0000ff;trans17.colorTransform=colorTrans17;r17=p;} if(menor<999){menor=reset;x7=0;activ=activ+1;} } else if (x8==8) { cont=1; if(p<menor){menor=p;} if(o<menor){menor=o;} if(n<menor){menor=n;} if(k<menor){menor=k;} if(menor==p){p21=9999;colorTrans17.rgb=0x0000ff;trans17.colorTransform=colorTrans17;r17=p;} if(menor==o){o21=9999;colorTrans15.rgb=0x0000ff;trans15.colorTransform=colorTrans15;r15=o;} if(menor==n){n21=9999;colorTrans14.rgb=0x0000ff;trans14.colorTransform=colorTrans14;r14=n;} if(menor==k){k21=9999;colorTrans11.rgb=0x0000ff;trans11.colorTransform=colorTrans11;r11=k;} if(menor<999){menor=reset;x8=0;activ=activ+1;} } else if((activ==8) and (cont==1 or cont==2)) { cont=cont+1; var t1:Number=a21+b21+g21+i21; var t2:Number=b21+c21+e21; var t3:Number=a21+b21+d21; var t4:Number=e21+f21+q21; var t5:Number=b21+c21+q21+f21; var t6:Number=d21+g21+i21; if((t1>9999 and t1<9999*3)and(t6>9999 and t6<9999*2)and(t3>9999 and t3<9999*2)and(t2>9999 and t2<9999*2)) { if(a21<menor){menor=a21;} if(b21<menor){menor=b21;} if(g21<menor){menor=g21;} if(i21<menor){menor=i21;} if(d21<menor){menor=d21;} } if( (t2>9999 and t2<9999*2) and (t4>9999 and t4<9999*2) and (t5>9999 and t5<9999*3) and (t3>9999 and t3<9999*2)) { if(b21<menor){menor=b21;} if(c21<menor){menor=c21;} if(e21<menor){menor=e21;} if(f21<menor){menor=f21;} if(q21<menor){menor=q21;} } if(a21==menor){a21=9999;menor=999;colorTrans1.rgb=0x0000ff;trans1.colorTransform=colorTrans1;r1=a;} if(b21==menor){b21=9999;menor=999;colorTrans2.rgb=0x0000ff;trans2.colorTransform=colorTrans2;r2=b;} if(g21==menor){g21=9999;menor=999;colorTrans7.rgb=0x0000ff;trans7.colorTransform=colorTrans7;r7=g;} if(i21==menor){i21=9999;menor=999;colorTrans9.rgb=0x0000ff;trans9.colorTransform=colorTrans9;r9=i;} if(f21==menor){f21=9999;menor=999;colorTrans6.rgb=0x0000ff;trans6.colorTransform=colorTrans6;r6=f;} if(c21==menor){c21=9999;menor=999;colorTrans3.rgb=0x0000ff;trans3.colorTransform=colorTrans3;r3=c;} if(e21==menor){e21=9999;menor=999;colorTrans5.rgb=0x0000ff;trans5.colorTransform=colorTrans5;r5=e;} if(d21==menor){ d21=9999;menor=999;colorTrans4.rgb=0x0000ff;trans4.colorTransform=colorTrans4;r4=d;} if(q21==menor){ q21=9999;menor=999;colorTrans16.rgb=0x0000ff;trans16.colorTransform=colorTrans16;r16=q;} rt=r1+r2+r3+r4+r5+r6+r7+r8+r9+r10+r11+r12+r13+r14+r15+r16+r17; } else { //trace("aplicacion finalizada"); vent._visible=true; ventf._visible=true; closer._visible=true; vent.text="El Costo Total es:"; ventf.text="$"+rt; } }
3. ejecutar la pelicula, ingresar los datos y presionar en el boton ejecutar hasta que aparezca el costo minimo con la ruta optima remarcado de azul
4. amigos, espero que les pueda servir de ayuda, buena suerte...