change line color with button?

  • brentjlaf
  • Student
  • Student
  • User avatar
  • Posts: 67

Post 3+ Months Ago

Quick question, I am trying to change the line color, thats being draw with the click of a button.

Code: [ Select ]
//////////////////////////
// colors
//////////////////////////
blue.onPress = function() {
    mycolor.color(0x0000FF);
};
red.onPress = function() {
    mycolor.color(0xFF0000);
};
black.onPress = function() {
    mycolor.color(0x000000);
};
green.onPress = function() {
    mycolor.color(0x00FF00);
};
_root.createEmptyMovieClip("line", 1);
_root.onMouseDown = function() {
    line.moveTo(_xmouse, _ymouse);
    line.lineStyle(1, mycolor, 100);
    this.onEnterFrame = function() {
        line.lineTo(_xmouse, _ymouse);
    };
};
_root.onMouseUp = function() {
    this.onEnterFrame = null;
};
//////////////////////////
// erase
//////////////////////////
buttonErase.onPress = function() {
    _root.line.clear();
};
  1. //////////////////////////
  2. // colors
  3. //////////////////////////
  4. blue.onPress = function() {
  5.     mycolor.color(0x0000FF);
  6. };
  7. red.onPress = function() {
  8.     mycolor.color(0xFF0000);
  9. };
  10. black.onPress = function() {
  11.     mycolor.color(0x000000);
  12. };
  13. green.onPress = function() {
  14.     mycolor.color(0x00FF00);
  15. };
  16. _root.createEmptyMovieClip("line", 1);
  17. _root.onMouseDown = function() {
  18.     line.moveTo(_xmouse, _ymouse);
  19.     line.lineStyle(1, mycolor, 100);
  20.     this.onEnterFrame = function() {
  21.         line.lineTo(_xmouse, _ymouse);
  22.     };
  23. };
  24. _root.onMouseUp = function() {
  25.     this.onEnterFrame = null;
  26. };
  27. //////////////////////////
  28. // erase
  29. //////////////////////////
  30. buttonErase.onPress = function() {
  31.     _root.line.clear();
  32. };
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

Instead of
Code: [ Select ]
mycolor.color(0xff0000);

Try
Code: [ Select ]
mycolor = 0xff0000;
  • brentjlaf
  • Student
  • Student
  • User avatar
  • Posts: 67

Post 3+ Months Ago

Ah more problemo's
not sure how i can either draw on top of the moving clip, or what i should be doing.


Code: [ Select ]
lineThickness = 0;
selectedColor = "0x000000";
_root.onMouseDown = startDrawing;
_root.onMouseUp = stopDrawing;
function startDrawing() {
    if (_xmouse>25) {
        _root.lineStyle(lineThickness, selectedColor, 100);
        _root.moveTo(_root._xmouse, _root._ymouse);
        _root.onMouseMove = drawLine;
    }
}
function drawLine() {
    _root.lineTo(this._xmouse, this._ymouse, 200);
}
function stopDrawing() {
    delete this.onMouseMove;
}
line0.onPress = function() {
    lineThickness = 0;
};
line3.onPress = function() {
    lineThickness = 3;
};
//////////////////////////
// color
//////////////////////////
colorRed.onPress = function() {
    selectedColor = "0xFF0000";
};
colorGreen.onPress = function() {
    selectedColor = "0x00FF00";
};
colorBlue.onPress = function() {
    selectedColor = "0x0000FF";
};
colorBlack.onPress = function() {
    selectedColor = "0x000000";
};
//////////////////////////
// erase
//////////////////////////
buttonErase.onRelease = function() {
    clear();
};
//////////////////////////
//boards
//////////////////////////
button_basketball.onPress = function() {
    holder.attachMovie("basketball", "basketball", 10);
};
button_curling.onPress = function() {
    holder.attachMovie("curling", "curling", 10);
};
button_football.onPress = function() {
    holder.attachMovie("football", "football", 10);
};
button_hockey.onPress = function() {
    holder.attachMovie("hockey", "hockey", 10);
};
button_soccer.onPress = function() {
    holder.attachMovie("soccer", "soccer", 10);
};
button_tennis.onPress = function() {
    holder.attachMovie("tennis", "tennis", 10);
};
button_volleyball.onPress = function() {
    holder.attachMovie("volleyball", "volleyball", 10);
};
  1. lineThickness = 0;
  2. selectedColor = "0x000000";
  3. _root.onMouseDown = startDrawing;
  4. _root.onMouseUp = stopDrawing;
  5. function startDrawing() {
  6.     if (_xmouse>25) {
  7.         _root.lineStyle(lineThickness, selectedColor, 100);
  8.         _root.moveTo(_root._xmouse, _root._ymouse);
  9.         _root.onMouseMove = drawLine;
  10.     }
  11. }
  12. function drawLine() {
  13.     _root.lineTo(this._xmouse, this._ymouse, 200);
  14. }
  15. function stopDrawing() {
  16.     delete this.onMouseMove;
  17. }
  18. line0.onPress = function() {
  19.     lineThickness = 0;
  20. };
  21. line3.onPress = function() {
  22.     lineThickness = 3;
  23. };
  24. //////////////////////////
  25. // color
  26. //////////////////////////
  27. colorRed.onPress = function() {
  28.     selectedColor = "0xFF0000";
  29. };
  30. colorGreen.onPress = function() {
  31.     selectedColor = "0x00FF00";
  32. };
  33. colorBlue.onPress = function() {
  34.     selectedColor = "0x0000FF";
  35. };
  36. colorBlack.onPress = function() {
  37.     selectedColor = "0x000000";
  38. };
  39. //////////////////////////
  40. // erase
  41. //////////////////////////
  42. buttonErase.onRelease = function() {
  43.     clear();
  44. };
  45. //////////////////////////
  46. //boards
  47. //////////////////////////
  48. button_basketball.onPress = function() {
  49.     holder.attachMovie("basketball", "basketball", 10);
  50. };
  51. button_curling.onPress = function() {
  52.     holder.attachMovie("curling", "curling", 10);
  53. };
  54. button_football.onPress = function() {
  55.     holder.attachMovie("football", "football", 10);
  56. };
  57. button_hockey.onPress = function() {
  58.     holder.attachMovie("hockey", "hockey", 10);
  59. };
  60. button_soccer.onPress = function() {
  61.     holder.attachMovie("soccer", "soccer", 10);
  62. };
  63. button_tennis.onPress = function() {
  64.     holder.attachMovie("tennis", "tennis", 10);
  65. };
  66. button_volleyball.onPress = function() {
  67.     holder.attachMovie("volleyball", "volleyball", 10);
  68. };
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

What do you want it to do, & what does it do now ?
  • brentjlaf
  • Student
  • Student
  • User avatar
  • Posts: 67

Post 3+ Months Ago

sorry, im trying to draw on top of the movieclips that i am loading, right now its drawing underneath them. the movieclip "holder" is the one im loading the other movieclips into.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

See how you're calling the drawing methods directly on _root ?

Not good.

Create an empty movieclip to call the drawing methods on, so that you can make sure the movieclip you're calling the drawing methods on is at a higher depth than the movieclips being loaded.
  • brentjlaf
  • Student
  • Student
  • User avatar
  • Posts: 67

Post 3+ Months Ago

Thanks! got her working 100%

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 18 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.