# Can you spot the error with this code?

**URL:** <https://forum.kirupa.com/t/can-you-spot-the-error-with-this-code/268374>\
**Category:** flash\
**Created:** [August 13, 2008, 4:32am UTC](https://forum.kirupa.com/t/can-you-spot-the-error-with-this-code/268374 "2008-08-13T04:32:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kru](https://avatars.discourse-cdn.com/v4/letter/k/ecccb3/32.png) [@kru](https://forum.kirupa.com/u/kru)\
**Post date:** [August 13, 2008, 4:32am UTC](https://forum.kirupa.com/t/can-you-spot-the-error-with-this-code/268374/1 "2008-08-13T04:32:48Z")

</div>

This one caught me off guard. Here I was, happily coding a wrapper for a little animated gif handler, and I got nailed by this. I spent about 20 minutes trying to figure out what was going on. I’m sure you guys will spot it instantly. The error message was no help at all.

main.as  
ActionScript Code:  
[LEFT]package  
[COLOR=#000000]{[/COLOR]  
[COLOR=#0000FF]import[/COLOR] flash.[COLOR=#000080]display[/COLOR].[COLOR=#000080]Sprite[/COLOR];

```
[COLOR=#0000FF]import[/COLOR] gif.[COLOR=#000080]Gif[/COLOR];

[COLOR=#000000][[/COLOR]SWF[COLOR=#000000]([/COLOR]frameRate=[COLOR=#FF0000]"63"[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]][/COLOR]
[COLOR=#0000FF]public[/COLOR] [COLOR=#000000] **class** [/COLOR] main [COLOR=#0000FF]extends[/COLOR] Sprite
[COLOR=#000000]{[/COLOR]
    [COLOR=#0000FF]public[/COLOR] [COLOR=#000000] **function** [/COLOR] main[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR]:[COLOR=#0000FF]void[/COLOR]
    [COLOR=#000000]{[/COLOR]
        [COLOR=#000000] **var** [/COLOR] gif:Gif = [COLOR=#000000] **new** [/COLOR] Gif[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
        [COLOR=#0000FF]stage[/COLOR].[COLOR=#000080]addChild[/COLOR][COLOR=#000000]([/COLOR]gif[COLOR=#000000])[/COLOR];
        gif.[COLOR=#0000FF]play[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
    [COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]

```

[COLOR=#000000]}[/COLOR]  
[/LEFT]

gif/Gif.as  
ActionScript Code:  
[LEFT]package gif  
[COLOR=#000000]{[/COLOR]  
[COLOR=#0000FF]import[/COLOR] flash.[COLOR=#000080]display[/COLOR].[COLOR=#000080]Sprite[/COLOR];

```
[COLOR=#0000FF]public[/COLOR] [COLOR=#000000] **class** [/COLOR] Gif [COLOR=#0000FF]extends[/COLOR] Sprite
[COLOR=#000000]{[/COLOR]
    [COLOR=#0000FF]public[/COLOR] [COLOR=#000000] **function** [/COLOR] Gif[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR]:[COLOR=#0000FF]void[/COLOR]
    [COLOR=#000000]{[/COLOR]
        graphics.[COLOR=#0000FF]beginFill[/COLOR][COLOR=#000000]([/COLOR]0xFFFFFF[COLOR=#000000])[/COLOR];
        graphics.[COLOR=#000080]drawRect[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000080]0[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]50[/COLOR], [COLOR=#000080]50[/COLOR][COLOR=#000000])[/COLOR];
        graphics.[COLOR=#0000FF]endFill[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
    [COLOR=#000000]}[/COLOR]

    [COLOR=#0000FF]public[/COLOR] [COLOR=#000000] **function** [/COLOR] [COLOR=#0000FF]play[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR]:[COLOR=#0000FF]void[/COLOR]
    [COLOR=#000000]{[/COLOR]
        [COLOR=#808080]*//*[/COLOR]
    [COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]

```

[COLOR=#000000]}[/COLOR]  
[/LEFT]

And the error message from the flex compiler…

```auto
C:\flex\development\bugtest\main.as(14): col: 8 Error: Call to a possibly undefined method play.

                        gif.play();
                            ^

```
