file not found
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?
Pumpkin Carving 2008
Can't save your head, but you might want to look again at that game in your signature. If you play a game, end the game, submit your score, and then press "Go get em'" at the bottom, your score is missing. Just thought you'd want to know.
The 'Boose':
ASUS Sabertooth P67 TUF
Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
8GB G.Skill Ripjaws 1600 DDR3
ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
New addition: OCZ Vertex 240GB SATA III SSD
WEI Score: 7.6
M.D.
Senior Member
I am guessing second mc is named either "bob" or "char2", but you are using both names mixed in the code.
file not found
@imprisoned pride
yeah...I saw that, but souldn't figure out why...maybe some day I will
@mr_malee
...ok
@tonypa
yes, I forgot to include that, bob is another one of my mc's
Attached Files
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();
M.D.
i'm not sure what kind of effect you we're looking for but something like this perhaps:
Code:
this.createEmptyMovieClip("Line",1);
Line.lineStyle(4,0x0000ff,100);
Line.moveTo(char._x, char._y);
char.onEnterFrame = function() {
Line.lineTo(char._x, char._y - Line._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;
}
Line._y += 1
}
stop();
file not found
I'm trying to draw two lines at once onstage that go to two different mc's.
Ultimately, my goal is to get four at once, but I'm just trying to get two to draw their lines following two mc's right now
for some reason, I can draw two lines at once if one or more goes to the mouse, but not if 2 or more go to an mc...
and I tried the codes both of you suggested, neither worked, I guess I should have been more clear, sorry.
M.D.
i don't understand, where are the lines originating from? if their originating from the player's and moving to a player, you will never see the line. If you want a trail, move the origin once and call the "lineTo" action whenever the player moves, don't update the origin and don't move the parent movieclip
Here's an example where the arrow keys move one and the WASD keys move the other. Is this what you are trying to do?
See attached.
Last edited by dawsonk; 08-22-2007 at 10:52 AM .
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width