Writing a Button Class

I'm sure this is real easy but I'm a bit of a newbie so I'm
still working out my MovieClip methods from my Stage methods.
Basically, I need to write code for a button class I call
NextButton.as which on a Mouseclick will move the stage along by 5
frames to the next page in my presentation. I've tried to do this
by writing things like this in my onClick method:
gotoAndStop(stage.currentFrame + 5);
But it doesn't like that at all because gotoAndStop is a
method of the MovieClip class but not the Stage class.
So I need to get a MovieClip to move the STAGE along 5 frames
to the next page in my presentation.
My only other option is to forget the button class altogether
and write code in every 5 pages of my frame, giving each "NextPage"
function a different name like NextPage1, NextPage2, NextPage3. I'm
sure there's a more intelligent way to do this! I'm too stubborn to
give in!!
Many thanks,
Marc

hi ofeet,
It comes back and says:
1061: Call to a possibly undefined method gotoAndStop through
a reference with static type flash.display:DisplayObject.
AND
1119: Access of possibly undefined property currentFrame
through a reference with static type flash.display:DisplayObject.
I've imported the following at the top under package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.display.Stage;
import flash.display.DisplayObject;
Don't know if I have to import anything else. Any
clues?

Similar Messages

  • Creating a dynamic button class

    Hi all. I'm trying to create a button class that has some
    properties such as scale that can be coded at runtime. The tutorial
    I found hard codes the scale amount into the class, but I would
    like to be able to create a new instance of the button class in
    Flash, and say on the main timeline, define my variables for
    scale...and pass these to the class file. I'm running into an
    "1120" error message. I have attached the original working code.
    Thanks.

    Thanks. I'm having trouble finding a clear tutorial that I
    can understand on this topic. I've tried creating a set function
    but not sure where to write the get function. I have attached my
    class file and my call to it in the main timeline. I've been
    struggling with learning custom classes and appreciate any help!
    Also, I am now creating a new instance on the main timeline
    instead of linking to it in the library. What is the best way of
    doing this.

  • Using two Button classes for single Button control MFC

    Hi,
    Here is my problem:
    I have a VC++ MFC dialog based application. There I am adding a Button to my dialog by just drag and drop from the tool box.
    I am also having a MyCustomButton.dll to give new looks to the button.
    Inside MyCustomButton.dll, MyCustomButton.cpp is the button class which is derived from CButton. 
    Now I want the behavior of my application in such a way at execution of my application, like if the  MyCustomButton.dll is present in system then the button of my dialog should look like as per implementation of MyCustomButton.dll, where as if the dll
    is not present normal MFC button should get displayed.
    Please guide me in achieving this. How can I make my application (*.exe) decide at run time.
    Thanks in Advance,
    Thanks & Regards, Mayank Agarwal

    Thanks Rupesh,
    But my requirement is like that only I have to decide at run time.
    Please look the scenario below:
    //  MyDialogDlg.h //
    #include "MyCustomButton.h"
    class MyDialogDlg
    MyCustomButton m_CalcButton;
    In the above piece of code
    m_CalcButton is object of  MyCustomButton class.
    and my requirement is such that if MyCustomButton
    .dll is not present then,  m_CalcButton should executed as the object of CButton class of MFC.
    There are cases where I  cant ship the dll.
    In such case how should I write the code? Please guide.
    Thanks in Advance.  
    Thanks & Regards, Mayank Agarwal

  • Extending button class

    Hello all,
    I am trying to extend the button class to include the ability
    to click the button when a user presses the enter key on the
    keyboard. I do not know how I would go about doing this. There are
    two private functions that control the press and release of the
    button; buttonPressed() and buttonReleased(), along with a private
    property ButtonPhase that seem to control this functionality. At
    first I thought I would override the keyDownHandler and the
    keyUpHandler, as they allow the user to click the button with the
    space bar, but it won't work with the private functions and
    property. Any ideas on how I could achieve this goal without having
    to copy and alter the original button class would be greatly
    appreciated. Does anybody know why the developers chose to have the
    button click when the space is hit instead of the enter key? It
    seems to me that the enter key is a much more intuitive keyboard
    shortcut than the space bar.
    Thanks for your help

    I recently had the same problem extend the Button class and
    override the two methods as follows
    override protected function
    keyDownHandler(event:KeyboardEvent):void
    super.keyDownHandler(event);
    if (event.keyCode == Keyboard.ENTER)
    this.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
    override protected function
    keyUpHandler(event:KeyboardEvent):void
    super.keyUpHandler(event);
    if (event.keyCode == Keyboard.ENTER)
    this.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_UP));
    }

  • Default skin for spark button class

    Hi, where in the spark button class or superclasses does it specify its default skin?

    Spark components like Button.as don't define thier default skins internally. If you want a skinnable component to have a default skin so that you don't have to  manually specify the skin every time you have two options. The preferred method, and the one used in the flex sdk, is to use a css file to specify the skin for the component. If you don't want to do that, then the other option is to call setStyle("skinClass", YourSkinClass) inside the constructor of the actionscript component.

  • Button class not creating a button

    Hi,
    I have some AS3 code which I was hoping would create a
    re-usable button class but it does not. I just get a blank canvas.
    I am not getting any errors. Code is attached. Anyone see what is
    wrong?

    thanks for the response.
    to instantiate this class with the var code that you posted
    and I reposted. Would this code be added to the .as file or would I
    put that on frame 1 of the .fla file?
    Also I want to create multiple buttons and position them on a
    page within a grid. With the class code I have posted, how would I
    go about doing that? Lastly, I want one of two movie clips to
    display once the button is clicked. Can someone explain how I would
    go about that as well?
    thanks

  • HtmlB button class...?

    Hi, I'm studying htmlb buttons and I'm wondering why there is a difference between:
    <b><hbj:button id="button" text="Go"/></b>
    and
    <b><input type="button" class="urBtnStd" value="Go"></b>
    I checked the source of the iView that had the htmlB button, and saw that it used the urBtnStd class, so I used it using regular html.  However, for some reason it doesn't look quite the same.  I'm curious to see if there a way to make them identical?
    Thanks so much,
    Baggett.

    Hi Ville, thanks for your response, this is the short code that I have:
    <b><%@ taglib uri="tagLib" prefix="hbj" %>          
    <hbj:content id="myContext" >
      <hbj:page title="Index Page">
         <hbj:form id="myFormId">
         <br>
         <hbj:gridLayout width="100%" cellPadding="5">
         <hbj:gridLayoutCell rowIndex="1" columnIndex="1" style="title" horizontalAlignment="LEFT">
              <hbj:button id="button" text="Go to page" onClick="Go to page"/>
         </hbj:gridLayoutCell>
         <hbj:gridLayoutCell rowIndex="5" columnIndex="2" style="" horizontalAlignment="LEFT">     
              <input type="button" class="urBtnStd" ct="Button" style="white-space:nowrap;" value="Go to page">
         </hbj:gridLayoutCell>
         </hbj:gridLayout>     
         </hbj:form>
      </hbj:page>
    </hbj:content></b>
    You could just copy and paste this code and check it out.  Basically, I looked at the source of the htmlb from my browser and tried to use it's class for my regular html button.
    Thanks so much,
    Baggett

  • Writing java bean class?

    Hi All,
    In my scenario,I am getting all pagelevel details from the database.
    I mean Suppose in my web application 10 pages are there.for 10 pages, all details (like page title,button names,page header etc) based on user.per user it will vary .Some body have insert,update buttons ,some body not.
    I was created java bean with static getters and setters for all pages to get the data and store.
    I don't want to connect to the database to get the page details per every page.so,
    its working for me.what happen if more than one user access the application.The details will effect to all when new user enter into the system?
    any suggestions.....................................????
    if I write non - static getters and setters ,I need to instantiate everypage.
    its takes more memory ,In my web application I have above 75 pages.
    solution???

    1)So,I need to pass the Class object to the
    session.setAttribute()
    right?
    Well to be precise - you create an instance of the class (object) for each registered and logged in user and then yes - store the object as a session attribute
    >
    2)Suppose I change my bean to instance bean,bean have
    above 20 instance variables .I think performance
    point of view,Its not good.
    Because,if users are more than 20 what happend?
    You should probably think about 200 :). 20 users is not an issue wwhen you have sufficient hardware.
    One option would be to store the user permission/preferences in the db and associate it with the user id. Infact for large applications that hold lots of user related data per user, that would be my preferred approach.
    ram.

  • Writing a whole class instance to a file

    Is it possible to write an intance of a class to a file whole?
    My problem is as follows I have a complicated class system for the piece of software i am currently writing this has vector classes upon vector classes upon vector classes etc. The top class is called rulelist. Having created an instance of this class in the main method and added various instances of other classes to it i want to be able to save this instance on exiting the program. I know how to write individual pieces of data to a file but is there an easier way to do this than to save all the data individualy and then re-sort it out when loading the instance again?
    Please help
    Will

    Sun has some tech tip articles on serialization:
    http://developer.java.sun.com/developer/JDCTechTips/
    Do a search for 'serialization' on this webpage.

  • Creating a Button Class from MC

    I have a few simple questions for those who know about
    classes. I have been reading the tutorials on creating classes and
    specifically extending the MC class. I am pretty sure that an
    extended MC_Class might help me get what I need from my project.
    I essentially have a bunch of buttons, hundreds to be exact -
    and the exact number needs to be dynamic. Each one is currently a
    static MC with a bunch of variables assigned to each one via global
    variables. Its iis pulling in data taht assign the button values
    from XML files and - these XML files may change.
    Q1. If I extend the MC class so I can add attributes to MC's
    instance (Avoiding global variables) - will it mess with the rest
    of the movie clips in my scene? I mean if all I want to do is ad a
    a few dynamic string variables - it really shouldnt effect any of
    the other clips would it? MC.JumpURL = "newurl.com", MC.Thumnail
    ="/here/image.jpg" (This would help alot)
    Q2. What if I wanted to define actions of the new MC in the
    class? If the MC is an extension of the MC class. Would all of my
    MC's automatically take on the actions of the custom MC Class? For
    instance - I want the movieclip to animate onscreen and have
    rollover effects. I could do this easy if it were static - but I
    need this to become dynamic. Also - there are now unknown
    quantities to deal with
    Q3. How exactly would I call and assign the MC its atributes
    at the same time? And how do I specify this MC to use the functions
    defined in the class and not the other MC's I created elsewhere in
    the File.
    Example. Currently I have a grid of MCs' created when the
    User clicks a menu item (Another type of MC).
    Each new MC animates onstage - it calls a
    loadMovie(_root.thumb[0], this.Flipper) to assign and embedded MC
    an image defined in the XML that was loaded and assigned because I
    placed the instance on stage and wrote a MC script on each MC.
    Confused - check out what I am creating at
    www.vincesidwell.com/Fischer
    Click Fabrication or TurboSystems menus. Both menues will
    load a new set of Thumbnails at the bottom. They are loaded via an
    XML loaded by the menu and a function assigns the jpgs for the main
    gallery, Rollover image, and eventually a URL for a downloadable
    High Res Image.
    The client recently added more than 9 images per menu item. I
    will need to create a scrollable thumbnail gallery with dynamic
    quantities
    I can manually create the MC Scroller item for static number
    of buttons. But scripting an unknown for each ones links and images
    is insane. So I am looking at Classes. Assign a custom class for
    the flipping buttons and I should be able to assign tthem as the
    XML loads, and have it automatic. (pray please please please)
    Anyhelp?
    Thanks
    Vince Sidwell

    Hi there!
    I'll try and give some answers to your questions below...
    "vin-E" <[email protected]> wrote in message
    news:[email protected]...
    >I have a few simple questions for those who know about
    classes. I have
    >been
    > reading the tutorials on creating classes and
    specifically extending the
    > MC
    > class. I am pretty sure that an extended MC_Class might
    help me get what
    > I
    > need from my project.
    >
    > I essentially have a bunch of buttons, hundreds to be
    exact - and the
    > exact
    > number needs to be dynamic. Each one is currently a
    static MC with a
    > bunch of
    > variables assigned to each one via global variables. Its
    iis pulling
    > in
    > data taht assign the button values from XML files and -
    these XML files
    > may
    > change.
    >
    > Q1. If I extend the MC class so I can add attributes to
    MC's instance
    > (Avoiding global variables) - will it mess with the rest
    of the movie
    > clips in
    > my scene? I mean if all I want to do is ad a a few
    dynamic string
    > variables -
    > it really shouldnt effect any of the other clips would
    it? MC.JumpURL =
    > "newurl.com", MC.Thumnail ="/here/image.jpg" (This would
    help alot)
    You do not have to create a new MC class to assign local
    values or functions
    to it. A pseudo code example:
    Loop through total buttons you want to make (which can be
    number of entries
    in an XML file)
    Create a new movieclip and load the button graphic into
    this, give it a
    name like
    MyButtonX, where X is an increasing number based on which
    button this
    is. (Instead of creating
    and empty movielcip, you could also attach a movie (or
    button) from
    library.
    Assign the values and create the functions for this button
    that you
    would like (probably based
    on information in the XML file):
    MyButtonX.someVariable = node.attribues.someData;
    createOnRelease(MyButtonX, someOtherParamters)
    (where you have defined the function createOnRelease to do
    something
    like
    function createOnRelease(MC, someOtherParameteres) {
    MC.onRelease = function() {
    do what you want to do based on someOtherParameteres
    Position and resize MyButtonX
    In your example you have a 3x3 grid, which might extend to
    3xTOTAL,
    so you'd have to use some
    mathematical formula based on the value X, something like
    MyButtonX._x =
    (((X-1)%3)*(buttonWidths+hSpaceBetweenButtons)
    MyButtonY._y = Math.floor((X-1)/3)*(buttonHeights
    +vSpaceBetweenButtons
    end of loop.
    >
    > Q2. What if I wanted to define actions of the new MC in
    the class? If
    > the MC
    > is an extension of the MC class. Would all of my MC's
    automatically take
    > on
    > the actions of the custom MC Class? For instance - I
    want the movieclip
    > to
    > animate onscreen and have rollover effects. I could do
    this easy if it
    > were
    > static - but I need this to become dynamic. Also - there
    are now unknown
    > quantities to deal with
    If you actually create a new class, than all instances of
    that class will
    have the methods you define for it (just like all instances
    of a movieclip
    has those methods. At least, have them available. That
    doesn't mean they are
    always in use ... like for example the onRollOver. But again,
    you don't need
    to create a class to give all your dynamically created
    buttons a rollover
    effect. (Check code above).
    > Q3. How exactly would I call and assign the MC its
    atributes at the same
    > time? And how do I specify this MC to use the functions
    defined in the
    > class
    > and not the other MC's I created elsewhere in the File.
    You use the instance name of the MC to access that MC and its
    attributes/methods. For example button number 10 might look
    like this:
    trace(MyButton10._x);
    trace(MyButton10.someVariableYouHaveDefined);
    MyButton10.callSomeFunctionYouHaveDefined();
    For a movieclip to access a variable that has been defined
    for that instance
    of the movieclip, use "this" to point to that particular
    instance. So if we
    defined the function "callSomeFunctionYouHaveDefined" for
    button number 10
    and want to access "someVariableYouHaveDefined" for this
    particular
    instance, then
    MyButton10.callSomeFunctionYouHaveDefined = function() {
    trace(this.someVariableYouHaveDefined);
    > Example. Currently I have a grid of MCs' created when
    the User clicks a
    > menu
    > item (Another type of MC).
    > Each new MC animates onstage - it calls a
    loadMovie(_root.thumb[0],
    > this.Flipper) to assign and embedded MC an image defined
    in the XML that
    > was
    > loaded and assigned because I placed the instance on
    stage and wrote a MC
    > script on each MC.
    >
    > Confused - check out what I am creating at
    www.vincesidwell.com/Fischer
    >
    > Click Fabrication or TurboSystems menus. Both menues
    will load a new set
    > of
    > Thumbnails at the bottom. They are loaded via an XML
    loaded by the menu
    > and a
    > function assigns the jpgs for the main gallery, Rollover
    image, and
    > eventually
    > a URL for a downloadable High Res Image.
    >
    > The client recently added more than 9 images per menu
    item. I will need
    > to
    > create a scrollable thumbnail gallery with dynamic
    quantities
    >
    > I can manually create the MC Scroller item for static
    number of buttons.
    > But
    > scripting an unknown for each ones links and images is
    insane. So I am
    > looking
    > at Classes. Assign a custom class for the flipping
    buttons and I should
    > be
    > able to assign tthem as the XML loads, and have it
    automatic. (pray please
    > please please)
    Again, no need for a class for this. If you load the buttons
    into seperate
    MCs, and make sure to have all these MCs created inside a
    common parent MC
    for these buttons (which then _only_ contains these buttons).
    You can move
    this parent MC up and down on the stage based on the
    scrollbar. And you can
    read height off this MC to create your scrollbar.
    You might want to check out the following tutorials at
    http://www.gotoandlearn.com/:
    XML Video Playlist
    Creating Animated Buttons
    Introduction to OOP
    Now, I've said many times you don't need to make your own
    class to do what
    you want. That does not mean you can't make your own class. I
    just think
    that the main problem you are facing is the dynamic part,
    which you will be
    facing if you make your own class or not.
    /Jensen/
    >
    > Anyhelp?
    >
    > Thanks
    > Vince Sidwell
    >
    >
    >

  • Writing a simple class

    I would like to write a class that will draw a gradient for
    the whole background of my file. I had written this in my file and
    it was working, but I would like to put that code into a class now,
    as I am trying to learn how to write classes. I am totally new to
    classes, so bare with me, I don't know what I am doing... more
    guessing at this point really. Here is what I have so far.
    My class is called BgGradient.as and holds the following AS
    so far.
    class BgGradient
    var gradient01:String;
    var gradient02:String;
    var fillType:String = "linear";
    var colors:Array = [gradient01, gradient02];
    var alphas:Array = [100, 100];
    var ratios:Array = [0, 255];
    var matrix:Object = {matrixType:"box", x:0, y:0,
    w:Stage.width, h:Stage.height, r:(90/180)*Math.PI};
    var spreadMethod:String = "pad";
    var interpolationMethod:String = "linearRGB";
    var focalPointRatio:Number = 1;
    function BgGradient() {
    beginGradientFill(fillType, colors, alphas, ratios, matrix,
    spreadMethod, interpolationMethod, focalPointRatio);
    moveTo(0, 0);
    lineTo(Stage.width, 0);
    lineTo(Stage.width, Stage.height);
    lineTo(0, Stage.height);
    lineTo(0, 0);
    endFill();
    I would like gradient01 and gradient02 to be hex values that
    I can specify in my main file. What am I missing here? Do I need to
    import anything? How about the drawing API? How would I call this
    from my main file?
    Thanks a lot for any help with this. I really appreciate any
    help!

    you don't have to pass anything, except you must pass
    something that has can reference a graphics class member to which
    you can apply your begingradientfill method.
    but if you want to specify gradient01 and gradient02 from
    outside your class, that would be one way to do it. you could also
    use a setter to define those variables outside your constructor.
    which is best depends upon what you want to do. if you always
    know those variable values when your create a class member, pass
    them in the contructor. otherwise, a setter is a good way to
    go.

  • Button class name

    When I want to create an instance of a panel I use the following code:
    component = new UIPanel();
    What should I use for an instance of a button? There is no UIButton in the javax.faces.component.

    sorry just to double confirm, is it UICommand? i guess i have asked a silly question.

  • Writing a picking class

    I'm trying to write a picking class to click on a cube and only rotate it in the x direction. I'm new to java3d and can't figure out what I need to do to write my own picking class to do it. Any help would be greatful

    you've read the tutorial?
    http://developer.java.sun.com/developer/onlineTraining/java3d/j3d_tutorial_ch4.pdf
    I extended PickMouseBehavior and used PickCanvas, but I was doing something completely different, so you'll probably want to ignore that.
    I doubt this has been helpful
    J.

  • 3 Class Investment Account

    I am writing a three class Investment Account program with the three classes being AccountInterface, AccountModel and Account.
    One of the butttonclick options is to save the data entered for a certain account (name, age, deposit, rate)
    Without using arrays you need to be abkle to enter the details for two different bank accounts, so in the interface you add the deatils for one, click add and it stores the data for the account, then when you clear this and add data for a new bank account it needs to check if there is anything for account 1 if yes, then add the details for account two.
    I am struggling with this.
    Can someone point me in the right direction of where to start with this? I know that the button click in the AccountInterface needs to call a method from AccountModel.

    Your problem is very specific to the homework assignment it comes from, and you're not describing your homework assignment very well. Perhaps someone here can give you specific advice but I doubt it.
    So here's some general advice:
    First, separate your GUI from the application logic. Thinking about button clicks and event handlers and such will just get in the way of understanding the problem to be solved. Try writing a test class (or several) that you can execute from the command line, and that will act as a hardcoded single scenario, that will invoke the application logic code. So an example test might do a single "add" operation. Then write code that will satisfy this test class.
    Secondly, make certain you understand the problem before you try to solve it. Draw diagrams, use Legos, whatever, to give yourself something tangible to work with. Once you're able to express the problem well, you're two-thirds of the way to solving it. A lot of homework just involves rephrasing what the prof said to make it make sense.
    And if all else fails, as your prof for clarification.

  • Preferred style of writing listeners

    As a programmer who is just now seriously learning Java, I use two main books for references:
    Java: How to Program (3rd Edition) by Dietel and Dietel
    and Teach Yourself Java 2 in 21 Days (3rd edition) by Cadenhead and Lemay
    The books differ on how they write listeners. Dietel suggests that you add a seperate listener to each component via an anonymous inner class, as below:
    myComponent.addActionListener(
       new ActionListener()
          public void actionPerformed(ActionEvent e)
             // do stuff
    );Cadenhead and Lemay, however, suggest that your main class should implement one ActionListener and add it to all components that have actions associated with them, as below:
    public class myApplication extends JFrame implements ActionListener
       public void actionPerformed(ActionEvent e)
          if (e.getSource() == "a component")
             // do stuff
          if (e.getSource() == "another component")
             // do other stuff
          // etc., etc.
    }I can understand not wanting to have so many anonymous inner class files, but at the same time I see the appeal to not having to check so many if statements. For a medium-sized application, which is preferred and why?

    My preference is to use one inner class per listener, the Dietel way. That way my code says "Here's a button. And here's what happens when it's clicked on." That works for me provided that all the buttons do different things. But if I had a situation with 10 buttons that all did essentially the same thing (as in a calculator) then I would probably do something more like the Cadenhead and Lemay, since you wouldn't end up with a massive case-statement inside the single listener.
    That's just my personal opinion. I don't even mind writing anonymous inner classes inside anonymous inner classes, following the rule I implied above of "code the object's behaviour next to its declaration". However many people would find that difficult to follow and to maintain, and I can sympathize with that viewpoint. You'll notice that I don't have trouble writing long complex sentences full of those clause things, either, so perhaps I'm not the best guide for simplicity.

Maybe you are looking for

  • J2EE RI: error in creating Oracle XA Datasource

    I want to use the Oracle XA driver within Sun's J2EE Reference Implementation. So I put the JDBC driver JAR files to the $J2EE_HOME/lib/system directory and add it to the J2EE_CLASSPATH environment variable. Then I add the XA Datasource with the foll

  • ORA-04030: out of process memory error for expdp utility

    Hi, I am using expdp utility to export schema objects. It was working fine for the past one year, but now I am facing this issue. It is giving below error while exporting one schema objects. Processing object type SCHEMA_EXPORT/TABLE/TABLE ORA-39125:

  • An't see itunes store video previews

    I can't see any video previews in itunes even though I hear the audio (either in the artwork window or the itunes store window). Anyone able to help? Thanks!

  • Any decent feature phones coming?

    I'm probably going to be adding 2 more 'feature' phone lines before the end of September.  Last month I added one for my daughter, a Pantech Crux.  ( We went back the Verizon store the day after she got the phone, and it was no longer on display - it

  • E-mail attachment

    When I receive an e-mail with a WMV as an attachment, it won't play on my iphone4.