A Flash Developer Resource Site

Results 1 to 16 of 16

Thread: Actionscript Falty

  1. #1
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870

    Actionscript Falty

    What is wrong with this Actionscript?

    Code:
    on (rollOver) {
    	ftxt = hit;
    //ftxt is a variable to a textbox, hit is the text i want to display
    }
    I don't know but it don't work.

    Regards,
    Tongxn

    P.S. sorry about this stupid question I just can't get it to work.
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  2. #2
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    Is hit a variable defined elsewhere, or do you want to display the word hit?
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  3. #3
    Member
    Join Date
    Aug 2005
    Posts
    42
    Maybe...

    Code:
    on (rollOver) {
    	ftxt.text = ("hit");
    //ftxt is a variable to a textbox, hit is the text i want to display
    }

  4. #4
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    i will try..

    nope don't work
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  5. #5
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    Quote Originally Posted by kortex
    Is hit a variable defined elsewhere, or do you want to display the word hit?
    just display in a dynamic txtbox
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  6. #6
    Member
    Join Date
    Aug 2005
    Posts
    42
    To use the .text code, the dynamic textbox would be placed physically on the stage and ftxt would be an instance name. Also, make sure your path to your textbox is correct (_parent , _root , ect)

  7. #7
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    yes I understand that you want to display it in a dynamic textbox, but my question related to syntax. If you want the word hit to display, then it need to be in " " marks otherwise Flash assumes it is a varaible name.

    so first thing is change hit to "hit" if that is what you want to do.

    Secondly I assume you entered the variable ftxt in the properties panel for the text field, which is fine, but you also have to keep in mind where that variable is being defined and changed. So I would go back ino the properties for the textfield and change it to read:

    _root.ftxt

    Then on the button you would have to change it to:


    on (rollOver) {
    _root.ftxt = "hit";
    //ftxt is a variable to a textbox, hit is the text i want to display
    }

    It is a matter of refering to right level for the variable. The way you have it orginally written, would create a variable on the button named ftxt and set it equal to another variable named hit, meaning that it would never actually change the value for the variable you set in the poperties for the text box.
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  8. #8
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    mumble. er.. it's no button. it's a MovieCLip!

    Arr about the instance name of a txtbox?
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  9. #9
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    now here's what happens if I got the instance name "ftxt" according to skillionair
    _level0.ftxt
    now whatsits?
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  10. #10
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    _level0 is synonomous with _root

    movie or button should work the same.
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  11. #11
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    er
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  12. #12
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    if you set the vairable in the properties box in the variable field, you do not need the instance name. skillinaire is assuming you are trying to target the text field via the instance name and set the text property. Which from what I have read does not seem to be the way you set it up.
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  13. #13
    Member
    Join Date
    Aug 2005
    Posts
    42

    fla

    may not be the only solution, but one I have used.
    Attached Files Attached Files

  14. #14
    AFX == P. Forsberg
    Join Date
    Nov 2001
    Posts
    439

    instance vs. var name

    if "ftxt" is the instance name of the dynamic text feild, you will need to write:
    code:

    on (rollover) {
    ftxt.text = "hit";
    }



    Good luck,
    1M.

  15. #15
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    Right O i'll try that today.
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  16. #16
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    OMG!!!..

    ftxt is NOT the instance name..he said so himself..that is was the VARIABLE name. (so Im assuming there is NO instance name set)
    which is it?

    is the INSTANCE NAME "ftxt"
    or
    the VAR name (of the textField properties) is "ftxt"

    if this is NOT a button...

    then use:

    this.onRollOver = function() {
    _root.ftxt = "hit";
    }

    if its a button, use:

    on (rollover) {
    _root.ftxt = "hit";
    }


    in the properties box for your textField.. make sure the variable is _root.ftxt

    thats it...

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