Text box array?

Hi,
I want to create a form that asks for 2 user inputs into text
boxes then outputs an answer into a label.
However, I want the user to be able to put in several inputs.
Because there is a possibility of having HEAPS of sets i want
to use an array.
So the form would like something like:
txtOne[0] + txtTwo[0] = lblAns[0]
txtOne[1] + txtTwo[1] = lblAns[1]
txtOne[2] + txtTwo[2] = lblAns[2]
Each textbox would have an onChange= myFunction(arraynumber)
then I want to use javascript to output the answer:
function myFunction(num) {
value1 = document.form1.txtOne
.value
value2 = document.form1.txtTwo
.value
answer = value1 + value2
document.form1.lblAns
.value = answer
Is there anyway to do this?
Thanks

You have to use a property node, and write the string array directly in the [strings] property.
See the attached vi
CCMessage Edited by chilly charly on 04-22-2005 03:02 PM
Chilly Charly    (aka CC)
         E-List Master - Kudos glutton - Press the yellow button on the left...        
Attachments:
TextTableToRingControl[1].vi ‏22 KB

Similar Messages

  • 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 use text boxes or rich text boxes inside loops in array format

     Help me,
        I try to use text boxes load automatically showing the character in the text box.One text box showing one character (ex: " A"). I use 5 text boxes.I try to code using   for loop but i don't know how to use array format.
    Please explain any solution.
    I am using Microsoft Visual Basic 2008 Express Edition

    Hi
    And yet again, this version uses a list of textbox names (IN REQUIRED ORDER) to fill.
    ' this is an overly simplified example
    ' in the form of a Project
    ' start a new Project with a default
    ' Form1 with many TextBoxes.A list of
    ' required textboxes to fill IN THE
    ' REQUIRED ORDER is used.
    ' Copy/paste this code to replace
    ' all Form1 code with this.
    ' NOTE: there is plenty of oppertunity
    ' for exceptions as no exception handling is
    ' included here.
    Option Strict On
    Option Explicit On
    Option Infer Off
    Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
    Dim tbNames As New List(Of String)
    ' add names IN THE ORDER required
    tbNames.AddRange({"TextBox2", "TextBox5", "TextBox1", "TextBox3", "TextBox4"})
    Dim s As String = "boxes"
    Dim counter As Integer = 0
    For Each name As String In tbNames
    For Each c As Control In Me.Controls
    If c.GetType() Is GetType(TextBox) Then
    If c.Name = name Then
    c.Text = s(counter)
    counter += 1
    End If
    End If
    Next
    Next
    End Sub
    End Class
    Regards Les, Livingston, Scotland

  • Bold a dynamic text box is not working...

    Dear Friends,
    i neeed to create a text box with bold letter. my coding is as follows.
    but it always shows bold, even i gave tf1.bold = false.
        reptitle.text = options[0][0].tit;
        var tf1:TextFormat = new TextFormat();
        tf1.color = options[0][0].col;
        tf1.size = options[0][0].siz;
        tf1.bold = options[0][0].bol;
        reptitle.setTextFormat(tf1);
        trace("bold :"+tf1.bold + " dat :"+options[0][0].bol);
    Note: where options[0][0] is an array has all the properties bold = true/false, color = 0x----.
    Any body can clarify me.. i got struct up..pls..
    Thanks and Regards,
    Syed Abdul Rahim

    you'll need two textformat instances (one with bold enabled and one without) to display text with both bold and non-bold text at the same time with setTextFormat.  if you just want to change the text from bold to non-bold (and vice-versa), you can use one instance.

  • PowerPoint using macro to delete text boxes after printing

    Hi,
    We created custom shows in Powerpoint and are running a macro to insert temporary page numbers on the slides before printing.  The issue is that I need to remove the page numbers after printing.  I'm a novice at VBA so I'm sure there is an easy
    solution, but nothing I've tried so far has been successful.  The code is displayed below for your reference.  Any help is greatly appreciated. Thanks!
    Sub PrintCustomShow()
          ' Change this number to specify your starting slide number.
          Const lStartNum As Long = 1
          ' Ask the user which custom show they want to print.
          Dim strShowToPrint As String, strPrompt As String
          Dim strTitle As String, strDefault As String
          ' See if any custom shows are defined.
          If ActivePresentation.SlideShowSettings.NamedSlideShows.Count _
             < 1 Then
             ' No custom shows are defined.
             ' Set up the string for the message box.
             strPrompt = "You have no custom shows defined!"
             ' Display the message box and stop the macro.
             MsgBox strPrompt, vbCritical
             End
          End If
          ' Find the page number placeholder; if found, pick up the style.
          Dim rect As PageBoxSize
          Dim oPlaceHolder As Shape
          Dim bFound As Boolean: bFound = False
          For Each oPlaceHolder In _
             ActivePresentation.SlideMaster.Shapes.Placeholders
             ' Look for the slide number placeholder.
             If oPlaceHolder.PlaceholderFormat.Type = _
                ppPlaceholderSlideNumber Then
                ' Get the position of the page number placeholder.
                rect.l = oPlaceHolder.Left
                rect.t = oPlaceHolder.Top
                rect.w = oPlaceHolder.Width
                rect.h = oPlaceHolder.Height
                ' Get the formatting of the slide number placeholder.
                oPlaceHolder.PickUp
                ' Found the slide number placeholder, so set the
                ' bFound boolean to True.
                bFound = True
                Exit For
             End If
          Next oPlaceHolder
          ' See if a slide number placeholder was found.
          ' If not found, exit the macro.
          If bFound = False Then
             ' Unable to find slide number placeholder.
             MsgBox "Your master slide does not contain a slide number " _
                & "placeholder. Add a " & vbCrLf & "slide number placeholder" _
                & " and run the macro again.", vbCritical
             End
          End If
          ' Set up the string for the input box.
          strPrompt = "Type the name of the custom show you want to print." _
             & vbCrLf & vbCrLf & "Custom Show List" & vbCrLf _
             & "==============" & vbCrLf
          ' This is the title of the input box.
          strTitle = "Print Custom Show"
          ' Use the first defined show as the default.
          strDefault = _
             ActivePresentation.SlideShowSettings.NamedSlideShows(1).Name
          ' Obtain the names of all custom slide shows.
          Dim oCustomShow As NamedSlideShow
          For Each oCustomShow In _
             ActivePresentation.SlideShowSettings.NamedSlideShows
             strPrompt = strPrompt & oCustomShow.Name & vbCrLf
          Next oCustomShow
          Dim bMatch As Boolean: bMatch = False
          ' Loop until a named show is matched or user clicks Cancel.
          While (bMatch = False)
             ' Display the input box that prompts the user to type in
             ' the slide show they want to print.
             strShowToPrint = InputBox(strPrompt, strTitle, strDefault)
             ' See if user clicked Cancel.
             If strShowToPrint = "" Then
                End
             End If
             ' Make sure the return value of the input box is a valid name.
             For Each oCustomShow In _
                ActivePresentation.SlideShowSettings.NamedSlideShows
                ' See if the show is in the NamedSlideShows collection.
                If strShowToPrint = oCustomShow.Name Then
                   bMatch = True
                   ' Leave the For loop, because a match was found.
                   Exit For
                End If
                ' No match was found.
                bMatch = False
             Next oCustomShow
          Wend
          ' Get the array of slide IDs used in the show.
          Dim vShowSlideIDs As Variant
          With ActivePresentation.SlideShowSettings
              vShowSlideIDs = .NamedSlideShows(strShowToPrint).SlideIDs
          End With
          ' Loop through the slides and turn off page numbering.
          Dim vSlideID As Variant
          Dim oSlide As Slide
          Dim Info() As SlideInfo
          ' Make room in the array.
          ReDim Preserve Info(UBound(vShowSlideIDs) - 1)
          ' Save the current background printing setting and
          ' then turn background printing off.
          Dim bBackgroundPrinting As Boolean
          bBackgroundPrinting = _
             ActivePresentation.PrintOptions.PrintInBackground
          ActivePresentation.PrintOptions.PrintInBackground = msoFalse
          ' Loop through every slide in the custom show.
          Dim x As Long: x = 0
          For Each vSlideID In vShowSlideIDs
             ' The first element in the array is zero and not used.
             If vSlideID <> 0 Then
                ' Add slide ID to the array.
                Info(x).ID = CLng(vSlideID)
                ' Get a reference to the slide.
                Set oSlide = ActivePresentation.Slides.FindBySlideID(vSlideID)
                ' Store the visible state of the page number.
                Info(x).IsVisible = oSlide.HeadersFooters.SlideNumber.Visible
                ' Turn off page numbering, if needed.
                If Info(x).IsVisible = True Then
                   oSlide.HeadersFooters.SlideNumber.Visible = msoFalse
                End If
                ' Create a text box and add a temporary page number in it.
                Dim oShape As Shape
                Set oShape = _
                   oSlide.Shapes.AddTextbox(msoTextOrientationHorizontal, _
                                            rect.l, rect.t, _
                                            rect.w, rect.h)
                ' Apply the formatting used for the slide number placeholder to
                ' the text box you just created.
                oShape.Apply
                ' Add the page number text to the text box.
                oShape.TextFrame.TextRange = CStr(x + lStartNum)
                ' Increment the array element positon.
                x = x + 1
             End If
          Next vSlideID
    ' Print the custom show. NOTE: You must turn background printing off.
                 With ActivePresentation
                 With .PrintOptions
                 .RangeType = ppPrintNamedSlideShow
                 .SlideShowName = strShowToPrint
                 End With
                 .PrintOut
                End With
          ' Restore the slide information.
          For x = 0 To UBound(Info)
             ' Get a reference to the slide.
             Set oSlide = ActivePresentation.Slides.FindBySlideID(Info(x).ID)
             oSlide.HeadersFooters.SlideNumber.Visible = Info(x).IsVisible
          Next x
          ' Restore the background printing setting.
          ActivePresentation.PrintOptions.PrintInBackground = _
             bBackgroundPrinting
       End Sub

    Hi hlolrich,
    According to the description, you want to remove the shapes which created after you print the presentaion.
    I suggest that you name the shape you added with some rule, then we can delete thease shapes via the name rule.
    And here is a sample that you delete the shapes which name contains the
    myShape words on the first slide for your reference:
    Sub deleteShapes()
    For Each aShape In Application.ActivePresentation.Slides(1).Shapes
    If InStr(aShape.Name, "myShape") Then
    aShape.Delete
    End If
    Next aShape
    End Sub
    Also you can learn more about PowerPoint developing from link below:
    How do I... (PowerPoint 2013 developer reference)
    PowerPoint 2013
    Regards & Fei
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Multi Selection from a List Box to a Text Box

    So I want to be able to make Multi Selections within List box and export it to the Text box. Right now I have a Script running on the cal of the Text Box
    event.value = getField("LISTBOX").valueAsString;
    Which is able to do one selection but I cant find anybody that can grab two selecitons and put into a text box with commas for something. Is there a way to do this?
    -Zach

    Wow over my head a little. I understand what an array is with script but not how to write the script to handle it. I made this:
    event.value = getField("LISTBOX").value;
    But still no change in the behavior with multi selections. Example below if you want to check it out.
    https://dl.dropboxusercontent.com/u/2944617/formtext2.pdf

  • Issue with creating a text box from a loop

    I was hoping someone could take a look at this code and maybe
    help me find out why this isnt working. What I am trying to do is:
    (NOTE: I have used a few differents scripts and combined them, so
    the code may not be the greatest).
    Pull Data from a PHP file (The PHP file gets it's data from
    database)
    Then run a loop that brings in First Name, Last Name, Jersey
    Number, and Position
    Then before it loops and gets the next player it creates an
    array that creates 3 text boxes with Full Name, Jersey Number and
    position
    then it loops through the process again untill all of the
    records have been retreived.
    I'm not sure if its because I have a do while loop inside of
    a for loop inside of a function and an Array. I'm new to Arrays and
    loops. the issue is it wont display the text boxes.
    NOTE: When I trace this, the data is being retrieved.
    Thanks for the help

    "this" inside your onLoad() method refers to your loadvars
    instance, receive. and the loadvars class has no createTextField()
    method, so you're not going to create any textfields if that code
    is in the onLoad() body.
    to remedy, reference a timeline instead of receive.

  • I have a requirement with select and text boxes. JSP / JDBC

    I have a Combo Box which iswritten by a JSP by connecting to DB!
    When i click on a <option> corresponding the other two text boxes must be loaded with data!
    if i have list of EmpID in <select>, in one text box i should get his CITY and other Occupation !
    What i thought is .... getting all the data from database. select empid from emp and write a combo and select city,occupation from emp, intp ARRAYLISTs!
    function updatData(){
    var index=document.projalloc.associateid.selectedIndex;
    }if i onSelect=updateData(), (i will get index of empid,as it is a combobox) using which i have to retrieve the values of city and occupation !!
    BUT HOW !
    I am gettin the index of empid but how to get the data into textbox !!!!

    well there are many ways of doing this.
    1).Render all the data corresponding to each employee at a time.By making a javascript arrays and try to get back the data from there.
    2).Save the ArrayList of DTO beans in the scope of session.Use AJAX call a CGI(Servlet/JSP action) fetch the values from the session render the response as XML now parse the XML data using javascript DOM and then update the consecutive textboxes.
    Just as an example checkout my answer in the below post.It was an example given for a dependent drop downs.however, we can definately use the same concept to update textboxes too.
    http://forum.java.sun.com/thread.jspa?threadID=5209661&messageID=9844137#9844137
    Hope that might help :)
    REGARDS,
    RaHuL

  • How load text into dynamic text boxes from external file?

    hi all,
    my animation is very simple - a background image and 2 text boxes.  one of the textboxes shows a large word, which crossfades to another word, with a total of about 12 words (showing one at a time in different text boxes fading in & out in the same spot).
    i need a way to have the text be imported dynamically via xml or json (xml preferred).  this article is a good start, but i noticed he's putting all of the text into one box - i need separate strings put into separate boxes from the xml.
    Chris Gannon - Loading XML via AJAX into Adobe Edge
    he uses
    var outputField = $(this.lookupSelector(“xmlOutput”));
    for his text box.  what would be the best way to revise this code to include all my individual strings to be loaded into my individual text boxes?  thinking an array might work, but my js skills are limited.
    any other suggestions or tutorials you could point me to would be appreciated.
    thanks!!

    thanks joel_pau !
    this is helpful in seeing how the array is created, but after giving it a go I became a little confused.
    i wound up trying it again based on the example i linked out to previously, but it's not adding the text from my xml file when previewing.
    here's the code i'm using in edge animate on my stage.  something must be wrong somewhere.  let me know if you have any suggestions on this.
    // insert code to be run when the composition is fully loaded here
    // here i'm assigning a variable to each one of my textboxes at they're named in my edge animate comp
    var outputField1 = $(this.lookupSelector("helps2"));
    var outputField2 = $(this.lookupSelector("communicate"));
    var outputField3 = $(this.lookupSelector("experience"));
    var outputField4 = $(this.lookupSelector("interact"));
    var outputField5 = $(this.lookupSelector("understand"));
    var outputField6 = $(this.lookupSelector("overcome"));
    var outputField7 = $(this.lookupSelector("flourish"));
    var outputField8 = $(this.lookupSelector("collab"));
    var outputField9 = $(this.lookupSelector("trust"));
    var outputField10 = $(this.lookupSelector("grow"));
    var outputField11 = $(this.lookupSelector("engage"));
    var outputField12 = $(this.lookupSelector("survive"));
    var outputField13 = $(this.lookupSelector("thrive"));
    var outputField14 = $(this.lookupSelector("evolve"));
    var outputField15 = $(this.lookupSelector("connect"));
    var outputField16 = $(this.lookupSelector("achieve"));
    $.ajax({   
        type: "GET",
        url: "myxmlfile.xml",
        dataType: "xml",
        success: function(xml) {
    //here i'm trying to load the the text in my xml file into my textboxes in edge animate.  'txt1, txt2, txt3' are the tags in my xml file
            outputField1 = $(xml).find('txt1').text();
            outputField2 = $(xml).find('txt2').text();
            outputField3 = $(xml).find('txt3').text();
            outputField4 = $(xml).find('txt4').text();
            outputField5 = $(xml).find('txt5').text();
            outputField6 = $(xml).find('txt6').text();
            outputField7 = $(xml).find('txt7').text();
            outputField8 = $(xml).find('txt8').text();
            outputField9 = $(xml).find('txt9').text();
            outputField10 = $(xml).find('txt10').text();
            outputField11 = $(xml).find('txt11').text();
            outputField12 = $(xml).find('txt12').text();
            outputField13 = $(xml).find('txt13').text();
            outputField14 = $(xml).find('txt14').text();
            outputField15 = $(xml).find('txt15').text();
            outputField16 = $(xml).find('txt16').text();
    but nothing happens on preview.  my textboxes still contain the original text that lives in my comp.

  • Multiple drop down menu items to populate the a separate text box...more help please

    Thanks to Gilad D67 for showing me how to have multiple drop down menu items appear in a separate text box. This stuff blows my mind. Is there any script I can use to make a new drop down menu item appear in the same text box, but on a new line below a previous entry. For example. I select 'cat' from my drop down menu and it appears in my text box. Now I choose 'dog' from my menu and it appears in my text box like so  'cat dog.' Is there any way I can make 'dog' go straight to a new line automatically without having to manually go into the text box and change it?
    cat
    dog (new selection goes straight to a new line)
    Now, I don't have a clue if this is also possible, but imagine, I don't like my drop down menu selection of 'dog' and I go back into the menu and I change to 'rat' but in the text box, 'dog' still appears and 'rat' is added. Do I have to manually delete 'dog' from the text box or is there script that can do this for me.
    Any assistance would be incredible. It amazes me how people know this stuff.
    This is the script I have so far
    (function () {
        // Do nothing if not committed
        if (event.willCommit) return;
        // Set up an array to hold the individual paragraphs of text
        var aQuotes = [3];
        // Populate the array with the paragraph text
        aQuotes[0] = "Use common singular nouns, plural nouns [plural ‘s’] and proper names to say what things are"
        aQuotes[1] = "Use numbers 1–10 to count"
        aQuotes[2] = "Use basic adjectives and colours to say what someone/something is or has"
        // Get the selected item, which is the export value of the selected combo box item
        var item = event.changeEx
        // Display the text corresponding to the selected item in the text field
        getField("Text30").value += " " + aQuotes[item];

    You have to set the option for the text field to be multiline and then change the last line of the script to:
    getField("Text30").value += "\r" + aQuotes[item];
    To reset the field you can use a separate button with a Clear Form command, and then you just select this one field from the list.

  • Autopopulate PDF Form Text boxes

    I would appreciated any help on this matter as my IT department is unfortunately of little use.
    I am trying to gather information from text boxes in a webpage dialogue inside of a EMR (electronic medical record) system to prefill out certain textboxes in fillable form I created.  I do not now how to reveal the source code from the page in order to get help creating the code/script.  I am a complete novice at javascript but have used the forum to create various arrays to autopopulate forms.  Here is a screenshot of what I am trying to accomplish.
    I would like to take the patient account number and name from the "1. Choose a patient"" boxes and prefill in the form with the patient name and account # text boxes in the form.  We have to fill out a million forms a day and it would BE SO GREAT if we didn't have to type in the info that is literally 2 inches above it!
    I do not know if this is even possible or I have to have some special privileges via the EMR company, but when I mentioned it to my IT department I got the deer in headlights look.
    Thanks for any help you can provide.
    Vanessa

    Same here. The boxes are shifted, to varying degrees, further down than in Acrobat Reader. This is a shame because I love Preview.
    Anyone?

  • Multiple drop down menu items to populate the same separate text box. How can I do it?

    In Acrobat Pro X, I've figured out how to create a drop down menu with items that will populate a separate text box, but how can I get multiple menu items to populate the same text box. For example. My drop down menu has three items  cat, dog, mouse. I choose cat and it appears in my separate text box (hooray). Next, I choose 'dog' from the same menu. I would like it to appear in the same text box along with my previous selection 'cat.' Is this possible? I'm very new to Java Script, any assistance would be greatly appreciated! Thank you

    She is the script I'm using
    (function () {
        // Do nothing if not committed
        if (event.willCommit) return;
        // Set up an array to hold the individual paragraphs of text
        var aQuotes = [3];
        // Populate the array with the paragraph text
        aQuotes[0] = "cat"
        aQuotes[1] = "dog"
        aQuotes[2] = "mouse"
        // Get the selected item, which is the export value of the selected combo box item
        var item = event.changeEx
        // Display the text corresponding to the selected item in the text field
        getField("Text field 1").value = aQuotes[item];

  • SSRS Text box expression in Report Header

    Hi Experts,
    I'm trying below expression under Text box (Report Header)
    = IIf( IsNothing(Parameters!vCp_ID.Value) OR Parameters!vCp_ID.Value = "", "All", Join(Parameters!vCp_ID.Value,", ") )
    It gives me error message as:- 
    Warning 1 [rsRuntimeErrorInExpression] The Value expression for the textrun ‘Header_Cp_ID_Value.Paragraphs[0].TextRuns[0]’ contains an error: Overload resolution failed because no Public '=' can be called with these arguments: 'Public Shared Operator =(a As String, b As String) As Boolean': Argument matching parameter 'a' cannot convert from 'Object()' to 'String'. C:\Users\abc1\Documents\Visual Studio 2008\Projects\Report Project1\Report Project1\ClaimsLevel.rdl 0 0
    Any help what I'm doing wrong? Because of this is it printing "#Error" while previewing the Report.
    If I remove IIF condition and place only:- 
    Join(Parameters!vCp_ID.Value,", ")
    than everything is working fine.
    Thanks in advance
    Kumar
    KG, MCTS

    Hi,
    Since this parameter allows selection of multi values, the values of the parameter is returned as an array which cannot be used in comparing with = operator, as you have in the expression
    Parameters!vCp_ID.Value = "".
    You may pass the first value of the parameter (element with 0 index) instead like
    Parameters!vCp_ID.Value(0) = "". Note the .Value(0). As such, you expression may be written as
    = IIf( IsNothing(Parameters!vCp_ID.Value) OR Parameters!vCp_ID.Value(0) = "", "All", Join(Parameters!vCp_ID.Value,", ") )
    Hope this helps. Please feel free to discuss if you have any other questions.
    Regards
    Please click "Mark as Answer" if this resolves your problem or "Vote as Helpful" if you find it helpful.
    BH

  • How to display Error for a particular text box programaticaly

    Hello All,
    I have 5 text boxes in a form and I have a requirement where if user click on any of the text boxes then i need to pass the id to class A and show the error description related to that text box in faces message.
    I have created class A in which i need to pass the id and get the error description but the problem is that the error description is in array list so i have created list of type class B which contains description.
    Right now in class A I have :-
    id ||||||||| description <>
    it1-------1.Invalid number
    -------2.Number not in use
    -------3.Number is out of range
    it2------1.error1
    2.error2
    3.error3
    and so on.....
    *public class ClassA {*
    public String Id;
    public List<ClassB> desc = new ArrayList();
    *public ClassA() {*
    super();
    *public void setId(String Id) {*
    this.Id = Id;
    *public String getId() {*
    return Id;
    *public void setDesc(List<ClassB> desc) {*
    this.desc = desc;
    *public List<ClassB> getDesc() {*
    return desc;
    *public class ClassB {*
    public String Description;
    *public ClassB() {*
    super();
    *public void setDescription(String Description) {*
    this.Description = Description;
    *public String getDescription() {*
    return Description;
    How do I pass the id and get the description for eg:- If id is it1 then How would I show all the 3 errors in faces message on value change.
    Please Suggest.
    Thanks in advance.

    your case is not clear.
    but this link may help you
    http://mjabr.wordpress.com/2011/08/31/how-to-show-multi-lines-afmessage/

  • Access of undefined property (dynamic text box)

    Hi guys,
    I have a movie clip working as a button that is disabled after click. I need to add a scoring option, so that on click it also adds to the score. When I add the scoreGame function, it says the text box is undefined. Ideas?
    Here's the code:
    package
              import flash.display.MovieClip;
              import flash.events.MouseEvent;
              public class DisablingButtons extends MovieClip
                        var labels:Array;
                        var thisParent:*;
                        var score:Number = 0;
                        var goalScore:Number = 8;
                        public function DisablingButtons()
                                  trace("it's working!");
                                  labels = this.currentLabels;
                                  this.addEventListener(MouseEvent.CLICK, scoreGame);
                                  this.addEventListener(MouseEvent.CLICK, disableButton);
                                  this.addEventListener(MouseEvent.ROLL_OVER, over);
                                  this.addEventListener(MouseEvent.ROLL_OUT, out);
                        function scoreGame(myEvent:MouseEvent):void
                                  score++;
                                  score1.text = String(score);
                                  if (score == goalScore)
                                            gotoAndStop(201);
                        function disableButton(event:MouseEvent):void
                                  for (var i:int = 0; i < labels.length; i++)
                                            if (labels[i].name == "disable")
                                                      this.gotoAndPlay("disable");
                                  this.removeEventListener(MouseEvent.CLICK, disableButton);
                                  this.removeEventListener(MouseEvent.ROLL_OVER, over);
                                  this.removeEventListener(MouseEvent.ROLL_OUT, out);
                        function over(event:MouseEvent):void
                                  for (var j:int = 0; j < labels.length; j++)
                                            if (labels[j].name == "over")
                                                      this.gotoAndPlay("over");
                        function out(event:MouseEvent):void
                                  for (var k:int = 0; k < labels.length; k++)
                                            if (labels[k].name == "out")
                                                      this.gotoAndPlay("out");

    When you instantiate the class in your fla, you would pass the textfield to the class...
    import DisablingButtons;
    var btn:DisablingButtons = new DisablingButtons(score1);
    addChild(btn);
    And in your class file you would need to adjust it to accept the textfield such as what I show below.  Just realize that I have manipulated the naming to preserve your score1 name at both ends of your code by naming the argument that the class sees differently (txt).  Otherwise I would have normally used a differewnt variable name within the class than score1
    package
              import flash.text.TextField;
              import flash.display.MovieClip;
              import flash.events.MouseEvent;
              public class DisablingButtons extends MovieClip
                        var labels:Array;
                        var thisParent:*;
                        var score:Number = 0;
                        var goalScore:Number = 8;
                       var score1:TextField;
                         public function DisablingButtons(txt:TextField)
                                  trace("it's working!");
                                  score1 = txt;
                                  labels = this.currentLabels;
                                  this.addEventListener(MouseEvent.CLICK, scoreGame);
                                  this.addEventListener(MouseEvent.CLICK, disableButton);
                                  this.addEventListener(MouseEvent.ROLL_OVER, over);
                                  this.addEventListener(MouseEvent.ROLL_OUT, out);
    etc...

Maybe you are looking for