I like to add a string variable to my sprites called "state", and then have conditional states like "idle", "walk", "attack", etc... For more complicated movements like with a boss, you can also have trigger objects that the boss can collide into and have a certain action take place before he switches directions.
In order to control his movement directions, you can make a variable called "direction", and make it a number or string, and have it so different numbers/words correlate with different directions you'd have him take. Assign a variable to the trigger objects with data corresponding to the new direction the boss should take after colliding with them.
There are of course a million ways to go about your goal. The vague method I described is only one of those ways, but your best bet is to experiment until it has the movement and actions you want.