A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Having trouble creating a button. (using FlashDevelop and Flixel)

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    1

    Having trouble creating a button. (using FlashDevelop and Flixel)

    Hello all, I'm completely new to ActionScript (as well as brand new to this forum). I'm using FlashDevelop and Flixel to attempt to make games.

    The error code I'm getting is: "Call to a possibly undefined method addEventListener through a reference with static type QuitButton."

    I have an image, quit.png, that I want to use as a Quit button. When clicked on, I'd like the game to go back to the MenuState. I have the image embedded in QuitButton.as, and MenuState is MenuState.as. The actual button appears in PlayState.as. Here is QuitButton.as, as this is where the problem lies:

    PHP Code:
    package  
    {
        
    import org.flashdevelop.utils.FlashConnect;
        
    import flash.events.*;
        
    import flash.display.*;
        
    import org.flixel.*;
        
        public class 
    QuitButton extends FlxSprite
        
    {
            [
    Embed(source "../media/quit.png")]public var Quit:Class;
            private var 
    _parent:*;
            
            public function 
    QuitButton(_x:int,_y:intparent:*):void
            
    {
                
    super(_x_y);    
                
    _parent parent;
                
    loadGraphic(Quitfalsefalse178);
                
    this.addEventListener(MouseEvent.CLICKclickquit);
            }
            
            private function 
    clickquit(event:MouseEvent):void
            
    {
                
    FlxG.state = new MenuState();
            }
            
            public 
    override function update():void
            
    {
                
    super.update();
            }

            
        }


    I have done some intense googling to try to find a solution, which I'd assume is obvious since I've only just started with flash and I'm not programming anything too difficult yet. If you can, try to explain in plain English for me Thanks in advance!

  2. #2
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    Unfortunately, I know nothing about FlxSprite and couldn't tell you is addEventListeners are part of the method for that class. That appears to be your error.
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

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