Copy link to clipboard
Copied
I have a drawing program that doesn't behave the way I expect:
var myShape:Shape = new Shape();
myShape.graphics.moveTo(mouseX,mouseY);
myShape.graphics.lineStyle(1, 0xFF0000);
//stage.addEventListener(MouseEvent.MOUSE_DOWN,startdraw);
stage.addEventListener(MouseEvent.MOUSE_DOWN, startdraw);
stage.addEventListener(MouseEvent.MOUSE_UP,stopdraw);
function startdraw(myevent:MouseEvent):void{
stage.addEventListener(MouseEvent.MOUSE_MOVE, draws);
myShape.graphics.lineTo(mouseX, mouseY);
myevent.updateAfterEvent();
}
function stopdraw(myevent:MouseEvent):void{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, draws);
}
function draws(myeventd:MouseEvent):void{
addChild(myShape);
}
I would like the Flash to recognize that the mouse is down and continue drawing while it is down. Currently it only draws if the mouse is clicked, even while it is down it does not draw. Once I click the mouse and it sends a signal that it has gone down it draws a straight line from the last point that it was clicked rather than drawing continuously.
try:
var myShape:Shape = new Shape();
myShape.graphics.lineStyle(1, 0xFF0000);
//stage.addEventListener(MouseEvent.MOUSE_DOWN,startdraw);
stage.addEventListener(MouseEvent.MOUSE_DOWN, startdraw);
stage.addEventListener(MouseEvent.MOUSE_UP,stopdraw);
function startdraw(myevent:MouseEvent):void {
myShape.graphics.moveTo(mouseX,mouseY);
stage.addEventListener(MouseEvent.MOUSE_MOVE, draws);
}
function stopdraw(myeventb:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_MOVE, draws);
}
func
Copy link to clipboard
Copied
I fixed it. Thanks anyway.
Copy link to clipboard
Copied
No, I didn't fix it. Now it draws and stops when the mouse is up, but there is a line joining the last mouse position to the new mouse position instead of there being a break in the curve.
var myShape:Shape = new Shape();
myShape.graphics.moveTo(mouseX,mouseY);
myShape.graphics.lineStyle(1, 0xFF0000);
//stage.addEventListener(MouseEvent.MOUSE_DOWN,startdraw);
stage.addEventListener(MouseEvent.MOUSE_DOWN, startdraw);
stage.addEventListener(MouseEvent.MOUSE_UP,stopdraw);
function startdraw(myevent:MouseEvent):void{
stage.addEventListener(MouseEvent.MOUSE_MOVE, draws);
}
function stopdraw(myeventb:MouseEvent):void{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, draws);
}
function draws(myeventd:MouseEvent):void{
myShape.graphics.lineTo(mouseX, mouseY);
myeventd.updateAfterEvent();
addChild(myShape);
}
Copy link to clipboard
Copied
I fixed it again for good. I had to add:
myShape.graphics.moveTo(mouseX,mouseY);
after the last line within the function startdraw();
Copy link to clipboard
Copied
try:
var myShape:Shape = new Shape();
myShape.graphics.lineStyle(1, 0xFF0000);
//stage.addEventListener(MouseEvent.MOUSE_DOWN,startdraw);
stage.addEventListener(MouseEvent.MOUSE_DOWN, startdraw);
stage.addEventListener(MouseEvent.MOUSE_UP,stopdraw);
function startdraw(myevent:MouseEvent):void {
myShape.graphics.moveTo(mouseX,mouseY);
stage.addEventListener(MouseEvent.MOUSE_MOVE, draws);
}
function stopdraw(myeventb:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_MOVE, draws);
}
function draws(myeventd:MouseEvent):void {
myShape.graphics.lineTo(mouseX, mouseY);
myeventd.updateAfterEvent();
addChild(myShape);
}
Copy link to clipboard
Copied
Any chance the drawing could be saved as a sharedobject so when the user re-opens the SWF, the drawing is intact and the user can continue?
Copy link to clipboard
Copied
you can save the data used to create the drawing so the drawing can be recreated but you can't directly save the drawing to a shared object.
you can save the drawing (as a bitmap) if the swf is on a server that can use server-side code.
Copy link to clipboard
Copied
I have exactly the same problem as crazy90210, I want to create a drawing pad where anyone can draw and it stays as a common art work among users.
Now I know very little about flash and this is the first thing that I am tring to do. My drawing pad works perfectly, but I don't know how to save it. I thought you could use remote shared object, why is tho not possible? (as I said, I know very little)
and umm, what does this mean:
you can save the drawing (as a bitmap) if the swf is on a server that can use server-side code
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more