Setting the name of a new object from a string

Is there anyway I can set the object name of a newly created
object from a string?
eg.
(the code below generates a compile time error on the
variable declaration)
public function addText(newTxt:String, txt:String,
format:TextFormat):void {
var
this[newTxt]:TextField = new TextField();
this[newTxt].autoSize = TextFieldAutoSize.LEFT;
this[newTxt].background = true;
this[newTxt].border = true;
this[newTxt].defaultTextFormat = format;
this[newTxt].text = txt;
addChild(this[newTxt]);
called using>
addText("mytxt", "test text", format);
I could then reference the object later on without using
array notation using mytxt.border = false; for example
There are many a time when I want to set the name of a new
object from a string.
In this example I have a function that adds a new text object
to a sprite.
The problem is, if I call the function more than once then
two textfield objects will exist, both with the same name. (either
that or the old one will be overwritten).
I need a way of setting the name of the textfield object from
a string.
using
var this[newTxt]:TextField = new TextField()
does not work, If I take the "var" keyword away it thinks it
a property of the class not an object.
resulting in >
ReferenceError: Error #1056: Cannot create property newTxt on
Box.
There must be a way somehow to declare a variable that has
the name that it will take represented in a string.
Any help would be most welcome
Thanks

Using:
var this[newTxt]:TextField = new TextField()
is the right approach.
You can either incrment an instance variable so that the name
is unique:
newTxt = "MyName" + _globalCounter;
var this[newTxt]:TextField = new TextField();
globalCounter ++;
Or store the references in an array:
_globalArray.push(new TextField());
Tracy

Similar Messages

  • How do I change the name of my new computer from "MacBook Air-2" to "iMac"?

    How do I change the name of my new computer from "MacBook Air-2" to "iMac"?

    Open the Sharing pane of System Preferences and change it.
    (95420)

  • I bought a new 5c and transferred from an old update from my iPhone 4.  The only issue I have is the name of my new phone.  How can I change it from Amyiphone4 to something else?

    I bought a new 5c and transferred from an old update from my iPhone 4.  The only issue I have is the name of my new phone.  How can I change it from Amyiphone4 to something else?

    settings - general - about - name - make the changes

  • Makin a new object from the file in activeX

    hi
    How can i make a new object from a file in ActiveX.
    i am Making an object of the following 
    C:\Program Files\Microsoft Office\OFFICE11\WINWORD in order to use Word in LabVIEW but when i use the property nodes, then no properties are being displayed.
    so further i cannot use Microsoft word. I dont want to use the Microsoft word in the CREATE DOCUMENT option of the ActiveX. This is because , from there, i cannot access the SPEECH function of the word.
    Help me out of this
    Somil Gautam
    Think Weird

    Duplicate² post: http://forums.ni.com/ni/board/message?board.id=170​&thread.id=437939&jump=true
    Somil: if you want to add something to an existing post then reopen that post, scroll down to the last entry and press "reply". Insert your new entry and then press "Post". Create a NEW post only if you want to start a NEW topic.
    By doing so there's a possibility to start a discussion rather than a one-way one-shot conversation. This increases the chance for you to get an answer to your questions and solutions to your problems.  
    Best regards
    chris
    CL(A)Dly bending G-Force with LabVIEW
    famous last words: "oh my god, it is full of stars!"

  • Java mapping - Setting the name of the file dinamically

    Hi all,
    Problem: I know how to set the name of the file in an Idoc to file interface if I'm using a message mapping, but not if I'm using a Java mapping.
    I'm using this code inside a user-defined function of the message mapping so that I can set the name of the file dinamically:
    public String GetFileName(String  inboundParameter,String IdocNumber,Container container){
    String filename;
    java.text.SimpleDateFormat dateformat = new java.text.SimpleDateFormat( "yyyyMMdd" );
    filename = "cikk_" + dateformat.format( new java.util.Date() ) "_" IdocNumber + ".txt";
    DynamicConfiguration conf = (DynamicConfiguration) container
           .getTransformationParameters()
           .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "FileName");
    conf.put(key, filename);
    return inboundParameter;
    (See also: /people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14)
    But how can I do that if I'm using a Java mapping??
    I don't have the class Container there. How can I retrieve the DynamicConfiguration object without that class?
    Thank you very much.

    Thank you Jin,
    I knew that it had to be related with the Map object got in setParameter, but in this link:
    http://help.sap.com/saphelp_nw04/helpdata/en/0f/80243b4a66ae0ce10000000a11402f/frameset.htm
    you can't find the constant DYNAMIC_CONFIGURATION.
    I think it's not up to date.

  • Setting the name of streamed zip file

    Hi,
    I have a servlet which creates a zip file with documents retrieved from a database. To create the zip file I am using the ZipOutputStream class and adding the documents one at a time to this object. This is all working fine.
    The problem I have is pretty simple, in that I can't seem to find a way in which to set the name of the zip file. This must be possible! At the moment it appears to be setting the name of the zip file to the name of the class that created it. In this case my class is called DocumentPacker and what comes back from the servlet is a zip file called DocumentPacker.zip. This wouldn't be so bad, but if you're creating the zip file for a user that does not have cookies enabled, it appends the session id to the end of the zip file name which i don't want.
    I am creating my ZipOutputStream like this:
    ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream()));
    and then adding the documents one at a time using a BufferedInputStream.).
    Any help on how to set the name would be much appreciated
    Thanks
    Claire

    Your servlet must set some headers on the HTTP response (Content-Type as "application/zip", Content-Disposition as "attachment; filename=yourfilename.zip")
    Read the RFC1806 document.
    Content-Type: application/zip
    Content-Disposition: attachment; filename=genome.jpeg

  • How to change the name of a Box Object in Crystal Reports 2008

    I am trying to change the name of a box object in a crystal report - 2008. This report was originally developed by consultants and requires that certain boxes be named according to a specific naming convention. I am making a change to the report and need to add a box with a name that matches the naming convention.  This is so some program functionality will work for the new box.  I can't contact the consultants because they don't work with our company anymore.
    Does anybody have any ideas? I've tried 'Format Box', but it won't let me change the name from there. I also tried it in the Report Explorer but to no avail.
    Thanks,
    Joanne

    Hi Joanne,
    Boxes do not actually have a 'name'. When you add a Box in a report, it will be called 'Box 1' by default. And the only place this name is visible is under the Report Explorer.
    Or do you mean to say 'Text Object'?
    -Abhilash

  • How to set the Default values for Info Objects in Data Selection of InfoPac

    Hi All,
    Flat file Extracion:
    How to set the Default values for Info Objects in Data Selection Tab  for Info Package
    ex: Fiscal Year Variant  Info Object having values 'K4' 'Y2' etc  in Flat file
    Initially  default value(not constant)  for this info Object value should be 'K4'  in Info Package
    If I set data selection value for this info object K4 it will retreive records with this selection only? how to handle
    Rgds,
    CV

    Hi,
    suppose as your ex. if you are having fiscalyear variant in the dataselection tab then specify K4 in the from column, again the ficalyearvariant row and click on insert duplicate row at the bottom . you will get another row . In that enter Y2 in the from column. now you can extract K4, y2 values .
    haritha

  • Set the name of cell or cells' range for a report and when export it to excel the names will be defined.

    Hello,
    I have an C# application that exports report from Reporting Services to Excel files.
    I would like to know if there is a possibility to set the name of the cell or range of cells in the report (via Report Builder or somewhere else) and when open the Excel the names are set. Similar functinality when you open the Excel and go Formulas/Define
    Name and set the name for a unique cell or range.
    Regards,

    Hi there,
    I don't believe this is possible in Reporting Services.  One workaround, if you don't know the exact range at runtime, might be to put hidden characters (white?) in your sheet at start and end of range, then do some postprocessing on the file using
    VSTO or perhaps a 3rd-party tool like this one.  
    http://www.aspose.com/reporting-services/excel-component.aspx
    If you do know the range it should be much easier.
    cheers,
    Andrew
    Andrew Sears, T4G Limited, http://www.performancepointing.com

  • I downloaded the new version of Mozilla and tried to install an add-on to allow me to set the home page for new tabs. The app says it has downloaded but does not open new tabs as my home page (google) - any suggestions what I can do?

    I downloaded the new version of Mozilla and tried to install an add-on to allow me to set the home page for new tabs. The app says it has downloaded but does not open new tabs as my home page (google) - any suggestions what I can do?

    I've been working on this all day!!! I've tried everything I know of and can't get it to load either. Sounds like lots of people are having problems. Here is what I have so far...I have uninstalled EVERYTHING on my pc from apple and reinstalled itunes to no avail. I have tried all sorts of things I've read as fixes online. NOTHING has worked. Here is something interesting that i have noticed though. my main pc (which is the one i have always managed my itunes account with for years) is a 32 bit system running windows 7. Yesterday I installed itunes for the first time on my new netbook which is a 64 bit (windows 7) system and it works just fine. i have three other laptops (all window 7) in my household that are all 64 bit operating systems and ALL have updated to 10.5 and THEY ALL work fine. this is FOUR 64 bit systems ALL updated w/10.5 that work and ONE that is a 32 bit that will not. Can't get any help from apple. their suppot *****! I want to get someone on the **** phone or a live chat but cant. *** APPLE????? please let mw know if you find SOMETHING i can try next. I'm out of ideas and patience!

  • Setting the name of a Workstation

    Hello,
    I am currently playing around with Java and Bluetooth, is it possible to set the name of the computer workstation so when the dongle is connecting to a device it does not show the actual name of the workstation.
    Cheers
    Mark

    Using:
    var this[newTxt]:TextField = new TextField()
    is the right approach.
    You can either incrment an instance variable so that the name
    is unique:
    newTxt = "MyName" + _globalCounter;
    var this[newTxt]:TextField = new TextField();
    globalCounter ++;
    Or store the references in an array:
    _globalArray.push(new TextField());
    Tracy

  • Find the names of all open forms from inside a PJC

    Hi,
    is it possible to find the names of all open forms from inside a PJC (pluggable java bean)?
    I have tried the window bean but it retrieves currently open windows and reads the title of each window, but what i need is to find the form name not the window title.
    oracle forms version: 10g
    Thank you
    Edited by: user542352 on Jun 26, 2009 1:07 AM

    You don't need to know names of all open forms to close them.
    Try to do someting like this :
    When you need to close all forms, set some global variable flag and call exit_form
    in WHEN-WINDOW-ACTIVATED of each form check your global flag and if set, also exit_form.

  • Setting the name of a file to be uploaded

    I'm having trouble setting the name that my uploaded files get when they are saved on my server. I upload the files useing the following:
    <html>
    <head>
    <title>File Upload</title>
    </head>
    <body>
    <%@ page import="java.io.*" %>
    <% if (request.getContentLength() <= 1)
    { %>
         <form method=post enctype="multipart/form-data">
         <input type=file name="file">
    <input type=submit value="Submit" name="Submit">
    <input type="text" name="fileName">
    </form>
    <%
    if (request.getParameter("Submit") != null)
    out.println(request.getParameter("file"));
    else
    String contentType = request.getContentType();
    String tempFieldType = request.getParameter("fileValue");
    if ((contentType != null)&&(contentType.indexOf("multipart/form-data") != -1))
    try
    ServletInputStream sis = request.getInputStream();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    int length = request.getContentLength();
    int read = 0;
    if (length != -1)
    for(int i = 0; i < length; i++)
    read = sis.read();
    baos.write(read);
    sis.close();
    String data = baos.toString();
    String origData = data;
    int boundaryStart = contentType.indexOf("boundary=");
    String boundary = contentType.substring(boundaryStart,contentType.length());
    boundary = boundary.substring((boundary.indexOf("=")+1),boundary.length());
    int gifStart = data.indexOf("\r\n\r\n")+4;
    int gifEnd = data.indexOf("--"+boundary,gifStart);
    File file;
    String filename = request.getParameter("fileName");
    out.print(filename);
    while(true)
    if (data.indexOf("image/gif") != -1) filename = filename+".gif";
    if (data.indexOf("jp") != -1) filename = filename+".jpeg";
    file = new File("C:\\"+filename);
    if(!file.exists())
    break;
    PrintStream pr = new PrintStream(new FileOutputStream(file));
    pr.write(baos.toByteArray(), gifStart, gifEnd-gifStart);
    pr.close();
    baos.close();
    catch(Exception exp)
    { out.println(exp); }
    %>
    </body>
    </html>
    I think my problem is in the <form method=post enctype="multipart/form-data"> this method is not letting me get the updated values of the text box fileName.
    Does somebody know how do get these values?
    thanks for you help,
    snnkmtt

    try to use jspsmartupload and see this post
    http://forum.java.sun.com/thread.jsp?forum=45&thread=81638&start=0&range=100
    thank you
    looking for ur solution
    all the best
    yours
    rajesh
    [email protected]

  • Setting the account your email is sent from

    I have followed the instructions for Setting the account your email is sent from, but it is not working.
    Email is not being sent from the account I have at the top of my list of accounts in my mail preferences.
    How do I fix this problem?
    IMAC G3   Mac OS X (10.3.9)  

    Copied from Mail Help:
    If you have set up multiple accounts in Mail, when you create a new message, the account the message is sent from is the one associated with the currently selected mailbox. If the current mailbox is listed in the On My Mac section of the mailbox list and is not associated with any particular account, then your message is sent from the first account listed in the Accounts pane of Mail Preferences.
    When you reply to a message, the From address is selected in the following order:
    The To and Cc fields are compared to email addresses you have set up in Mail Preferences. Mail uses the first address it finds as the reply address.
    If the message is in an account mailbox, Mail uses the email address for the account the mailbox belongs to.
    If all else fails, Mail uses the email address for the first account listed in the Accounts pane of Mail Preferences.
    Tiger Mail includes a default account selection for "send new mail from" regardless which mailbox is currently selected when selecting New to compose a new message.

  • Photostream needs the name of my new computer.  The old one died.

    How can I get the name of my new computer for photostream.  My old computer died and I have tried to find a way to tell my phone to send my photos to my new computer.  The Icloud is on and my photos have been transferred from my old computer but all the new photos are trying to go to the name of the old computer that is listed under settings.

    For Windows:
    Start > Control Panel > System and Maintenance > System > Computer, then look under Computer name, domain and workgroup settings. The computer name will be there.
    For Mac:
    The computer name is listed right below the Mac OS X apple logo on the login screen.
    Hope I helped.

Maybe you are looking for

  • Interval 01 was not created for number range object HRTEM_REFN

    Dear expert! Now, I'm getting some issues in Training and event management module. - The first, I created business event - Second, I process to book for business event by tcode: PSV1 --> book --> book/payment info --> activity allocation. But when I

  • How can i use the AND opperator to AND to arrays

    hi, i have two large arrays of booleans and i need to copy all the true values from array 1 to array2 without losing the trues that are already in array 2. From my knowledge of asm, i know that using the AND opperator is perfect for this, seeing as e

  • Purchased songs skip/jump in the middle of playback on my iPhone 3GS.

    Purchased songs skip/jump in the middle of playback on my iPhone 3GS. How can I fix this?

  • RS 232 with more than 1000 Hz

    I am trying to read out data from a serial port which is given out constantly by a measurement device at a predefined rate (up to 4000 Hz). It is connected via USB which creates a virtual Com-port with a baudrate of 921600. Communication works with t

  • Debugger stubbornly refuses to use correct IP address

    I'm trying to use SQL Developer 1.5.4 to debug a stored procedure. Sql Developer is running on my laptop: 192.168.8.148. My database server is running on 192.168.8.197. Another machine on my LAN. I'm trying to start a debugging session, I see Executi