Simple coding question: Adding variable to a string

I can't figure out what the syntax is for this in Actionscript. Basically, I have a variable I want to add into a string that will call a certain frame based on user's language selection. So...
var currentPage:int; <<this updates dynamically when nextPage, previousPage, etc are called
if (currentLanguage == "English") {
     myMovie.gotoAndStop ("English%n", currentPage);
else if (currentLanguage == "Spanish") {
     myMovie.gotoAndStop ("Spanish%n", currentPage);
Then each frame of myMovie will be named "English1" "Spanish1" "English2" "Spanish2" etc to correlate with page numbers.
Is this possible in Actionscript 3.0?
Thanks!

sure.  you can use a variable in place of the frame label and/or the scene name.  from your code, you're using a variable in place of the scene name.  that should work (if you're using scenes).
if you want to go to frame label english1, when currentPage is 1, you should use:
myMovie.gotoAndStop("english"+currentPage,possiblescenenamehere);
and because i don't think you're using scenes, just use:
myMovie.gotoAndStop("english"+currentPage);
or, even easier:
var currentPage:int;  // defined somewhere;
var language:String;  // defined somewhere;
myMovie.gotoAndStop(language+currentPage);

Similar Messages

  • Bizarre Question - Accessing Variables w/ a String

    Im obsessed with finding a way to do this, haha, but i dont know
    if its remotely possible.
    Instead of explaining it i will post some pseudo-code...
    class HackClass{
    int AVar = 1;
    int BVar = 2;
    int CVar = 3;
    // ...use some arbitrary method of getting user input
    String input = // user's input, in this case it is = "AVar"
    // and then what im trying to achieve...
    // im looking for something like this ---> (variable)input = 5;
    System.out.println("Avar = " + AVar); // this would output 5
    Note, this is very oversimplified. So though it would be easy in this example, i am not looking to register every
    variable in some table and then use some elaborate lookup function with the string, rather, is there a way to refer to a variable in code with a string?
    I cant imagine there is, but that would be WICKED.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Wow. Thanks for the code.
    Im writing test code now.
    You said this was "java-beanish"... is it reflection?
    Because the only way it compiles is if i import...
    import java.lang.reflect.*;also, in your code you never defined the variable 'object' in
    method.invoke(object, invokeParam);and for anyone else interested in the code - here is my test class:
    import java.lang.reflect.*;
    public class HackThis{
    public static void main(String[] args) {
         String var = "Var1";
         Integer value = new Integer( 1234 );
         HackThis ht = new HackThis();
         Class[] param = new Class[1];
         param[0] = value.getClass();
         Method method = ht.getClass().getMethod("set" + var, param);
         Object[] invokeParam = new Object[1];
         invokeParam[0] = value;
         method.invoke(object, invokeParam);
    public HackThis(){
    public Integer getVar1(){
         return Var1;
    public void setVar1(Integer i){
         Var1 = i;
         Integer Var1 = new Integer(99);
    }...but note it wont compile because 'object' hasnt been defined yet

  • Simple Coding Question

    Why am I getting exceptions...
    Exception in thread "main" java.lang.IllegalArgumentException: Cannot format given Object as a Date
    at java.text.DateFormat.format(Unknown Source)
    at java.text.Format.format(Unknown Source)
    at Ch2DateDisplay.main(Ch2DateDisplay.java:32)
    ....with the following code:
    import javax.swing.*;
    import java.util.*; //for Date
    import java.text.*; //for SimpleDateFormat
    class Ch2DateDisplay {
    public static void main( String[] args ) {
    Date today;
    SimpleDateFormat simpleDF1,
    simpleDF2;
    today = new Date();
    simpleDF1 = new SimpleDateFormat( );
    simpleDF2 = new SimpleDateFormat("EEEE MMMM dd, yyyy");
    //Default short format display
    JOptionPane.showMessageDialog(null, "Today is " +
    simpleDF1.format(today) );
    //Programmer-designated long format display
    JOptionPane.showMessageDialog(null, "Today is " +
    simpleDF2.format(today) );
    Any help would be appreciated.

    Also...srry about the multiple topics in one post....but I have these 2 individual java files that I want to merge and run together. Here they are individually:
    import javax.swing.*;
    import java.util.*; //for Date
    import java.text.*; //for SimpleDateFormat
    class DateDisplay {
    public static void main( String[] args ) {
    Date today;
    SimpleDateFormat simpleDF1;
    today = new Date();
    simpleDF1 = new SimpleDateFormat("EE-MM-dd-yy, hh:mm a\nDDD");
    //Default short format display
    JOptionPane.showMessageDialog(null, "Today is " +
    simpleDF1.format(today) +"th day in the year.");
    ....and
    import javax.swing.*;
    class HW1 {
    public static void main(String[]args) {
    String name, first, middle, last, space;
    space = " ";
    //Input the full name
    name = JOptionPane.showInputDialog
    (null, "Enter your full name (first, middle, last):");
         //Extract first, middle, and last names
    first = name.substring(0, name.indexOf(space));
    name = name.substring(name.indexOf(space)+1, name.length());
    middle= name.substring(0, name.indexOf(space));
    last = name.substring(name.indexOf(space)+1, name.length());
    //Output the name
    JOptionPane.showMessageDialog(null,"Your name is: " + first +
    " " + middle +" " + last + "\nReformatted: " + last +"," +" "
    + first +" " + middle.substring(0, 1) +".");
    Each of these works on its own but I want them together so that the output displays the date on top of the window and name below. How would I go about doing this? Thanks in advance.

  • Variable name to string

    Hi, I'm really new to TestStand, so this is probably an easy question:
    I'm using TestStand 4.5 and I'm trying to convert the name of a variable, Locals.MaxArrayIndex, which is a numeric variable, into a String, Locals.VarString.
    I know that the Str() function can be used to convert a numeric into a String, but how can I store the actual words "Locals.MaxArrayIndex" in a string?
    Thanks! 

    Hmmm...it works great for Parameters that are arrays, but for me it won't work if the Parameter is a numeric variable. Maybe I'm making a mistake somewhere else that I'm not picking up; so I attached the sequence file if you want to take a look at it.
    The issue arises in the 'Else' statement. I'm pretty sure the syntax in my function and popup are correct, but the String (ParamName) that is supposed to hold the value of the Parameter variable name (DataSelect) doesn't seem to ever be filled and outputted in the error message.
    I would really appreciate it if any of you guys could have a look at the file (I'm sure I'm making some kind of really rookie mistake)
    Thanks! 
    Attachments:
    GenerateError.seq ‏9 KB

  • Variable or Substitution String in Interactive Report Filter

    Background: I have an application that has a number of customized Interactive Reports where the Filter on the reports is set to a custom company name. When I install the application, I do not want to go through the reports and change the filter for the new company's name. The filters I need to change are all set by LOVs.
    Question: Is there a way that I can do one of the following:
    - associate a Filter with a Variable or Substitution String such that I can set that variable or string on login and then the user always sees the correct Filter displayed in the Interactive Report?
    - or is there a code method to update a sql apex table behind the scenes to reset the Filter to the new value. So that I could run that after installation as part of a customization / set-up time?
    System Info: 4.1.0.00.32
    Thanks,
    Stephen
    I used the IR_FILTER function, and while it allowed for a new filter to be set. It did not save the filter after logout or for other users accessing the Primary report. I could not find a SAVE Interactive Report function. So, my question still stands on looking for a method to set and save Filters programatically.
    Edited by: slsmith on Apr 19, 2012 8:07 PM

    Hi,
    I don't have access to an Apex 3 environment to check this, but I think that the Apex 4 Interactive Reports save the filters slightly differently and an attempt to mimic that functionality using IR conditions would fail.
    The only alternative I can think of right now is to have an additional column that returns 0 or 1 - eg:
    SELECT FIELD1,
    FIELD2,
    FIELD3,
    CASE WHEN (FIELD1 IS NULL OR FIELD2 IS NULL OR FIELD3 IS NULL) THEN 1 ELSE 0 END INCLUDE_NULLS
    FROM YOURTABLEand then apply a filter to INCLUDE_NULLS = 1
    Andy

  • Javascript variable names in strings

    This should be easy, but i can't find any info on how to do
    it!
    It's easy to put the contents of a variable into a string but
    how does one place the name of a Javascript variable into a
    string??
    The only solution i have found is to store the name
    separately as a string, but this isn't very neat.

    OK, simple statement first:
    Integer does not equal string.
    You also seem to be tossing around "runtime" and "static" somewhat liberally. Once you wire an integer (be it a control or block diagram constant) to the case structure's selector, the cases can only take on integer values. This is by design. If you wire a string, the case items take on string values. If you wire an enum, the case items take on the enumeration values. Once you've defined a case structure's cases you can't change them at "runtime". This, by definition, is different code.
    That said, it seems to me that you're looking for an enum.

  • Good practice to initalize all instance variables with type String to emptr

    Is it a good practice to initalize all instance variables with
    type String to emptry string?
    #1 approach:
    public class A
    { private String name = "";
    private String address ="";
    //etc...
    rather than
    #2 approach:
    public class A
    { private String name;
    private String address;
    //etc...
    When I read Java books, the examples don't usually do #1 approach.
    The problem is if we don't initialize to empty string, when we call
    the getter method of that instance variable, it will return null.
    Please advise. Thanks!!

    Please advise. Thanks!!It depends on your coding style. If you can avoid lots of checks for null Strings in the rest of the code then why not initialize to "".
    You have the same situation when a method returns an array. If you under circumstances return a null array reference then you have to always check for this special case, but if you return a zero length array instead you have no special case. All loops will just run 0 iterations and everything will work fine.
    So in general I guess the return of zero objects instead of null references really boils down to whether it simplicates the rest of your code by removing lots of extra checks for the special null case. This usage is especially favourable in the zero length array case. See Effective Java by Bloch, item 27.

  • Simple Quick Question

    wrong section, post was moved.
    Message was edited by:
    Rob17

    you titled "simple quick question"...
    .. complicated to answer..
    a) the TermsOfUse of the iTS don't allow any processing of purchased files, these are "copy protected"..
    b) iM has a voice-over function..
    c) iM is a video-edit app.. easy to use... just learn to handle it...
    d) iM allows to "extract" audio (=muting the original audio, adding your own..)
    e) to learn iM, spend some time here: http://www.apple.com/ilife/tutorials/imovie/index.html
    f) use pencil and paper first! WRITE and scribble, what shall happen when in your movie/parody... make a script, draw a storyboard .. THEN launch iM.. in other words: think first, then edit.. iM is just a tool, it does not "create"... Picasso needed a papertowel and half a stencil to create art....
    g) to get comfortable with iM, start with your own, small, short (3min!) project... import some stills, edit them, add a funny voice-over, add sounds, add music... good? make a bigger one...
    h) .. in our Lecture II, we teach you how to import shows from TV, youtube, wherever..
    standard disclaimer:
    be nice to ©opyrights ...

  • Simple drawString question

    Hi,
    Does anyone have a simple way to center a Graphics.drawString(string, x, y) operation?
    The x variable dictates the very left of the string object to be drawn.
    I'd like to be able to find out how wide my string will be in pixels when drawn so that I can allow for the string to be centered (at the moment, if I have x being where I want the center of my string, and use that in drawString then obviously my text is off center to the right of where I want it to be).
    I am sure this is a very very common problem, but I can't immediately fins anything in the API that will help.
    Please, any assistance would be most gratefully welcomed!
    - Peter

    import java.awt.*;
    public void paint(Graphics g){
    FontMetrics metrics = g.getFontMetrics();
    String text = "Demo Text";
    int txtWidth = metrics.stringWidth(text);
    int txtHeight = metrics.getHeight();
    int centerX = getX() / 2 - txtWidth / 2;
    int centerY = getY() / 2 - txtHeight / 2;
    g.drawString(text, centerX, centerY);
    }Remember, with Swing components, not to override paint. Override paintComponent instead. The above
    code would cause your component's border to disappear, for example.
    Also, FontMetrics stringWidth is not the best method to use. From its own API:
    Note that the total advance width returned from this method does not take into account the rendering
    context. Therefore, the anti-aliasing and fractional metrics hints can affect the value of the advance.
    When enabling the anti-aliasing and fractional metrics hints, use getStringBounds(String, Graphics)
    instead of this method.
    Here's an example, using TextLayout.
    import java.awt.*;
    import java.awt.font.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class Locator extends JPanel {
        private String text;
        public void setText(String text) {
            this.text = text;
            repaint();
        public String getText() {
            return text;
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            if (getText() == null)
                return;
            Graphics2D g2 = (Graphics2D) g;
            g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
            g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
            TextLayout tl = new TextLayout(getText(), getFont(), g2.getFontRenderContext());
            Rectangle2D bounds = tl.getBounds();
            int x = (int)((getWidth() - bounds.getWidth())/2-bounds.getX());
            int y = (int)((getHeight() - bounds.getHeight())/2-bounds.getY());
            tl.draw(g2, x, y);
        public static void main(String[] args) {
            Locator app = new Locator();
            app.setFont(new Font("Lucida Bright", Font.ITALIC, 36));
            app.setText("abcdefghijklmnopqrstuvwxyz");
            JFrame f = new JFrame("Locator");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            Container cp = f.getContentPane();
            cp.add(app);
            f.setSize(550,200);
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }

  • Simple query question

    hi all,
    I have a XMLType table with one column - I have presently one row, in my column xmlsitedata I have stored one large xml file.The schema definition is given below:
    <?xml version="1.0" encoding="UTF-8" ?>
    - <xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    - <xs:element name="siteList">
    - <xs:complexType>
    - <xs:sequence>
    <xs:element name="site" type="siteType" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    - <xs:complexType name="siteType">
    - <xs:sequence>
    <xs:element name="nameEn" type="xs:string" />
    <xs:element name="nameFr" type="xs:string" />
    </xs:sequence>
    <xs:attribute name="code" type="xs:string" />
    </xs:complexType>
    </xs:schema>
    I have executed the query below:
    select x.XMLSITEDATA.extract('/siteList/site/nameEn/text()').getCLOBVal() "stName" from wsitelist x;
    and I get all english names of some 200 locations, however, there is 1 row selected and all names show up on one row. How do I split them into 200 or whatever rows?
    Thanks,
    Kowalsky

    Have a look at the answer provided in the following thread.
    very simple XML question
    This may solve your problem.
    use xmlsequence.
    Alvinder

  • Assigning a node value from an XML variable to a String type  in Weblogic Process Integrator

    Hi,
    Is there any way to assign a node value from an XML variable to a String variable
    in Weblogic Process Integrator...
    Thanx.
    Narendra.

    Nerendra
    Are you talking about using Xpath on the XML document and assigning to a
    variable, it is unclear what you are asking
    Tony
    "Narendra" <[email protected]> wrote in message
    news:3bba1215$[email protected]..
    >
    Hi,
    Is there any way to assign a node value from an XML variable to a Stringvariable
    in Weblogic Process Integrator...
    Thanx.
    Narendra.

  • How to store serval char variables into a string variable?

    I have serval char variables, but i don't know how to put them together (without using arrays). I am thinking to store these char variables into a string variable but i don't know how to do it. For example,
    char letter1 = 'a', letter2 = 'b', letter3 = 'c';
    String letters;
    then how can i do to make letters = "abc" from using letter1,2,3?
    I am just a beginner of Java, if anyone can help me, i will appreciate that very much!!!

    String letters=""+leter1+letter2+letter3;is fine and dandy. What it actually compiles to is
    String letters = new StringBuffer().append(letter1).append(letter2).append(letter3).toString();Which ofcourse is much more code to write, but still good to know.
    So do see the API for java.lang.StringBuffer.
    Heikki

  • Simple/silly question: how do I set/change default font/color for outgoing mail messages?

    Simple/silly question: how do I set/change default font/color for outgoing mail messages?

    Just a suggestion..........
    Download Thunderbird.  Easier to use when it comes to what you want to do w/your emails. 

  • Geting a variable from a String

    Hi, i need to get a variable from a string. For example:
    int test1;
    int test2;
    int test3;
    int test = getvariablefromstring("test"+3);
    ..................

    Reflection will work for member variables, not locals. It'sprobably not the right solution for you though.
    If you just want test1, test2, test3, ... testN, then you want an array or a List.
    http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html
    http://java.sun.com/docs/books/tutorial/collections/

  • Question on Variables in OBIEE

    Hi,
    I am prasanna.I have a question on variables.
    Is it necessary to create a different connection pool for session variables? I am unable to use the same connection pool for both repository and session variables.
    can anyone help me.
    Regards,
    prasanna.

    Hi Prasanna,
    You can use the same connection pool by checking out “Allow First Connection for init block” to true
    For setting *“Allow First Connection for init block”* follow below steps :
    1. In the Administration Tool, select Tools, then select Options to display the Options dialog.
    2. On the General tab, select ”Allow First Connection for init block.
    But this option is not a best practice and might cause performance issues.
    Better think is to use Different connection pool for variables.
    Try this...

Maybe you are looking for

  • Why does my iphone randomly delete new contacts

    Over the last month I have noticed that some, maybe all...of the contacts that I have recently added to my address book have disappeared.  I know that I entered them into my phone.  I could even see where the name showed up on my recent's list.  Howe

  • How long will it take to install Illustrator on a fast computer?

    How long will it take to install Illustrator on a fast computer?

  • Ipod Classic Game cannot be launched

    I tried to play solitare, which comes on the ipod and recieved the above error message. Is there anything I can do before I reformat this thing?

  • ODI Zip

    Hi, Is it possible to use any zip utility ( Internal ODIZip and any other zip utility in the server ) if the agent is not running in that server? Thanks, Ramesh

  • Installation of Tiger on a PowerBook G4 17in - failing

    As the subject would suggest, I'm having troubles installing Tiger. My PowerBook went in to have its hard drive fixed as it had started developing errors. So, with a new hard drive installed (not by me, an Apple repair place) I have been trying to in