A Flash Developer Resource Site

Results 1 to 18 of 18

Thread: [RESOLVED] scrathcard error

  1. #1
    prgrmr 4 hours user 4 years
    Join Date
    Dec 2009
    Location
    behind you
    Posts
    54

    resolved [RESOLVED] scrathcard error

    I am trying my luck at making a scrathcard app like the one found in this tutorial
    http://www.tutorialized.com/view/tut...d-in-AS3/50890

    I followed the instructions but have this error
    1071: Syntax error: expected a definition keyword (such as function) after attribute Function, not mouseD.

    here is my code

    PHP Code:
    var mouseclick:number=0;

    var 
    maskmc:Sprite =  new sprite();
    thingy.mask maskmc;
    addChild(mask_mc);
    stage.addEventListener(MouseEvent.mouseDown,mouseD);
    stage.addEventListener(MouseEvent.mouseMove,mouseM);
    stage.addEventListener(MouseEvent.mouseUp,mouseU);

    Function 
    mouseD(event:MouseEvent):void{
        
    mouseclick 1;
    }
    Function 
    mouseM(event:MouseEvent):void{
        if (
    mouseclick==1) {
            
    mask_mc.graphics.beginFill(0*000000);
            
    mask_mc.graphics.drawEllipse((mouseX-30),(mouseY-30),60,60);
            
    mask_mc.graphics.endFill();
        }
    }
    Function 
    mouseU(event:MouseEvent):void{
        
    mouseclick 0;


    If you could help me with this I would appreciate it

  2. #2
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    the word function should all be lowercase and not uppercase.
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  3. #3
    Senior Member
    Join Date
    Jun 2008
    Posts
    549
    This look like my tutorial.

    Your mouseDown, mouseMove and mouseUp need to be capitalised.

  4. #4
    prgrmr 4 hours user 4 years
    Join Date
    Dec 2009
    Location
    behind you
    Posts
    54
    samac1068; ok I tried changing the function to lowercase but these TEN ERRORS! I only had ONE before!

    I'll post the errors down below but come on what's going on?

    ilike2; First off, it could very well be your tutorial since the website it came from shares your name (kind of).


    Also capitalizing only made flash not recognize them (they turned to black text).



    ERRORS:
    1046: Type was not found or was not a compile-time constant: number. see footnote (1)
    1120: Access of undefined property mask_mc. see footnote (2)
    1120: Access of undefined property mask_mc. see footnote (3)
    1120: Access of undefined property mask_mc. see footnote (4)
    1180: Call to a possibly undefined method sprite. see footnote (5)
    1120: Access of undefined property thingy. see footnote (6)
    1120: Access of undefined property mask_mc. see footnote (7)
    1119: Access of possibly undefined property mouseDown through a reference with static type Class. see footnote (8)
    1119: Access of possibly undefined property mouseMove through a reference with static type Class. see footnote (9)
    1119: Access of possibly undefined property mouseUp through a reference with static type Class. see footnote (10)


    var mouseclick:number=0;(1)

    var maskmc:Sprite = new sprite(); (5)
    thingy.mask = maskmc; (6)
    addChild(mask_mc);(7)
    stage.addEventListener(MouseEvent.mouseDown,mouseD );(8)
    stage.addEventListener(MouseEvent.mouseMove,mouseM );(9)
    stage.addEventListener(MouseEvent.mouseUp,mouseU);(10)

    function mouseD(event:MouseEvent):void{
    mouseclick = 1;
    }
    function mouseM(event:MouseEvent):void{
    if (mouseclick==1) {
    mask_mc.graphics.beginFill(0*000000); (2)
    mask_mc.graphics.drawEllipse((mouseX-30),(mouseY-30),60,60); (3)
    mask_mc.graphics.endFill(); (4)
    }
    }
    function mouseU(event:MouseEvent):void{
    mouseclick =0;
    }

  5. #5
    Senior Member
    Join Date
    Jun 2008
    Posts
    549
    1: You need a capital n, eg. 'Number'
    2.-7: It seems you have not give a movie clip the instance name: 'mask_mc'
    8-10: like i mentioned you need capitals, eg MouseEvent.MOUSE_DOWN

  6. #6
    prgrmr 4 hours user 4 years
    Join Date
    Dec 2009
    Location
    behind you
    Posts
    54
    Ok Ilik2 I tried capitalizing but nothing happened, the text just turned back to black (I'm pretty sure that's not supposed to happen)
    1119: Access of possibly undefined property MouseUp through a reference with static type Class.

    as you can see the errors remains unchanged



    As for the others..
    1 solved
    2-7 ok I changed the symbol name from "thingy" to mask_mc
    all the errors went away




    but still I need those other errors gone but they stay and capitalizing isn't helping
    Last edited by ym54; 04-03-2010 at 01:32 PM.

  7. #7
    prgrmr 4 hours user 4 years
    Join Date
    Dec 2009
    Location
    behind you
    Posts
    54
    *bump*

  8. #8
    prgrmr 4 hours user 4 years
    Join Date
    Dec 2009
    Location
    behind you
    Posts
    54
    *bump*

  9. #9
    prgrmr 4 hours user 4 years
    Join Date
    Dec 2009
    Location
    behind you
    Posts
    54
    *bump*

  10. #10
    Senior Member x-death's Avatar
    Join Date
    Aug 2009
    Posts
    175
    <x-death to the rescue!>

    sorry i'm all hyped up for toy story 3. anyways to solve this problem of yours:
    Code:
    // you need to make sure when defining you start with a capital.
    var mouseclick:Number=0;
    
    var maskmc:Sprite =  new Sprite(); // you forgot to start with capital again
    addChild(mask_mc);
    // you need to add mask mc first. or else it won't exist
    thingy.mask = maskmc; 
    // i'm not sure if mouse_move is an actual event or not. i think 
    // it should be mouse_change so you might want to look into that.
    stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseD);
    stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseM);
    stage.addEventListener(MouseEvent.MOUSE_UP, mouseU);
    
    // i usually write evt instead of event but either works just fine.
    function mouseD(event:MouseEvent):void{
        mouseclick = 1;
    }
    function mouseM(event:MouseEvent):void{
        if (mouseclick==1) {
            mask_mc.graphics.beginFill(0*000000);
            mask_mc.graphics.drawEllipse((mouseX-30),(mouseY-30),60,60);
            mask_mc.graphics.endFill();
        }
    }
    function mouseU(event:MouseEvent):void{
        mouseclick = 0;
    }
    i hope this helps. it should get rid of most of the errors.

  11. #11
    prgrmr 4 hours user 4 years
    Join Date
    Dec 2009
    Location
    behind you
    Posts
    54
    ok here are my current codes and errors
    code
    var mouseclick:Number=0;

    var maskmc:Sprite = new Sprite();
    mask_mc.mask = maskmc;
    addChild(mask_mc);
    stage.addEventListener(MouseEvent.mouseDown,mouseD );
    stage.addEventListener(MouseEvent.mouseMove,mouseM );
    stage.addEventListener(MouseEvent.mouseUp,mouseU);

    function mouseD(event:MouseEvent):void{
    mouseclick = 1;
    }
    function mouseM(event:MouseEvent):void{
    if (mouseclick==1) {
    mask_mc.graphics.beginFill(0*000000);
    mask_mc.graphics.drawEllipse((mouseX-30),(mouseY-30),60,60);
    mask_mc.graphics.endFill();
    }
    }
    function mouseU(event:MouseEvent):void{
    mouseclick =0;
    }



    errors
    1119: Access of possibly undefined property mouseDown through a reference with static type Class.
    1119: Access of possibly undefined property mouseMove through a reference with static type Class.
    1119: Access of possibly undefined property mouseUp through a reference with static type Class.

    Notes
    1 changing mouseup to MouseUp or Mouse_Up does nothing
    2 when I check for i code errors using the error checker it says I have no errors but when I run it I get these errors

  12. #12
    Senior Member x-death's Avatar
    Join Date
    Aug 2009
    Posts
    175
    i wrote "MOUSE_DOWN" not "Mouse_Down". when writing the actual event like mouse_up or mouse_down you need all letters to be capital. just look at the code i wrote and you'll see the correct way of writing all of it.

    i thought i said this already, but i guess i must not have. either way you know now. and there shouldn't be any more errors. also checking the code for errors only fines obvious mistakes like what you did when writing number. but most errors i usually tend to find pop up when testing.
    Last edited by x-death; 04-10-2010 at 11:35 PM.

  13. #13
    prgrmr 4 hours user 4 years
    Join Date
    Dec 2009
    Location
    behind you
    Posts
    54
    All errors are gone.

    Now I just need to finish it up.

    I am getting no errors but I still cvan't get it to work.

    Here is my file
    http://www.filesavr.com/scratchcard

    Here is the tutorial
    http://www.ilike2flash.com/2009/07/c...nscript-3.html

    can someone help me find my error?

  14. #14
    prgrmr 4 hours user 4 years
    Join Date
    Dec 2009
    Location
    behind you
    Posts
    54
    *bump*

  15. #15
    Senior Member x-death's Avatar
    Join Date
    Aug 2009
    Posts
    175
    cool system. i like it.

    this was a simple mishap on your end. the tutorial wrote "mask_mc" and when you changed the name you forgot to change the name in the following code:
    Code:
    if (mouseclick==1) {
    mask_mc.graphics.beginFill(0*000000);
    mask_mc.graphics.drawEllipse((mouseX-30),(mouseY-30),60,60);
    mask_mc.graphics.endFill();
    }
    so you need to take away the "_" in mask_mc and it should all work.

  16. #16
    prgrmr 4 hours user 4 years
    Join Date
    Dec 2009
    Location
    behind you
    Posts
    54
    changed it but it made no difference

    Did you compare the tutorial to the file

    I think the problem may be how I set up the layers

  17. #17
    Senior Member x-death's Avatar
    Join Date
    Aug 2009
    Posts
    175
    it worked for me, i went tot he tutorial copied the code they gave at end of tutorial then got a picture and put tit in a movieclip named it the name in the code. put the movieclip on the stage and tested it.

    and it works fine!

    i then looked at your code and fixed everything that needed to be fixed so to be honest if its not working then its something your doing wrong. just start over and do exactly what i just said that i did.

  18. #18
    prgrmr 4 hours user 4 years
    Join Date
    Dec 2009
    Location
    behind you
    Posts
    54
    changed the name and done!


    Not sure what difference it made but whatever works.


    resolved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center