PDA

View Full Version : Moving a movieclip continuosly backwards & forwards on the stage with actionscript



LauraITT
March 10th, 2009, 03:02 PM
Hi guys,

Does any one know ne good tutorials for this?

I have some code done but it could be all wrong as I am not the best coder at all, just starting out.

Here it is:

package classes
{
import flash.display.*;
import flash.events.*;
import flash.display.MovieClip;
import flash.events.MouseEvent;


public class RollableChar extends MovieClip
{

//static const edgeDistance:Number = 80;
private var character:MovieClip;
//public var theCharacter:MovieClip;

public function startChar() {

// add to screen characters
addCharacter();


}

public function addCharacter() {

var character = new Object();
theCharacter.dx = 0.0;
theCharacter.x = 100;
theCharacter.dy = 100;
theCharacter.direction = 1;
theCharacter.moveRight = true;
theCharacter.moveLeft = true;
theCharacter.rollSpeed = 10;

if ((theCharacter.dx < 0) && (theCharacter.x > 100)) {
addCharacter(); }
}

public function sit() {

}


public function roll(charcter:MovieClip) {
for(var i:int=0;i<character.length;i++) {

// move
roll(character[i]);

// if hit a wall, turn around
if (character[i].hitWallRight) {
character[i].moveLeft = true;
character[i].moveRight = false;
} else if (character[i].hitWallLeft) {
character[i].moveLeft = false;
character[i].moveRight = true;
}
}
}


}
}

LauraITT
March 10th, 2009, 07:11 PM
I also have this class if it helps






package classes
{
import flash.display.MovieClip;
import classes.RollableChar;


public class MainApp2 extends MovieClip
{
//public var theCharacter:MovieClip;
//public var myCarrot:RollableChar;

public function MainApp2()
{
roll();
//trace("Hello");
}

private function roll()
{

}


}

}

LauraITT
March 11th, 2009, 09:18 AM
Sorted