Events, Variables and Input Text

Hi,
I'm not new to Flash or AS3 but I've never really made anything too complex. I'm making a Flash game and getting to know Variables for the first time. The tutorials online confuse me because they're mostly geared towards AS2 and I bought this book (which is awesome) Game Design with Flash, but it only covers variables involving numbers and a guessing game.
All I want right now is a field to enter your name and below, whatever the user has entered, will show up in a Dynamic text field that will go, "Oh, so your name is (whatever)?" I understand that the information that the user types into the Input Text Field has to be entered in somehow, so do I need to make a function to make it work with a button? Right now I can type in the Input but nothing shows up in the Dynamic text field.
I borrowed an AS3 example from elsewhere on this forum and added my own Instance names. I also wanted to know, how can I call up the user's name throughout the game? Just calling that same variable up?
Here is what I have:
stop();
var myName:String;
myName = userName.text;
confirm_txt.text = "So your name is "+ myName;
I get no errors but the Dynamic text box isn't showing what I'm typing... How do I go about "entering" the name so it shows up and I can call it up anytime throughout the game?
Thank you so much in advance for any help offered!

"It sounds like the same concept of a class, so if a class is a pot, everything in it can be what pertains to the pot."
Well, there one important thing you need to keep in mind when dealing with Flash. There are classes and display lists. Classes have properties and methods and display lists have children.
For example,
var myClip:MovieClip = new MovieClip();
var mySprite:Sprite = new Sprite();
myClip.addChild(mySprite);
Now, this is important:
you can
trace(myClip.x) - because is x a documented property of MovieClip class
BUT
you cannot
trace(myClip.mySprite) because although mySprite is a child of myClip, IT IS NOT A PROPERTY of myClip as it is not a property of MovieClip class.
In other words, display list of a DisplayObjectContainer is sort of independent property/feature that doesn't fall into conventional realm of class capabilties. This special feature is addressed and children are manipulated in a special, peculiar to Flash manner only.
Using pot analogy, display list is a space where you can put DisplayObjects. Objects that are put into this space do not belong to the instnace but just temporarily occupy it.
Here is a little game (let's name it "move vegies between pots") that may help you to get feel of parent/child relationships. Click on vegies and observe how they behave relative to their parents:
import flash.display.Graphics;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.text.TextField;
var apple:MovieClip = vegie("apple");
var beet:MovieClip = vegie("beet");
var onion:MovieClip = vegie("onion");
var pear:MovieClip = vegie("pear");
var bigPot:Sprite = makePot(250, 250);
var mediumPot:Sprite = makePot(200, 200);
var smallPot:Sprite = makePot(150, 150);
addChild(bigPot);
addChild(mediumPot);
addChild(smallPot);
bigPot.x = 20;
bigPot.y = 20;
mediumPot.x = bigPot.x + bigPot.width + 50;
mediumPot.y = bigPot.y + bigPot.height - mediumPot.height;
smallPot.x = mediumPot.x + mediumPot.width + 50;
smallPot.y = bigPot.y + bigPot.height - smallPot.height;
var vegies:Array = [apple, beet, onion, pear];
var pots:Array = [bigPot, mediumPot, smallPot];
putVegies();
* Places vegies into big pot
function putVegies():void {
     for each(var veg:MovieClip in  vegies) {
          bigPot.addChild(veg);
          // bigPot has index 0 in pots Array
          veg.parentIndex = 0;
          veg.mouseChildren = false;
          veg.buttonMode = veg.useHandCursor = true;
          veg.x = veg.width + Math.random() * (bigPot.width - veg.width * 3);
          veg.y = veg.height + Math.random() * (bigPot.height - veg.height * 3);
          veg.addEventListener(MouseEvent.CLICK, onClick);
* listener to clicking on vegies
* chooses a new random parent
* @param     e
function onClick(e:MouseEvent):void {
     var target:MovieClip = e.currentTarget as MovieClip;
     // new parent random index
     var parentIndex:int = Math.round(Math.random() * (pots.length - 1));
     var newParent:Sprite = pots[parentIndex];
     newParent.addChild(target);
     target.x = target.width + Math.random() * (newParent.width - target.width * 3);
     target.y = target.height + Math.random() * (newParent.height - target.height * 3);
* Makes vegie
* @param     text - vegie label
* @return
function vegie(text:String):MovieClip {
     var label:TextField = new TextField();
     label.autoSize = "left";
     label.text = text;
     label.x = - label.width / 2;
     label.y = - label.height / 2;
     var s:MovieClip = new MovieClip();
     var g:Graphics = s.graphics;
     g.beginFill(0xffffff * Math.random());
     g.drawCircle(0, 0, (label.width / 2) + 5);
     g.endFill();
     s.addChild(label);
     return s;
* Draws pot outline
* @param     w
* @param     h
* @return
function makePot(w:Number, h:Number):Sprite {
     var edge:Number = 10;
     var s:Sprite = new Sprite();
     var g:Graphics = s.graphics;
     g.lineStyle(2, 0x000000);
     g.moveTo(0, 0);
     g.lineTo(w, 0);
     g.lineTo(w - edge, edge);
     g.lineTo(w - edge, h - edge);
     g.curveTo(w - edge, h, w - edge * 2, h);
     g.lineTo(edge * 2, h);
     g.curveTo(edge, h, edge, h - edge );
     g.lineTo(edge, edge);
     g.lineTo(0, 0);
     return s;

Similar Messages

  • How to create customer exit for characteristic variables and for text vars.

    hi friends,
      can anybody tell me how to create customer exit for characteristic variables and for text variables in bw ides system.
    thanks,
    sree

    Hi,
    Please have a look at:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f1a7e790-0201-0010-0a8d-f08a4662562d
    Krzys

  • Subscript & Superscript in dynamic and input text field in Flash

    Yes, <sub> & <sup> tags are not supported by
    Flash but you can
    use Subscript & Superscript in dynamic and input text
    field in Flash:
    Download & install Subscript & Superscript fonts
    from
    http://www.subscriptfont.com
    or
    http://www.superscriptfont.com
    You will need to restart Flash software after installed
    fonts.
    Create a dynamic text field with Arial font embeded. Set the
    HTML property to true.
    Create a dynamic text field with Subscript font embeded.
    Create a dynamic text field with Superscript font embeded.
    Use HTML tag to set text to subscript or superscript like
    below:
    Some text<font face="Superscript">©</font>
    If you are using ActionScript to test the htmlText, use
    script like below:
    my_txt.htmlText = "Some text<font
    face='Superscript'>TM</font>";
    They are better than CG since it goes lower than the baseline
    and it's real subscript..

    Hi Nirnalatha,
    I have newly joined this forum and while going through the
    posts I came across your post which I thought I could help out. But
    I think I am too late for the reply.
    I am also into Flashlite development couple of months from
    now. Coming to your questions:
    1. Textbox problem: I am surprised to know that E70 mobiles
    (Device central list has E70-1 only) does not show input text box
    when cursor is in input box. Anyways its a good thing that you dont
    get an additonal input box. Like all J2ME applications you will be
    able to type the text inline. Infact we had reverse problem where I
    was told to create inline edit input box instead of flashlite input
    box. I think this is the mobile setting. Check the device features
    in the Adobe Device Central under Flash - Standalone player - Text
    and Fonts features. It will be mentioned whether inline text is
    allowed or not.
    2. Soft keys issues: You need to use
    fscommand2("SetSoftKeys", "Previous", "Next");
    and use a key listener in order to override the Mobile
    Softkey commands. Check out the flashlite help which clearly
    explains this.
    Hope I have given youa way to solve ur problem.

  • Using variables in input text fields nested in a movieclip

    Hi all,
    I am designing a roulette wheel type game. I am using a variable, "_global.myMoney = 0; " to keep track of the total money the player has. When I built the prototype, I used a dynamic text field on the stage with an instance name of "myMoney_text" and a variable of "_root.myMoney"
    Now, I need to move this text box into a movie clip with an instance name of "winnings_mc"
    When I test the movie, it looks like it showing the style sheet (font size, font, etc...) inside the dynamic text box. If I change the variable of the box to "_root.winnings_mc.myMoney" it seems to track initially, but now my updateMoney function in my main script does not work.
    The function is called like this:
    trace("updated money equals " + updateMoney(myMoney));
    This always traces zero now, the initial value.
    Any ideas?
    Thanks!

    if you want to use a global variable, when initializing and everytime you assign a new value, prefix the variable with _global:
    _global.myMoney.
    whenever you want to retrieve its value, use myMoney.
    you should not be using _root.myMoney.
    and as ned mentioned, you should stop using the variable associated with textfields and use the text property of your textfield to assign its text.

  • Text arrays (variables) and Dynamic Text Box

    Hello everyone. I have a text file (let's call it sample.txt)
    that has numerous variables or arrays in this format:
    &info=This is some information
    &stuff=This is more stuff
    &whatever=Even more stuff again....
    Anyway, I need to load a particular variable via individual
    buttons from this same sample.txt file into a dynamic text box
    (let's call it dynText), and I am a bit lost as to how to do it.
    Please provide me a solution thank you.
    Glenn

    Thank you very much, it's greatly appreciated. It worked
    perfectly except that it does not like variables that begin with
    numbers like:
    &401_2b=401_2b
    The above doesn't work, but if I do this...
    &h401_2b=401_2b
    Everything is fine. Problem being, I am generating the
    variables via PHP and therefore cannot "change" them. Can you
    provide me with a way that ActionScript can "see" the variable that
    starts with a numeric value? Thanks for your time.
    Glenn

  • How to print and input text in Adobe Edge

    Hi everybody!
    I have an input and I need to create a button that when pressed, send to print the text the user typed in the input.
    Any idea how to do that?
    thank you very much

    Saw this about printing:
    If you need to print an specific content, you can hide the rest (and format the printed area) by CSS:
    <style media="screen"> .noPrint{ display: block; } .yesPrint{ display: block !important; } </style> <style media="print"> .noPrint{ display: none; } .yesPrint{ display: block !important; } </style>
    As you can see, by setting the media attribute of your style tag, you can set up styles for both the normal view (screen) and the printing view (print). Full article is here.

  • Query with user-exit hierarchy variable and input ready hierarchy node var.

    Hello everyone.
    we are using several hierarchies (2005, 2006 and 2007) of the same info object 0FUNDS_CTR (one for each fiscal year). We would like to be able to use same reports regardless of chosen fiscal year (selected hierarchy) and ever more, to select node inside proper hierarchy. At the moment reports use 3 parameters:
    1) fiscal period from - fiscal period to
    2) hierarchy name
    3) hierarchy node
    Our goal is to get report with only 2 parameters:
    1) fiscal period from - fiscal period to
    2) hierarchy node
    since hierarchy name could be derived (user exit) from fiscal period.
    When user selects hierarchy node he is being asked to select hierarchy name (despite of user exit for hierarchy name) and key date (populated with current date).
    We would like to avoid step of user selecting hierarchy. Is it possible?
    Any other approaches to problem would be appreciated.
    Kind regards,
    Josko.

    Hi Jörg,
    As mentioned, I_STEP = 3 is  processed once per query, not once per varaiable.
    If this statement is placed within case-endcase for I_VNAM it never will be processed.
    Please take a look on this, it might be helpful..
    Regards
    Joe

  • Loading an input text..

    Hi,
    Here is my problem:
    I'm trying to load and input text with a 'x' value.
    This 'x' value is result of a method operation.
    I need to do this after the partial page rendering of a select one choice, and the method operation bases its calculation upon the select one choice value.
    Does any one have any idea on how to do this?
    Thanks in advanced,
    Max.

    Hi,
    This is basic partialTriggers handling. Try something like the following:
    In the page:
    <af:selectOneChoice value="#{bean.valueChoice}" id="choice" autoSubmit="true">
      <f:selectItem itemValue="1" itemLabel="Item 1"/>
      <f:selectItem itemValue="2" itemLabel="Item 2"/>
    </af:selectOneChoice>
    <af:inputText value="#{bean.valueText}" partialTriggers="choice"/>In the bean:
    private Integer valueChoice;
    private String valueText;
    public Integer getValueChoice()
        return valueChoice;
    public void setValueChoice(Integer valueChoice)
        if (valueChoice != null && valueChoice.intValue() == 1)
            valueText = "x";
        this.valueChoice = valueChoice;
    public String getValueChoice()
        return valueText;
    public void setValueChoice(String valueText)
        this.valueText= valueText;
    }Regards,
    ~ Simon

  • How to define and populate value to a variable in a text file

    hi all,
    i have a text file on unix server, when i read it through open dataset, is it possible to populate dynamic value to a variable in the text file. and is it possible to define a variable at any place in the text file?
    after this the program will send the internal table for emailing.
    thanks.

    Hi, If this file on server is a email template you can put some tags / marks and you can change it after you read it with OPEN DATASET / READ...
    Sample:
    OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    CHECK sy-subrc EQ 0.
    DO.
      READ DATASET p_file INTO lv_string.
      IF sy-subrc EQ 0.
        EXIT.
      ENDIF.
      REPLACE ALL OCCURENCES OF '((SYSTEM_ID))' WITH sy-sysid.
      APPEND input_file_tab.
    ENDDO.
    CLOSE DATASET p_file.
    on file there's a line with:
    This email was generated on server ((SYSTEM_ID))
    It will be translated to (sy-sysid = DEV):
    This email was generated on server DEV
    This is a "variable" like that you can use.

  • Losing variables using loadMovie in input Text Field

    Hello! Im trying to load an swf into another swf that has a variable in the text input field. Im a designer and not a programmer but I am using this tutorial to get started in loading a form with a variables in it.
    http://www.kirupa.com/developer/actionscript/flash_php_email.htm
    What im doing is trying to duplicate is the text box so that when i want to load new_box.swf (with a variable name "company") into main.swf into a movieclip with an instant name "loader." using this:
    on (release) {
        loadMovie ("new_box.swf", "_root.form.loader");
    I can get the movie to load but it loses the variable "company" in the process and when i send the form it doesnt work. If i just keep it in the main timeline it works but not when i loadMovie. Any info would help. Thank you.

    when you load an swf into another, the _root will refer to the root of main swf.
    try add this code to first frame of your loaded swf.
    this._lockroot = true;

  • How to add comma and dollar sign that places automatically in input text field

    I have this ROI calculator which has several text input field
    on frame one with calculate and reset buttons. When a user enters
    numerical values in the text field, and jumping to the next field,
    I want the input text filed be updated with dollar sign and with
    comma.
    Next when they hit "ENTER" key or click "Calculate ROI"
    button, all the input text fields on frame 2 as a result of
    calculations be updated with dollar sign and comma. I also need
    that once the comma sign is assigned then it would not add any more
    even if user presses the button. Can someone help me in
    this?

    If you want to Set the Comma when you Switch to next Text
    Field
    Use onKillFocus / onSetFocus Functions.
    to restrict multiple comma, Before Adding comma use
    myText.text =
    myText.text.split(",").join("").split("$").join("");
    So this will give you the value without Comma and Dollar
    symbol, Now add the Comma and dollar.
    or you need to use a Flag for onChange Event.

  • Changing the cursor position in an input text field and Removing leading numeric zeros

    Flash8 - AS2
    It's good to be back after all these years and thanks for the faithfull folks like kglad, Ned Murphy, Rothrock and all the others who give so much of themselves to make this forum a success!
    My Problem:
    I have an input text field that is named in the properties box as 'numberOfKids'.
    When the program is executed, and a delete or backspace is pressed the input textfield goes blank
    and any calculations that use 'numberOfKids' shows NaN.
    I have trapped the NaN and undefined so that a numeric 0 shows up instead of a blank.
    There are two problems:
    First problem:
      The cursor is to the left of the zero, so the first number inputted by the user is 10x larger than what they want.  0 becomes 10.
    Question:  How do I get the cursor to move to the right of the 0?
    Second Problem: 
      When I manually move the cursor to the right of the 0 and input a number, say 4, it shows up as 04.
    Question 2:  How do I delete the leading numeric zero in the input textfield?
    Thanks for the help.
    Here's the code I am using:
    calculateChildWeight = function () {
    if (isNaN(numberOfKids)) {
      numberOfKids = 0;
    if ((numberOfKids) == undefined) {
      numberOfKids = 0;
    if (numberOfKids>=0 && numberOfKids<=137) {
      numberOfKids = numberOfKids;
    } else {
      numberOfKids = 0;
    if (isNaN(adjustedChildWeight)) {
      adjustedChildWeight = 0;
    if ((adjustedChildWeight)=undefined) {
      adjustedChildWeight = 0;
    adjustedChildWeight = Number(numberOfKids*(-100));
    //numberOfKids.setSelection(numberOfKids.length, numberOfKids.length);
    //if (numberOfKids.length=2 && numberOfKids<10) {
      // remove the first character or leading zero
    //  numberOfKids = numberOfKids;

    Thanks Rothrock for being so  patient.
    I'm lost!
    I go back to a brand new flash file to try and implement the textfields as a stand alone test document.  I have lost the concept I think.
    I created on the stage of a blank .fla file  4 text fields, 2 input and 2 dynamic.  I gave them an instance name in the properties box.  I use this instance name.text to find the value of the field.  I use the parseInt to put that value into a numeric variable for calculation.  The results are put to the appropriate textfield.
    All seems to work except one of my input text fields.   I use the value of this field  to calculate:
    revisedValue = parseInt(numberOfKids.text);
    revisedValue = revisedValue*(-100);
    The problem now is that if the numberic '2' is inputted into numberOfKids, numberOfKids.text shows up as 200 and a trace shows up as '2NaN'.
    Flash is logical and consistant, I must conform to it but I'm in the dark.
    (( Concerning the forum:  If I click on helpful, which your posts have been in directing me, does that blank out the possibility of selecting the correct answer in the future???))

  • Changing a variables length for text input in Captivate 6

    I am using eLearning CS6 (non-subscription I believe, but no one at my office can confirm) and use a machine where all software is deployed via push from IT. The ability to check for updates has been removed from me.
    I need to be able to have users enter data into the course and have it both be forwarded on to our database AND appear in later segments of the course.
    I recall being able to update the TEB variable length in previous versions but can not find the option anywhere in CS6. or perhaps I'm imaging it.
    I am running version 6.0.1.240 and there is no Format option in my TEB properties. I do not see alignment options, and instead see Characters as a menu above the Shadow & Reflection option.
    I do know where to set the value in a text caption box. However, I seem to be limited to entering a single variable in the caption field in order for this to be option. However, there are times where we'd rather have multiple variables strung together on a single line, or a word or two of static text appearing before or after the variable.
    If I want to string the user entered data from multiple variables into a single caption box there appears to be no way to change the variable's character length from 15 to a higher value.
    Does anyone know of another way to work around this other than through the use of multiple caption boxes?
    I've been driving myself a bit batty trying to think of a way around the 1 caption 1 variable limit...
    Thanks.
    Note: Please don't advise me to upgrade. I've already been told the office will not pay for an update to the software so quickly on the heels of our upgrade from CS 5.5 to CS6 (happened within a 6 month span).

    15 characters is the default when you insert the variable into a text caption.  But you can set this to anything from 1 to about 250...as long as you use the Insert Variable icon in the Properties tab > Format accordion to insert the variable.  Look for the field in the dialog that allows you to specify the variable's display length.

  • Problem with action script 3 make input text box and button....

    Hi every one I am trying to make a family book using "Air for Android" with a simple search engin in the book
    air for android only work with AS3,
    the search function is to type a person's name and hit submit then go to a specific frame.
    have a problem making below code to work in AS3 and hopefully one of you guys can lead me in the right direction to fix the issue.
    Currently, I have an input text box and a button. When you type specific words into the input box and then hit the button it sends you to a specific frame.
    (it work find in AS2 but not in AS3,)
    Here is my current code that is placed on the main timeline, first frame:
    stop();
    onEnterFrame = function () {
        submit.onRelease = function() {
            switch (yourname.text) {
            case "name1" :
                gotoAndStop(2);
                break;
            case "name2" :
                gotoAndStop(3);
                break;
    My button that checks if the phrase is correct is called "submit" and my input box has an instance of "yourname".
    My phrases that will be accepted in the input box are "name1" and "name2" which bring me to two different frames.
    Basically, I'm having a problem with making this to work with AS3.

    you should use the default option in the switch statement
    that way yourname contains something not in one of the case statements it will go to the default bit and execute teh code there
    function onSubmit(e:MouseEvent):void
                                  switch (yourname.text)
                                            case "name1":
                                                      gotoAndStop(2);
                                                      break;
                                            case "name2":
                                                      gotoAndStop(3);
                                                      break;
                                            default:
                                                      goToAndStop(you frame you want);
                                            break;

  • Can we hide the real value of input text box and show other value in ADF?

    Hi All,
    I have a table in which i have one the column as "Quantity" and text box as "quantity" :-
    <af:column sortProperty="quantity" filterable="true"
    sortable="true" headerText="Quantity" id="c3"
    width="60"
    rendered="#{row.bindings.booleanFlag.inputValue != 'E'}"
    filterFeatures="caseInsensitive">
    <div align="center">
    *<af:inputText value="#{row.bindings.quantity.inputValue}"*
    label="#{bindings.queryProductResponseType.hints.quantity.label}"
    required="#{bindings.queryProductResponseType.hints.quantity.mandatory}"
    columns="#{bindings.queryProductResponseType.hints.quantity.displayWidth}"
    maximumLength="#{bindings.queryProductResponseType.hints.quantity.precision}"
    shortDesc="#{bindings.queryProductResponseType.hints.quantity.tooltip}"
    id="it5" partialTriggers="it19"
    readOnly="#{row.activeYN == 'N'}">
    <f:validator binding="#{row.bindings.quantity.validator}"/>
    <af:validateRegExp pattern="^[1-9]+[0-9]*$"
    messageDetailNoMatch="Quantity must be in whole number format."/>
    </af:inputText>
    </div>
    </af:column>
    Now when the user will enter say 400 in input text box "quantity" , the value should be divided in the same row to other column text box say "conversion" which holds the value as 40 , so if the division doesn't give any remainder(means remainder =0 ) means real value(400/40) = 10 then it should set the value of input text box "quantity" as 10 but the user should be able to see 400 which he/she entered before, as we want to send the 10 as request but we have to show 400 to the user and if remainder goes greater than 1 than it should show an error.
    I have to implement this in value change listener of the text box as i need to calculate the real value each time for a row.
    How should i implement this ?
    Thanks .
    Thanks.

    Thanks timo,
    But can you give me full details how should i implement this as i am newbie to ADF. I have found the data control in Data controls tab in left hand side and right click on it -> edit definition -> but it does not give me the option to add attribute , it just give me the option to edit the existing attribute. Can you explain me how to add the transient attribute and how to implement it ? Any sample code snippet ?
    Thanks.
    Edited by: user13644804 on May 15, 2011 10:09 AM
    Edited by: user13644804 on May 15, 2011 10:09 AM

Maybe you are looking for