actionscript 3 - Move and Scale a MovieClip smoothly between multiple points -


i have set-up of 3 horizontal rows button aligned each of them , character (centered each row) want move between these rows (think of little big planet). able program character moves between 3 rows , has set scale when does, want see character moving between points; not watch teleport location. i've tried can think of: loops, boolean on/off, velocity/distance/difference shenanigans, etc., i'm having no success getting move @ button click , continue moving until reaches point. i'm not sure if can set-up scale incrementally until reaches desired end scale size or not. saw similar problem asked on site, solution gave uses point class , lot of math, , have never had success getting flash use points. suggestions appreciated.

package {     import flash.display.movieclip;     import flash.events.event;     import flash.events.mouseevent;      public class main_test_5 extends movieclip     {         private var cam:movieclip = new movieclip();         private var player:player = new player();         private var topposition:uint = 170;         private var centerposition:uint = 270;         private var bottomposition:uint = 370;         private var ui:userinterface = new userinterface();         private var testbackground:testbackground = new testbackground();          public function main_test_5():void         {             player.x = 100;             player.y = 370;             cam.addchild(player);             addchild (ui);              // add event listeners             stage.addeventlistener(event.enter_frame, checkeveryframe);             ui.topbutton.addeventlistener(mouseevent.click, topbuttonclick);             ui.centerbutton.addeventlistener(mouseevent.click, centerbuttonclick);             ui.bottombutton.addeventlistener(mouseevent.click, bottombuttonclick);             addchild (cam);         }          public function checkeveryframe(event:event):void         {             cam.x -= player.x - player.x;             cam.y -= player.y - player.y;         }         public function topbuttonclick (event:mouseevent):void         {             trace ("top click");             if (player.y > topposition) // 170, player.y starts @ 370             {                 player.y -= 100;             }             else if (player.y <= topposition)             {                 player.y = topposition;             }             if (player.y == topposition)             {                 player.scaley = 0.8;                 player.scalex = 0.8;             }             else if (player.y != topposition)             {                 player.scaley = 0.9;                 player.scalex = 0.9;             }         }         public function centerbuttonclick (event:mouseevent):void         {             trace ("center click");             if (player.y > centerposition) // 270             {                 player.y -= 100;             }             if (player.y < centerposition)             {                 player.y += 100;             }             if (player.y == centerposition)             {                 player.scaley = 0.9;                 player.scalex = 0.9;             }         }         public function bottombuttonclick (event:mouseevent):void         {             trace ("bottom click");             if (player.y < bottomposition) // 370             {                 player.y += 100;             }             if (player.y >= bottomposition)             {                 player.y = bottomposition;             }             if (player.y == bottomposition)             {                 player.scaley = 1;                 player.scalex = 1;             }             else if (player.y != bottomposition)             {                 player.scaley = 0.9;                 player.scalex = 0.9;             }         }     } } 

sounds you'd simple. suggest using tweening library. prolific of greensocks tweenlite, part of animation platform

using tweenlite, following:

in place of:

player.y += 100; 

you do:

tweenlite.to(player, 1,{y: player.y + 100, ease: quad.easeinout}); 

this tween (move gradually on time) player object it's current position specified y (player.y + 100). on 1 second , nice in , out ease.

you can add more properties tween (scalex/y, x) really.


do note, there many tweening platform alternatives, including 1 baked flash professional. tweenlite not free use if charge end users fee application. sure review license if use commercially.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -