Urgent: Getting the 'Cancel' button to work

Hi everyone!!!
I am having problems with a button that should close a JFrame that is created in another class file. Basically I dont know how to pass the required object (that is the "NewWizardFrame" object) through to the action listener for the cancel button that exists as a inner class within "NewWizardPanel". I am getting nullpointerexceptions when I click on the 'cancel' button to close the frame. I will post all the code below so that anyone can compile it and see what the hell i'm going on about!!! If you know how to fix the problem just post the fixed code back here and everything will be perfect!!! Thanks
p.s. I will give 5 duke dollars to the first person who can post me back the fixed code. Thanks again.
The code follows below, just run the NewChartTest file.
* NewChartTest.java
* 23/11/02 (Date start)
* This class is for test purposes for
* the "New Chart" wizard
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class NewChartTest extends JPanel
private JButton newButton;
public JFrame wizardFrame;
public NewChartTest()
// create new button
newButton = new JButton("New Chart");
// create tooltip for every button
newButton.setToolTipText("New Chart");
// add our button to the JPanel
add(newButton);
// construct button action
NewButtonListener listener1 = new NewButtonListener();
// Add action listener to button
newButton.addActionListener(listener1);
private class NewButtonListener implements ActionListener
public void actionPerformed(ActionEvent evt)
wizardFrame = new JFrame("New Chart Wizard*");
NewWizardPanel wizardPanel = new NewWizardPanel();
wizardFrame.getContentPane().add(wizardPanel);
wizardFrame.setSize(380, 220);
wizardFrame.setVisible(true);
// Main entry point into the ToolBarPanel class
public static void main(String[] args)
// Create a frame to hold us and set its title
JFrame frame = new JFrame("New Chart Test");
// Set frame to close after user request
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Add our tab panel to the frame
NewChartTest nct = new NewChartTest();
frame.getContentPane().add(nct, BorderLayout.CENTER);
// Resize the frame
frame.setSize(680, 480);
// Make the windows visible
frame.setVisible(true);
* NewWizardPanel.java
* 23/11/02 (Date start)
* This class is for test purposes for
* the "New Chart" wizard
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class NewWizardPanel extends JPanel
private JLabel projectNameLabel;
private JLabel maxCharacterLabel;
private JLabel durationLabel;
private JLabel monthLabel;
private JTextField projectName;
private JComboBox projectDuration;
private JButton okButton;
private JButton cancelButton;
private JFrame wizardFrame;
public NewWizardPanel()
// create additional panels to hold objects
JPanel topPanel = new JPanel();
JPanel lowerPanel = new JPanel();
JPanel buttonPanel = new JPanel();
// Create a border around the "nextpanel"
Border etched = BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.black, Color.blue);
Border titled = BorderFactory.createTitledBorder(etched, "Please provide a title to your project");
topPanel.setBorder(titled);
// Create a border around the "lowerpanel"
Border etched1 = BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.black, Color.blue);
Border titled1 = BorderFactory.createTitledBorder(etched1, "Please select the duration of your project");
lowerPanel.setBorder(titled1);
// initialise label objects
projectNameLabel = new JLabel("Project Name", JLabel.LEFT);
maxCharacterLabel = new JLabel("(Max 20 Chars)");
durationLabel = new JLabel("Duration (in months)", JLabel.LEFT);
monthLabel = new JLabel("1 - 12 months");
projectName = new JTextField("Default Name", 20);
projectName.setColumns(15);
topPanel.validate();
projectDuration = new JComboBox();
projectDuration.setEditable(false);
projectDuration.addItem("1");
projectDuration.addItem("2");
projectDuration.addItem("3");
projectDuration.addItem("4");
projectDuration.addItem("5");
projectDuration.addItem("6");
projectDuration.addItem("7");
projectDuration.addItem("8");
projectDuration.addItem("9");
projectDuration.addItem("10");
projectDuration.addItem("11");
projectDuration.addItem("12");
// initialise buttons
okButton = new JButton("Ok", new ImageIcon("Test/ok.gif"));
cancelButton = new JButton("Cancel", new ImageIcon("Test/cancel.gif"));
// add objects to panels
topPanel.add(projectNameLabel);
topPanel.add(projectName);
topPanel.add(maxCharacterLabel);
lowerPanel.add(durationLabel);
lowerPanel.add(projectDuration);
lowerPanel.add(monthLabel);
buttonPanel.add(okButton);
buttonPanel.add(cancelButton);
// create instance of cancelButtonListener
CancelButtonListener cancelListen = new CancelButtonListener(wizardFrame);
// add actionListener for the cancel button
cancelButton.addActionListener(cancelListen);
// use Box layout to arrange panels
Box hbox2 = Box.createHorizontalBox();
hbox2.add(topPanel);
Box hbox4 = Box.createHorizontalBox();
hbox4.add(lowerPanel);
Box hbox5 = Box.createHorizontalBox();
hbox5.add(buttonPanel);
Box vbox = Box.createVerticalBox();
vbox.add(hbox2);
vbox.add(Box.createGlue());
vbox.add(hbox4);
vbox.add(Box.createGlue());
vbox.add(hbox5);
this.add(vbox, BorderLayout.NORTH);
private class CancelButtonListener implements ActionListener
public CancelButtonListener(JFrame awizardFrame)
wizardFrame = awizardFrame;
public void actionPerformed(ActionEvent event)
Object source = event.getSource();
if(source == cancelButton)
wizardFrame.setVisible(false);
// Main entry point into the ToolBarPanel class
public static void main(String[] args)
// Create a frame to hold us and set its title
JFrame frame = new JFrame("New Chart Wizard");
// Set frame to close after user request
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Add our tab panel to the frame
NewWizardPanel nwp = new NewWizardPanel();
frame.getContentPane().add(nwp, BorderLayout.CENTER);
// Resize the frame
frame.setSize(680, 480);
// Make the windows visible
frame.setVisible(true);

Hi everyone!!!
I am having problems with a button that should close a
JFrame that is created in another class file.
Basically I dont know how to pass the required object
(that is the "NewWizardFrame" object) through to the
action listener for the cancel button that exists as a
inner class within "NewWizardPanel". I am getting
nullpointerexceptions when I click on the 'cancel'
button to close the frame. I will post all the code
below so that anyone can compile it and see what the
hell i'm going on about!!! If you know how to fix the
problem just post the fixed code back here and
everything will be perfect!!! Thanks
p.s. I will give 5 duke dollars to the first person
who can post me back the fixed code. Thanks again.
The code follows below, just run the NewChartTest
file.
* NewChartTest.java
* 23/11/02 (Date start)
* This class is for test purposes for
* the "New Chart" wizard
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class NewChartTest extends JPanel
private JButton newButton;
public JFrame wizardFrame;
static NewChartTest instance;
public NewChartTest()
{  instance = this;
>
// create new button
newButton = new JButton("New Chart");
// create tooltip for every button
newButton.setToolTipText("New Chart");
// add our button to the JPanel
add(newButton);
// construct button action
NewButtonListener listener1 = new
1 = new NewButtonListener();
// Add action listener to button
newButton.addActionListener(listener1);
private class NewButtonListener implements
nts ActionListener
public void actionPerformed(ActionEvent evt)
wizardFrame = new JFrame("New Chart
("New Chart Wizard*");
NewWizardPanel wizardPanel = new
Panel = new NewWizardPanel();
wizardFrame.getContentPane().add(wizardPanel);
wizardFrame.setSize(380, 220);
wizardFrame.setVisible(true);
// Main entry point into the ToolBarPanel class
public static void main(String[] args)
// Create a frame to hold us and set its
set its title
JFrame frame = new JFrame("New Chart Test");
// Set frame to close after user request
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Add our tab panel to the frame
NewChartTest nct = new NewChartTest();
frame.getContentPane().add(nct,
dd(nct, BorderLayout.CENTER);
// Resize the frame
frame.setSize(680, 480);
// Make the windows visible
frame.setVisible(true);
* NewWizardPanel.java
* 23/11/02 (Date start)
* This class is for test purposes for
* the "New Chart" wizard
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class NewWizardPanel extends JPanel
private JLabel projectNameLabel;
private JLabel maxCharacterLabel;
private JLabel durationLabel;
private JLabel monthLabel;
private JTextField projectName;
private JComboBox projectDuration;
private JButton okButton;
private JButton cancelButton;
private JFrame wizardFrame;
public NewWizardPanel()
// create additional panels to hold objects
JPanel topPanel = new JPanel();
JPanel lowerPanel = new JPanel();
JPanel buttonPanel = new JPanel();
// Create a border around the "nextpanel"
Border etched =
tched =
BorderFactory.createBevelBorder(BevelBorder.RAISED,
Color.black, Color.blue);
Border titled =
itled = BorderFactory.createTitledBorder(etched,
"Please provide a title to your project");
topPanel.setBorder(titled);
// Create a border around the "lowerpanel"
Border etched1 =
ched1 =
BorderFactory.createBevelBorder(BevelBorder.RAISED,
Color.black, Color.blue);
Border titled1 =
tled1 = BorderFactory.createTitledBorder(etched1,
"Please select the duration of your project");
lowerPanel.setBorder(titled1);
// initialise label objects
projectNameLabel = new JLabel("Project Name",
Name", JLabel.LEFT);
maxCharacterLabel = new JLabel("(Max 20
(Max 20 Chars)");
durationLabel = new JLabel("Duration (in
ion (in months)", JLabel.LEFT);
monthLabel = new JLabel("1 - 12 months");
projectName = new JTextField("Default Name",
Name", 20);
projectName.setColumns(15);
topPanel.validate();
projectDuration = new JComboBox();
projectDuration.setEditable(false);
projectDuration.addItem("1");
projectDuration.addItem("2");
projectDuration.addItem("3");
projectDuration.addItem("4");
projectDuration.addItem("5");
projectDuration.addItem("6");
projectDuration.addItem("7");
projectDuration.addItem("8");
projectDuration.addItem("9");
projectDuration.addItem("10");
projectDuration.addItem("11");
projectDuration.addItem("12");
// initialise buttons
okButton = new JButton("Ok", new
k", new ImageIcon("Test/ok.gif"));
cancelButton = new JButton("Cancel", new
l", new ImageIcon("Test/cancel.gif"));
// add objects to panels
topPanel.add(projectNameLabel);
topPanel.add(projectName);
topPanel.add(maxCharacterLabel);
lowerPanel.add(durationLabel);
lowerPanel.add(projectDuration);
lowerPanel.add(monthLabel);
buttonPanel.add(okButton);
buttonPanel.add(cancelButton);
// create instance of cancelButtonListener
CancelButtonListener cancelListen = new
n = new CancelButtonListener(wizardFrame);
// add actionListener for the cancel button
cancelButton.addActionListener(cancelListen);
// use Box layout to arrange panels
Box hbox2 = Box.createHorizontalBox();
hbox2.add(topPanel);
Box hbox4 = Box.createHorizontalBox();
hbox4.add(lowerPanel);
Box hbox5 = Box.createHorizontalBox();
hbox5.add(buttonPanel);
Box vbox = Box.createVerticalBox();
vbox.add(hbox2);
vbox.add(Box.createGlue());
vbox.add(hbox4);
vbox.add(Box.createGlue());
vbox.add(hbox5);
this.add(vbox, BorderLayout.NORTH);
private class CancelButtonListener implements
nts ActionListener
public CancelButtonListener(JFrame
(JFrame awizardFrame)
public void actionPerformed(ActionEvent
onEvent event)
Object source = event.getSource();
if(source == cancelButton)
NewChartTest.instance.wizardFrame.setVisible(false);
// Main entry point into the ToolBarPanel class
public static void main(String[] args)
// Create a frame to hold us and set its
set its title
JFrame frame = new JFrame("New Chart
w Chart Wizard");
// Set frame to close after user request
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Add our tab panel to the frame
NewWizardPanel nwp = new NewWizardPanel();
frame.getContentPane().add(nwp,
dd(nwp, BorderLayout.CENTER);
// Resize the frame
frame.setSize(680, 480);
// Make the windows visible
frame.setVisible(true);

Similar Messages

  • I have Windows 7 and PS Elements 10 and can't get the text button to work properly.  What can I do?

    I have Windows 7 and PS Elements 10 and can't get the text button to work properly.  What can I do?

    Try selecting the T tool and then doing a reset (see image below)

  • Answer: to How can I get the reset button to work.

    How can I get the reset button to work?: Answer
    Thanks to everyone who helped on this. You are awesome. Especially Ned!!  Posted here because I was unable to add more to the existing post.
    Here is the question:
    When you click on the reset button, this error below comes up. If you can't find the button it is the navy colored rectangular thing in the lower left corner of page.
    ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
        at flash.display::DisplayObjectContainer/removeChild()
        at AddATree2/onReset()
    When you click on the reset button, this error below comes up. If you can't find the button it is the navy colored rectangular thing in the lower left corner of page.
      Here is the answer:
    //when you click the reset button everything is removed from the stage
        //except the star, baclground, and reset button (trees and greeting REMOVED)
        public function onClear(Event:MouseEvent):void
                if (tree3) removeChild(tree3);
                if (tree2) removeChild(tree2);
                if (webText) removeChild(webText);
                if (tree) removeChild(tree);
                clickCount = 0;

    This is the answer to what to put in the onclear function.

  • HT5012 How do I get the meddle button to work on my iphone

    How do I get the meddle button to work on my iPhone

    I Cannot use the meddle button on my p
    iPhone

  • Issues with getting the slide button to work after upgrade to iOS 7.02 and 7.03

    Ever since upgrading to iOS 7.02 and 7.03 having issues with getting the slide button to work to open up iPad 2.  Happened last week and was able to restore it to new and get it to work again and it worked great until one week later (this morning) doing the same thing.  Have tried restoring iPad to new 3 times (via itunes) and still unable to get the slide button to move so can use the iPad.  IPad able to charge, able to restore, able to sync with itunes even able to recover but not able to get past first screen where you have to slide to access iPad.  Any help would be greatly appeciated.  Live about 300 miles from nearest Apple store.

    I am beginning to wonder whether there isn't some weird problem with that Home button.
    Try this: Settings > General > Accessibility > AssistiveTouch = On
    This will place a button on the iPad's screen.
    You can move this button anywhere on the screen.
    This button gives you - amongst many other things - a soft Home button.
    To turn your iPad on, you can use the Sleep/wake button or move a small magnet across the bezel of the iPad where the volume controls are.
    If you use the magnet, then: Settings > General > Lock / Unlock = On
    Now should not need to press the Home button anymore.
    If this method allows you to use your iPad without a hitch, then suspect hardware problems with the Home button.

  • Tecra A11 - Cannot get the FN buttons to work on Win 7

    I had to do a new install of Windows 7 on my Tecra A11.
    Everything works fine but, I am finding that I really really miss the ability to turn the trackpad on and off and turn the wireless on and off.
    I'm guessing that the only way to do this would be to reinstall that program that connects the FN key to the numbered Function Keys.
    I don't know what to call it so I don't know what to search for. I do want to be careful and not install more than I need.
    Is there a program or way I can get this function reinstalled?
    Thanks,
    Susan
    p.s. On this fine forum, I found how to turn the track pad off when a mouse is installed but if I don't have a mouse attached and this is turned off, I'm kind of in a mess :)

    Hi
    The FN buttons are controlled by VAP (value added package) and the Flash Card Support Utility.
    Install the VAP firstly and check if the FN buttons would work. If this is will not work then you should try also the Flash Card Support Utility to get this FN buttons working.
    The Flash Card Support can be found in Satellite L500 or other later series
    Greets

  • Getting the exit button to work

    ....how do I get this exit button to work on my posted project please.
    Currently is does not close down the "movie" so I have to have a slide telling users
    to close their tab/window/browser to exit.
    Many thanks in anticipation
    Grandpa70

    Hi there
    Please take a look at the link below.
    Click here to view
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • Can't get the Submit button to work on Acrobat X

    I was having this problem on Acrobat 9 and so I bit the bullet and upgraded, hoping the problem would go away, but it did not.
    I have a simple form for an event which recipients will fill out and submit, emailing the entirePDF to others (not to me)
    I've done these forms a zillion times, no problemo, but this is the first time I've tried since upgrading from Entourage email to Outlook, and I have a sneaking suspicion the problem lies there somehow.
    Can install the button, all fine, but when I click it to test, I get this message:
    "An error occured while trying to create a mail document. Acrobat is unable to complete your request."
    Anybody know what I can do to fix this?
    signed,
    Desperate

    I gave up on the 'Submit' button long ago, as have others, I suspect.
    It fails in about half of the cases.
    Now I place a note at the top of the form instructing users how to manually attach the form to an email in case the button doesn't work – it's ridiculous. Thinking about it, it would be more clean-cut to get rid of the button alltogether.
    I also keep getting requests to provide forms as Word documents instead. Apparently people are way more comfortable with Word than willing to deal with idiosyncrasies in PDFs.

  • Sennheiser MM50s with iPhone - can't get the voice button to work :(

    Can anybody advise?
    I am on the latest iPhone OS. The headphones are brand new and sound great - but the voice/music control button does nothing but switch one speaker off while I hold it.
    Any advice welcome. I've cleaned the earbud socket with surgical spirit and my original headset works perfectly.
    Thanks.
    Steve

    Sorry if my answer confused.
    I don't mean you need to use excessive force to push it home, but I do need to make sure the connector is all the way in and that it's easy to leave it nearly-but-not-quite home, and when that's the case the mic button doesn't work.
    I've just tried quantifying it. From the front of the iPhone, when the headphones are all the way in there's no more than 0.5mm of gold connector showing. But with as little as 1.0mm showing, the mic button doesn't work, although sound does in both ears (and sometimes it's louder than normal too).
    (Because of the curve on the iPhone, there's a good 1-2MM of connector showing at the back even when fully inserted)
    If you're confident the connector is as far in as it'll go without damaging something, then it sounds like you've got either something in the connector slot of the iPhone or duff headphones. Do the buttons on the stock iPhone headphones work for you? That would narrow down the problem for you...
    PS: you don't need to push-and-hold; that launches Voice Control. A short but confident stab should play/pause; two quick pushes will skip a track, and 3 quick ones will go back to the start of the current track or go to the previous track if you were already near the start. I found the button on the MM50s a bit un-ergonomic in position and operation to start with but I'm getting more confident with knowing I've hit it now. There can be a 1-2 second delay between hitting the button and getting an effect though.

  • How can I get the reset button to work?

    When you click on the reset button, this error below comes up. If you can't find the button it is the navy colored rectangular thing in the lower left corner of page.
    ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
        at flash.display::DisplayObjectContainer/removeChild()
        at AddATree2/onReset()
    Here is the code:
    THERE IS AN ATTACHED .FLA AND 3 AS FILES, RESET, TREE, AND ADDATREE2
    Appreciate your thoughts!  w_sights
    ADDATREE2.AS
    /* AS3
        Copyright 2008 __MyCompanyName__.
    package
         *    Class description.
         *    @langversion ActionScript 3.0
         *    @playerversion Flash 9.0
         *    @author
         *    @since  19.05.2009
        import flash.display.Sprite;
        import flash.display.MovieClip;
        import flash.events.MouseEvent;
        import flash.events.Event;
        import flash.utils.Timer;
        import flash.text.TextField;
        import flash.text.TextFormat;
        import flash.text.StyleSheet;
        import Reset;
        import Tree;
        public class AddATree2 extends MovieClip {
            // CLASS CONSTANTS
             //  CONSTRUCTOR
             *    @Constructor
            public function AddATree2(){
                reset.addEventListener( MouseEvent.CLICK, onReset ) ;
                reset.buttonMode = true ;
                reset.mouseChildren = false;
                mcAdd.addEventListener ( MouseEvent.CLICK , onClick ) ;
                mcAdd.buttonMode = true ;
                mcAdd.mouseChildren = false;
                //var reset_btn:reset = new reset();
            //  PRIVATE VARIABLES
                private var clickCount:Number = 0;
            //  PUBLIC VARIABLES
                public var reset:MovieClip = new MovieClip();
            //  GETTER/SETTERS
            //  PUBLIC METHODS
            //  EVENT HANDLERS
            private function onClick ( evt : MouseEvent ) : void
                clickCount++;
                switch(clickCount)
                    case 1:
                            var tree = new Tree ( ) ;
                            addChild ( tree ) ;
                            tree.x = 430;
                            tree.y = 300;
                            tree.scaleX = .95;
                            tree.scaleY = .95;
                            var brickham:BrickhamScriptProBMP = new BrickhamScriptProBMP();
                            var fmt:TextFormat = new TextFormat();
                            fmt.font =  brickham.fontName;
                            fmt.size = 58;
                            /*var regularText:TextField =  new TextField();
                            regularText.autoSize = "left";
                            regularText.embedFonts = true;
                            regularText.defaultTextFormat = fmt;
                            //regularText.text = "Merry Christmas"
                            addChild(regularText);
                            var css:StyleSheet = new StyleSheet();
                            css.setStyle("p", {fontFamily:brickham.fontName, fontSize:78,color:"#FFFFFF"});
                            //css.setStyle("a", {textDecoration:"underline"});
                            var webText:TextField = new TextField();
                            webText.autoSize = "left";
                            webText.embedFonts = true;
                            webText.styleSheet = css;
                            webText.htmlText = "<p>Merry Christmas</p>";
                            webText.x = 52;
                            webText.y = 41;
                            addChild(webText);
                            break;
                    case 2:
                            var tree2 = new Tree();
                            addChild(tree2);
                            tree2.x = 175;
                            tree2.y = 450;
                            tree2.scaleX = .65;
                            tree2.scaleY = .65;
                            break;
                    case 3:
                            var tree3 = new Tree();
                            addChild(tree3);
                            tree3.x = 45;
                            tree3.y = 365;
                            tree3.scaleX = .45;
                            tree3.scaleY = .45;
                            break;
               /*     case 4:
                            var tree4 = new Tree();
                            addChild(tree4);
                            tree4.x = 660;
                            tree4.y = 195;
                            tree4.scaleX = .25;
                            tree4.scaleY = .25;
                            break;
            //mcAdd.removeEventListener ( MouseEvent.CLICK , onClick ) ;
            //  PRIVATE & PROTECTED INSTANCE METHODS
            /*reset_btn.addEventListener(MouseEvent.CLICK, resetButton);*/
            function onReset(event:MouseEvent)
                var webText:TextField = new TextField();
                var reset:MovieClip = new MovieClip();
                reset.x = 450;
                reset.y = 500;
                reset.scaleX = .01;
                reset.scaleY = .01;
                addChild(reset);
                stage.addEventListener(MouseEvent.CLICK, removeWebText);
                var tree = new Tree();
                removeChild(tree);
                var tree2 = new Tree();
                removeChild(tree2);
                var tree3 = new Tree();
                removeChild(tree3);
            public function removeWebText(event:MouseEvent):void
                var webText:TextField = new TextField();
                var fmt:TextFormat = new TextFormat();
                removeChild(webText);
    TREE.AS
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        public class Tree extends MovieClip
            function Tree()
                addEventListener ( Event.ADDED_TO_STAGE , onAddedToStage ) ;
            private function onAddedToStage ( evt : Event ) : void
                width = stage.stageWidth ;
                height = stage.stageHeight ;
    RESET.AS
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        public class Reset extends MovieClip
            function Reset()
                addEventListener ( Event.ADDED_TO_STAGE , onAddedToStage ) ;
            private function onAddedToStage ( evt : Event ) : void
                width = stage.stageWidth ;
                height = stage.stageHeight ;

    Hello:
    Thank you for responding so quickly.
    I have added child and it has removed the error. However, the button icon has disappeared as you can see when you play the .swf and the reset button doesn't clear the stage of everything but the star and the back ground.
    See new code:
    /* AS3
        Copyright 2008 __MyCompanyName__.
    package
         *    Class description.
         *    @langversion ActionScript 3.0
         *    @playerversion Flash 9.0
         *    @author
         *    @since  19.05.2009
        import flash.display.Sprite;
        import flash.display.MovieClip;
        import flash.events.MouseEvent;
        import flash.events.Event;
        import flash.utils.Timer;
        import flash.text.TextField;
        import flash.text.TextFormat;
        import flash.text.StyleSheet;
        import Reset;
        import Tree;
        public class AddATree2 extends MovieClip {
            // CLASS CONSTANTS
             //  CONSTRUCTOR
             *    @Constructor
            public function AddATree2(){
                reset.addEventListener( MouseEvent.CLICK, onReset ) ;
                reset.buttonMode = true ;
                reset.mouseChildren = false;
                mcAdd.addEventListener ( MouseEvent.CLICK , onClick ) ;
                mcAdd.buttonMode = true ;
                mcAdd.mouseChildren = false;
                //var reset_btn:reset = new reset();
            //  PRIVATE VARIABLES
                private var clickCount:Number = 0;
            //  PUBLIC VARIABLES
                public var reset:MovieClip = new MovieClip();
            //  GETTER/SETTERS
            //  PUBLIC METHODS
            //  EVENT HANDLERS
            private function onClick ( evt : MouseEvent ) : void
                clickCount++;
                switch(clickCount)
                    case 1:
                            var tree = new Tree ( ) ;
                            addChild ( tree ) ;
                            tree.x = 430;
                            tree.y = 300;
                            tree.scaleX = .95;
                            tree.scaleY = .95;
                            var brickham:BrickhamScriptProBMP = new BrickhamScriptProBMP();
                            var fmt:TextFormat = new TextFormat();
                            fmt.font =  brickham.fontName;
                            fmt.size = 58;
                            /*var regularText:TextField =  new TextField();
                            regularText.autoSize = "left";
                            regularText.embedFonts = true;
                            regularText.defaultTextFormat = fmt;
                            //regularText.text = "Merry Christmas"
                            addChild(regularText);
                            var css:StyleSheet = new StyleSheet();
                            css.setStyle("p", {fontFamily:brickham.fontName, fontSize:78,color:"#FFFFFF"});
                            //css.setStyle("a", {textDecoration:"underline"});
                            var webText:TextField = new TextField();
                            webText.autoSize = "left";
                            webText.embedFonts = true;
                            webText.styleSheet = css;
                            webText.htmlText = "<p>Happy Happy</p>";
                            webText.x = 52;
                            webText.y = 41;
                            addChild(webText);
                            break;
                    case 2:
                            var tree2 = new Tree();
                            addChild(tree2);
                            tree2.x = 175;
                            tree2.y = 450;
                            tree2.scaleX = .65;
                            tree2.scaleY = .65;
                            break;
                    case 3:
                            var tree3 = new Tree();
                            addChild(tree3);
                            tree3.x = 45;
                            tree3.y = 365;
                            tree3.scaleX = .45;
                            tree3.scaleY = .45;
                            break;
               /*     case 4:
                            var tree4 = new Tree();
                            addChild(tree4);
                            tree4.x = 660;
                            tree4.y = 195;
                            tree4.scaleX = .25;
                            tree4.scaleY = .25;
                            break;
            //mcAdd.removeEventListener ( MouseEvent.CLICK , onClick ) ;
            //  PRIVATE & PROTECTED INSTANCE METHODS
            /*reset_btn.addEventListener(MouseEvent.CLICK, resetButton);*/
            function onReset(event:MouseEvent)
                var webText:TextField = new TextField();
                var reset:MovieClip = new MovieClip();
                reset.x = 450;
                reset.y = 500;
                reset.scaleX = .01;
                reset.scaleY = .01;
                addChild(reset);
                stage.addEventListener(MouseEvent.CLICK, removeWebText);
                var tree = new Tree();
                addChild(tree)
                var tree2 = new Tree();;
                addChild(tree2);
                var tree3 = new Tree();
                addChild(tree3);
                removeChild(tree);
                removeChild(tree2);
                removeChild(tree3);
            public function removeWebText(event:MouseEvent):void
                var webText:TextField = new TextField();
                var fmt:TextFormat = new TextFormat();
                addChild(webText);
                removeChild(webText);
    ===============
    TREE.AS
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        public class Tree extends MovieClip
            function Tree()
                addEventListener ( Event.ADDED_TO_STAGE , onAddedToStage ) ;
            private function onAddedToStage ( evt : Event ) : void
                width = stage.stageWidth ;
                height = stage.stageHeight ;
    RESET.AS
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        public class Reset extends MovieClip
            function Reset()
                addEventListener ( Event.ADDED_TO_STAGE , onAddedToStage ) ;
            private function onAddedToStage ( evt : Event ) : void
                width = stage.stageWidth ;
                height = stage.stageHeight ;

  • How do i get the SUBMIT Button to work

    I added the SUBMIT button to a form that is to be emailed. When I tested it on my other email account, I was able to complete the form, but when I clicked the SUBMIT button, nothing happens.

    I added the SUBMIT button to a form that is to be emailed. When I tested it on my other email account, I was able to complete the form, but when I clicked the SUBMIT button, nothing happens.

  • I cant get the tab button to work and open a new tab for new web site?

    i try to click on the plus sign to open a new tab and also right click mouse to open new tab and nothing works.

    # Go to Tools, Addons, Extensions,
    # select Ask Toolbar,
    # click uninstall or disable,
    # restart Firefox.
    Please let us know whether that solves the issue.

  • TS3297 hi. I am trying to change my billing address in itunes but it is not letting me do this. When I go to edit, I see only the 'cancel' button at the bottom of the page, no 'done' button to make changes. Why? I am a US registered itunes user but live o

    hi all. Hope someone can help me because I'm getting very frustrated and not finding answers! I am trying to change my billing address in my itunes store account, but itunes is not allowing me to do this. At the bottom of the page, I only get the 'cancel' button, no 'done' button to make changes. I am using an HP mini, and am a registered US itunes account holder, living outside the US right now (East Timor to be precise).
    Why won't the store let me change my info? I'm not having any other problems.

    The possible reasons are:
    1. Store credits in your account
    2. Pending downloads
    For more information contact iTunes Customer Support:
    http://www.apple.com/support/itunes/contact/

  • Why does the delete button not work in iPhoto

    How can I get the delete button to work in iPhoto?

    Have you tried deleting the app from your history, and restarting it? (Otherwise --> restart/reset the iPad)

  • I am walking through Apples tutorial getting started with iOS development. I am at the storyboard area and can't seem to drag the cancel button to the green exit. I am not sure why the exit button doesn't except it. Is anyone else having this issue?

    I am walking through Apples tutorial getting started with iOS development. I am at the storyboard area and can't seem to drag the cancel button to the green exit. I am not sure why the exit button doesn't except it. Is anyone else having this issue? Is there a work around? I have done this app twice and still cant get the exit to except the Cancel or Done  bar buttons

    Yes I checked it.  As far as I can see I did everything Apple said to do.  I took some screen shot so you can see how the screens are connected and what and where the code is, and what it does when I drag the cancel and done bar buttons to the exit

Maybe you are looking for

  • Adobe 9.3 Extract help

    I have Adobe Acrobat Reader 9.3 standard version.  I want to open a pdf file and extract a couple of pages and save as a pdf file.  I looked for directions on this and everyone says to tab "document" and select extract and then....  WELL  I dont have

  • How to do web services between two applications

    I have tried to get a complete example about how to do a web service between two applications in ADF but I saw all the put examples that describe only how to do a web service and test it in the same application. Please, I want to see a whole example

  • Can't synch Ipod because not enough memory

    I just bought an iPod Classic.  When I tried to synch it showed about 80 GB of data, but I got the message, " The XXXXX iPod can not be synchged .  There is not enough memory available.  Anybody have an idea of what is going on? 

  • Guitar Rig  and Logic Studio

    The Guitar Rig that is in MainStage; How do I insert that into a Logic Studio 8 track? I'm assuming I'd start with an Audio track as opposed to MIDI. Just can't seem to locate the Guitar Rig - only Guitar Amp Pro. Thanks

  • Manually configure icloud for mail in OSX 10.6.8

    Hi Running SnowLeopard on an iMac. Still using Quicken 2007 which needs rosetta. Previously getting mail [MobileMe] worked perfectly. Now no longer so. Can anyone advise on how to manually enter an email account in SnowLeopard to access iCloud please