Copy link to clipboard
Copied
Hi, friend!
I'm totally new to flash in general. I really need help! I've spent too long Google searching to try and find the answer to this. But I tried to use drag and drop but my code keeps coming up with this error Scene 25, Layer 'Layer_2', Frame 1, Line 7, Column 34 1084: Syntax error: expecting identifier before rightparen. here is the code that I use
var Drawing: Number = 1;
var LineSize: Number = 7;
var DrawColor: Number = 0xff15bb;
var Canvas_sp: Sprite = new Sprite = ();
this.addChild (Canvas_sp);
Canvas_sp.graphics.beginFill (0x00D9FF);
Canvas_sp.graphics.drawRect (0,0,500,400);
var Drawing_sh: Shape = new Shape ();
this.addChild (Drawing_sh);
Canvas_sp.addEventListener (MouseEvent.MOUSE_UP, MouseUp);
Canvas_sp.addEventListener (MouseEvent.MOUSE_DOWN, MouseDown);
Canvas_sp.addEventListener (MouseEvent.MOUSE_MOVE, MouseMove);
function MouseUp (e: MouseEvent): void
{
Drawing = 0;
}
function MouseDown (e: MouseEvent): void
{
var CanX: Number = Drawing_sh.mouseX;
var canY: Number = Drawing_sh.mouseY;
Drawing = 1;
Drawing_sh.graphics.lineStyle (LineSize, DrawColor);
Drawing_sh.graphics.moveTo (CanX, CanY);
}
function MouseMove (e: MouseEvent): void
{
var CanX: Number = Drawing_sh.mouseX;
var canY: Number = Drawing_sh.mouseY;
if (Drawing == 1)
{
Drawing_sh.graphics.lineTo (CanX, CanY);
}
}
PLEASE HELP!
Flash Player is dead. And Flash Player never let you create scripts. What are you actually working with?
Copy link to clipboard
Copied
Flash Player is dead. And Flash Player never let you create scripts. What are you actually working with?
Copy link to clipboard
Copied
Je suis sur Thomson Windows
Copy link to clipboard
Copied
Suggest you post your Flash / Action Script questions in the Animate CC community.
IMO, nobody should be wasting time with Flash applications in 2021.
Copy link to clipboard
Copied
We don't generally help people debug code or do homework, but this jumped out at me:
var Canvas_sp: Sprite = new Sprite = ();
Pretty sure it should be this:
var Canvas_sp: Sprite = new Sprite();
It's also weird that you would include spaces between the function and the parens that hold the parameters. It might be ignored, but it's really odd. You wouldn't generally see that in practice.
this.addChild (Canvas_sp);
vs.
this.addChild(Canvas_sp);
There's a lot of extra spaces sprinkled around in similar ways.
I'm not sure if either of those is why your code blows up on Line 7. I'm guessing it's that Sprite declaration causing some weird downstream effect. (I think you're effectively assigning an anonymous empty function to the constructor of a Sprite object with that syntax, but I'd have to test it -- it's most likely not what you were shooting for.)