A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Compile error 1061 displays when attempting to play timeline animation

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    7

    Compile error 1061 displays when attempting to play timeline animation

    Hi,

    Scenario: Click on button and timeline animation plays

    Error:
    Scene 1, Layer 'actions', Frame 1, Line 11
    1061: Call to a possibly undefined method play through a reference with static type Function.

    What does this error mean and what code needs to be added to fix it?


    Actionscript Code:
    import flash.events.MouseEvent;

    bullet_btn.addEventListener(MouseEvent.CLICK, bullet);
    function bullet(event:MouseEvent) :void
    {
        spinbul_pt_1.play();
    }

    function spinbul_pt_1(){
        bul_pt_1_MC.play();
    }

  2. #2
    Senior Member
    Join Date
    Jul 2008
    Posts
    391
    Is that all the code from Frame 1? Line 11 is a closing brace..

    The error is saying that you tried to call the play method from a Function class. So either spinbul_pt_1 or bul_pt_1_MC is a Function instead of a MovieClip.

  3. #3
    Junior Member
    Join Date
    Sep 2011
    Posts
    7
    - Is that all the code from Frame 1? Line 11 is a closing brace..

    There is additional code that is commented out (and not included in the post) between '{' and 'spinbul_pt_1.play();' which puts 'spinbul_pt_1.play();' at line 11.

    - I was attempting to create the function 'spinbul_pt_1' using the piece of code 'function spinbul_pt_1()'.
    - bul_pt_1_MC is a movie clip
    How do I create the function?

  4. #4
    Senior Member guardiankitty's Avatar
    Join Date
    Dec 2006
    Location
    Here
    Posts
    215
    If you can, post the fla. I would be happy to take a peek at it and help out.

    -GK

  5. #5
    Junior Member
    Join Date
    Sep 2011
    Posts
    7
    CS5, AS 3.0
    FLA is attached.
    Attached Files Attached Files

  6. #6
    Junior Member
    Join Date
    Jun 2011
    Posts
    9
    Well you are trying to call a function spinbul_pt_1.play();
    Later the function's name is spinbul_pt_1.
    What are you trying to do with the .play() part ?

    You can just do this, there is no need for calling another function.

    Actionscript Code:
    import flash.events.MouseEvent;

    bullet_btn.addEventListener(MouseEvent.CLICK, bullet);
    function bullet(event:MouseEvent) :void
    {
        bul_pt_1_MC.play();
    }

    Oh and also in your fla file you might want to put a stop(); command at the beginning of the motion tween because it starts playing without clicking the button.

  7. #7
    Senior Member guardiankitty's Avatar
    Join Date
    Dec 2006
    Location
    Here
    Posts
    215
    Sorry was AFK for a bit, attached is the fixed fla.

    Some comments:

    1) You dont need any extra frames on your main timeline. (just the one is needed- and if you work with mc's, it is better not to have the timeline animate and loop.)

    2) No need to make a function which does nothing other than 'run' a method. IE. a function for just play() or stop() for a movieclip class is not needed and makes your code harder to work with.

    3) Never use buttons- A common rookie mistake. Sprites or Movieclips are always the better bet.


    In short, the error is caused by calling a function as if it was an instance.
    The function should be called like: spinbul_pt_1();
    Not: spinbul_pt_1.play();


    Hope that helps
    Attached Files Attached Files

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