save my brain from exploding
I'm trying to draw 2 dynamic, user-created lines onstage at once, and nothing is working...
right now, I have two layers, on layer one, it had the following actionscript:
Code:
createEmptyMovieClip("Line",1);
Line.lineStyle(4,0x00ccff,100);
char.onEnterFrame = function() {
Line.moveTo(char._x, char._y);
onEnterFrame = function () {
Line.lineTo(char._x, char._y);
}
if (Key.isDown (Key.UP)) {
char._y -= 2;
}
if (Key.isDown (Key.DOWN)) {
char._y += 2;
}
if (Key.isDown (Key.RIGHT)) {
char._x += 2;
}
if (Key.isDown (Key.LEFT)) {
char._x -= 2;
}
}
stop();
obviously, this layer contains the char mc ( and the as based Line mc)
on the 2nd layer
Code:
createEmptyMovieClip("Line2",2);
Line2.lineStyle(4,0x990000,100);
bob.onEnterFrame = function() {
Line2.moveTo(char2._x, char2._y);
onEnterFrame = function () {
Line2.lineTo(char2._x, char2._y);
}
char2._x = _xmouse;
char2._y = _ymouse;
}
stop();
again, on this layer there is an mc called char2
for some reason, ^this^ doesn't work, but it will work if I do this:
Code:
createEmptyMovieClip("Line2",2);
Line2.lineStyle(4,0x990000,100);
bob.onEnterFrame = function() {
Line2.moveTo(_xmouse._x, _ymouse);
onEnterFrame = function () {
Line2.lineTo(_xmouse, _ymouse);
}
}
stop();
can anybody save my head from exploding?
Maybe try something like this...
Code:
createEmptyMovieClip("Line", 1);
Line.lineStyle(4, 0x0000ff, 100);
char.onEnterFrame = function() {
Line.moveTo(char._x, char._y);
if (Key.isDown(Key.UP)) {
char._y -= 2;
Line.lineTo(char._x, char._y);
}
if (Key.isDown(Key.DOWN)) {
char._y += 2;
Line.lineTo(char._x, char._y);
}
if (Key.isDown(Key.RIGHT)) {
char._x += 2;
Line.lineTo(char._x, char._y);
}
if (Key.isDown(Key.LEFT)) {
char._x -= 2;
Line.lineTo(char._x, char._y);
}
};
stop();