_global variable lost outside of function?

Vexing riddle: why are my global variables undefined outside
of the functions that use them?
Loading XML file and creating arrays from the child nodes.
Like this:
var modules:Array = this.firstChild.childNodes;
_global.moduleContents = new Array();
for (var i = 0; i<modules.length; i++) {
_global.moduleContents.push(modules
.attributes.contents);
then I have another function that recursively extracts each
index from _global.moduleContents array and pushes them into a
_global. pageContents array. (see attached code)
I made sure to use _global. in front of all global variables.
The code workd flawlessly in itself. I am able to trace the whole
array or single array indices from within the functions.
But they are undefined outside of the functions! I checked to
make sure there is no local variable of the same names - in every
case I use _global before the variable name.
The crazy part of it is I tried testing some simple functions
with global variables in a new movie to understand the scope issues
and they worked fine!
function messages() {
_global.greetings = ["hello", "hi", "how are you?"];
function sayHi() {
_global.greetings.push("how goes it?");
sayHi();
messages();
trace("this is outside: "+_global.greetings);
Why not in this:

Gotcha, what is happening is that you call a loading script
that basically works in the background of other scripting
operations, you can call multiple load actions and they will all
execute at the same time, because you have your trace call after
the load action and you are not waiting for that file to be loaded
you are getting an 'undefined' var.
You may want to put something in at the end of all of your if
(success) statements like
_global.docstructureLoaded = true;
checkLoadStatus();
then say this on your next load function;
_global.pageContentsLoaded =true;
checkLoadStatus();
then in your root area
checkLoadStatus(){
if(_global.pageContentsLoaded==true && .... ){
//when all your loads are done do this ...
Just to make sure that you arn't calling any other functions,
or moving your timeline ahead before your data gets to the right
place.

Similar Messages

  • Loading Variables in a Class Function

    I am having problems loading variables from an external text
    file inside of a class function. The text file has been created
    properly, and the code that I use in the class is as follows:
    _root.createEmptyMovieClip("texRules", -100);
    loadVariables("texRules.txt", _root.texRules);
    m_Rules = _root.texRules.rules;
    I create an empty movie clip on the root frame named
    texRules, load the variables into that movie clip with the next
    line and then set my member string value equal to the text file
    variable named rules. When I run the program, I get an undefined
    for my m_Rules.
    Here is my texRules.txt:
    rules=THESE ARE THE TEXAS HOLD'EM RULES.
    Any ideas as to what I am doing incorrectly?

    I've opted to use the LoadVars instead of creating an empty
    movie clip and loading the variables there. Here is my new code.
    public function setRules():Void
    var rulesLoader:LoadVars = new LoadVars();
    rulesLoader.onLoad = function (success:Boolean):Void
    if (success)
    trace(rulesLoader.rules);
    this.m_Rules = rulesLoader.rules;
    else
    trace( "Unable to load external file.");
    rulesLoader.load("texRules.txt");
    Here is where I define my properties of my class:
    class TexHoldem extends Game
    //Class member properties
    //Private Properties
    private var m_Rules:String;
    private var m_Target:MovieClip;
    Here is my constructor:
    public function TexHoldem(target)
    this.m_Target = target;
    super("Texas No Limit Hold'Em", 0, 1);
    setRules();
    The setRules function works fine, the only problem now is
    that I can't save the variables once the onLoad function goes out
    of scope. I've thought of modifying it so that it returns a type,
    but that seems difficult. The two easiest solutions I see is to
    create an empty text field that holds the string or find a way to
    get the rulesLoader.rules outside of the onLoad scope. Any
    suggestions now? Sorry to change the problem on you.

  • Why do I have to declare my int outside the function?

    `Hi!
    I've writen the very simple class get_results with one methode test:
    public class Get_results {
       protected int nb=0;
    public int test(int numb) {
             //int nb=0;
             nb=numb;
             return nb;
               }//End test
    }//End classthis methode will be called from a jsp file:
    <jsp:useBean id="results" scope="session" class="mypackage.Get_results" />
    <%= results.test(3) %>I don't understand why I have to declare int nb outside the function test. If I declare int nb at the beginning of the function and not right at the beginning of the class
    public class Get_results {
    public int test(int numb) {
             int nb=0;
             nb=numb;
             return nb;
               }//End test
    }//End classthe it doesn't work. I don't understand why since I only need the int nb in the test methode and nowhere else in the class.
    can anyone explane this to me?
    thanks.
    Message was edited by:
    ChristopheD
    Message was edited by:
    ChristopheD

    I get this message:
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: 2
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    java.lang.ArrayIndexOutOfBoundsException: 2
         org.apache.jsp.grammaire_002dresults_jsp._jspService(grammaire_002dresults_jsp.java:219)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
    Message was edited by:
    ChristopheD

  • DS 1.3 changing the value of a variable in a planning function

    Hello,
    i created a planning application with Design Studio 1.3 and one of my planning functions is a revaluation function which uses a variable for the revaluation factor. In Analysis for Office you can set a value for this factor by selecting the planning function and then give a fixed value or set a reference to a cell in your workbook. However in Desing Studio i don't see my variable under my planning function and i also couldn't find a script command to use for this problem because the variable is not known to Design Studio. Right now i can only set a default value for the variable in SAP BW (RSPLAN) but i would like to let the user enter a value at runtime of my application.
    Anyone already had a similar problem and can confirm that it is not possible to access variables used in planning functions or has found a way and can tell me how to achieve this?
    Greetings,
    André

    Hi Andre,
    we are using the revaluation function type, too.
    For setting the variable for the factor you should use the following script:
    <ds_planningsequenceOrFunctionAlias>.setVariableValueExt("<techNameOfTheVariable>", <value>);
    It could be possible, that you cannot see the variable in the value help (strg + space) after inserting the planning sequence or planning function to your Design Studio application.
    Please, enter the technical name of the variable manually, it should work.
    We have no problems. In our application the variable is filled by an input field value.
    Kind regards
    Patrick

  • How to use variable in the LIKE function along with % operators

    Hi,
    Is there any way i can use the variable in the Like function. That means i have query like
    SELECT * FROM Device WHERE DeviceName LIKE %v_MediaName%;
    Here "v_MediaName" is the userdefined variable which contains string. I want to retrieve all the records from the "DEVICE" table whose DeviceName LIKE %v_MediaName%;
    If i put it in a single quotes '%v_MediaName%' then the v_MediaName will be treaded as a string instead of a variable. I am using this query in a Procedure.
    please help me out to resolve the issue.
    thanks

    LIKE '%'||v_MediaName||'%';
    Will not make use of the indexes though.
    Message was edited by:
    satishkandi

  • How can I pass variable to eventdriven startElement() function?

    I am new to java and SAX. Could anybody tell me how to pass variable to eventdriven startElement function? I tried the following code but didn't work.
    public class ReadXmlSax extends DefaultHandler
    String elementName;
    String requestName;
    Vector v = new Vector();
    public Enumeration getAttribute(String sFileName, String sTagName, String sAttrName)
         Enumeration e;
         elementName=sTagName;
    requestName=sAttrName;
    File f = new File(sFileName);
    // Use an instance of ourselves as the SAX event handler
    DefaultHandler handler = new ReadXmlSax();
    // Use the default (non-validating) parser
    SAXParserFactory factory = SAXParserFactory.newInstance();
    try {
    // Parse the input
    SAXParser saxParser = factory.newSAXParser();
    saxParser.parse(f, handler);
    } catch (Throwable t) {
    t.printStackTrace();
    e = v.elements();
    return(e);
    //===========================================================
    // SAX DocumentHandler methods
    //===========================================================
    public void startDocument()
    throws SAXException
    public void endDocument()
    throws SAXException
    public void startElement(String namespaceURI,
    String sName, // simple name
    String qName, // qualified name
    Attributes attrs)
    throws SAXException
              //System.out.println(elementName);
              if (qName.equals(elementName))
                   String serverName = attrs.getValue("",requestName);
                   v.addElement(serverName);
    }

    I attached the main call the ReadXmlSax class. I added the
    "system.out.println(elementName);" in the function getAttribute and startElement as well. I got printing out "name" for elementName from function getAttribute but got others printing out "null" for elementName from function startElement. Any suggestions? thanks
    import java.io.*;
    import java.util.*;
    import ReadXmlSax;
    public class ReadElement
         public static void main(String argv[])
              ReadXmlSax r = new ReadXmlSax();
              Enumeration e = r.getAttribute("dre.xml","server","name");
              try{
                   while (e.hasMoreElements()) {
                   System.out.println((String)e.nextElement());}
              }catch(Throwable t){
                   t.printStackTrace();
    <strong>test</strong>

  • How can I access JSP variables from a JavaScript function in a JSP page?

    Respected sir
    How can I access JSP variables from a JavaScript function in a JSP page?
    Thanx

    You may be get some help from the code below.
    <%
        String str="str";
    %>
    <script>
        function accessVar(){
           var varStr='<%=str%>';
           alert(varStr);// here will diplay 'str'
    </script>

  • Variable screen in Planning Function for Integrated Planning

    Hi all.
    I have created a planning application with the WAD, based on an Input_ready Query. Manual planning works fine and even planning functions go well, using the command wizard.
    However, if I try to use a variable in a planning function and I set the parameter to pop-up the variable screen within the command wizard for a planning function, I get an 'uncaught exception'. An almost blank IE-window pops up which is supposed to display the variables, but it fails.
    Does anybody know how to solve this?
    Gr.,
    Marc.

    Hello Marc,
    do you still have this error? I encountered the same problem with SPS 9. Maybe you should install at least SPS 10. The variable popup works correct there.
    Best regards
    Martin

  • Access payroll variables from custom payroll function

    Hi All,
    I have a requirement to create a custom payroll function that returns some data from IT0006 and IT0032.
    I have written the code in PCBURZDE0, as the payroll is for Germany, it does read the data needed.
    My question is, how I can access the variables specified for the function in the payroll schema.
    Schema definition in PE01
    Zeile     Fkt        Par1  Par2 Par3 Par4 D Text
    000010 BLOCK BEG                              Fahrradleasing
    000020 _DFRD &PRO GEN
    000030 BLOCK END
    If I double-click Par1 for function _DFRD (&PRO), then I see he two variables I should write the data to:
    Zeile  VarArg. FZ T Operation        Operation Operation Operation Operation Operation *
           -------------+---------+------------------+---------+---------+---------+---------+
    000010                  AMT= PKWWRPRINT     *
    000020           1     AMT= ENTKM  PRINT
    So, as I understand I should write the two variables PKWWR and ENTKM, I have the values in the function code, but I don't know how to access these variables.
    Thanks for your help!
    Gyöngyi

    1 - PIT is a Function that is used in the Payroll Schema to "Process the Internal Table".
    2 - You mentioned that you had created a Custom Function to read IT0006 and IT0032, and I only suggested to you that you could have that Custom Function generate Information WageTypes and save them in the Input Table where they could then be used in PCRs.
    3 - I did not mention that you can read only one value through operation AMT, but I mentioned that using AMT=xxxxxx followed by AMT=yyyyyy means that the first statement is useless.  On the other hand, using AMT=xxxxxx followed by AMT+yyyyyy and AMT+zzzzzz will result in the amount being the total of the 3 values.
    4 - Please read some documents on Schemas, Functions and PCRs, such as in the Wikis on this site, and study your current Payroll Schema, it's sub-schemas, it's functions and the operations in it's PCRs.  Note that t-code pe01, pe02 and pe04 can be used to find some documentation on functions and operations.

  • Variable problem in a function module

    Hi all,
    I'm writing a function module FM1 via SE37.
    Data A type I.
    Function FM1.
      perform x.
    Endfunction.
    Form x.
    Endform.
    The system warned me that variable A has been defined,
    is that becoz I've defined variable A in another function module within the same function group?

    Hi macy,
    1. If we declare any variable
        before any function defitinoin,
      (just like u have done)
    2. Then, it is as good as
       GLOBAL VARIABLE
    (which can be accessed via all fm in that group)
    3. Hence, your error is coming.
    4. Either give another name to your variable,
      or
      change the POSITION of the variable definition,
      (in the other FM)
    5. ie.
      WRITE BELOW THE FUNCTION DEFITNIION.
      FUNCTION MYFUNC.
      data :a type c. <----
      ENDFUNCTION
    6. not like this.
      data :a type c. <----
      FUNCTION MYFUNC.
      ENDFUNCTION
    regards,
    amit m.
    Message was edited by: Amit Mittal

  • JUnit Test Debug: Static variable lost value!!!

    Hi, I am writing JUnit code.
    env: JDeveloper + JUnit Plugin + Selenium RC
    While I am debugging, I found the static variable lost between 2 different test, I mean a test is a @Test, do somebody know why??
    Thank you very much!!

    1.) The File you initialize in the method is not the same as the instance file variable that you initially initialized to null. You declared a new File in that method.
    2.) Read about layout managers. The behavior you are seeing is because of the default layout manager's behavior.

  • I have suddenly lost the scrolling function in mail. In all other programs it still works. Can anyone provide a solution?

    I have suddenly lost cthe scrolling function in mail and cannot scroll down an individual email or the list of emails in a box. The scrolling function is perfectly okay in all other programs. Can anyone help, please?

    Disclaimer
    The Author of this posting offers the information contained within this posting without consideration and with the reader's understanding that there's no implied or expressed suitability or fitness for any purpose. Information provided is for informational purposes only and should not be construed as rendering professional advice of any kind. Usage of this posting's information is solely at reader's own risk.
    Liability Disclaimer
    In no event shall Author be liable for any damages whatsoever (including, without limitation, damages for loss of use, data or profit) arising out of the use or inability to use the posting's information even if Author has been advised of the possibility of such damage.
    Posting
    Another example would be a p2p link between two L3 switches.

  • How to access _global variables in different domain

    hi
    i am loading a swf in local and this has to be communicate the swf which was in the server(different domain). using the system.security.allowdomail i can access the variables, but i can't able to access _global variable.
    Pls tell how to access _global variable in different domain
    Thanks in advance
    @flash

    Ganesh,
    It should work the way you mentioned it. I don't see why it
    didn't unless there is a spelling mistake or something. If there
    is you should have a got an error message. :-)
    I actually don't recommend using globals at all, I would rather
    use a PL\SQL Package Specification to define Global Variable.
    These variables are valid for the duration of the Session and
    they are restricted to Char(255) limit. It reduces the number of
    mistakes when converting dates and Such. It also forces the
    developers to place all the globals in one place instead of
    multiple places. Read Feurstein's book on PL\SQL Programming for
    more details.
    Sunil
    MS Ganesh (guest) wrote:
    : Hi Steve,
    : I know how to assign values to global variables.
    : I did the following
    : Form Name : FIRST_FORM
    : :global.group_id := 'SUPERVISOR'
    : call_form('SECOND_FORM');
    : In Second Form
    : When New Form Instance
    : Message(:global.group_id);
    : No message is displayed.
    : Please explain to me the steps in detail.
    : Thanks in advance.
    : Bye
    : MS GANESH
    : Steve (guest) wrote:
    : : Just assign value to global variable i.e.
    : : :global.foo := 'anything'; or
    : : COPY('anything', 'global.foo');
    : : to remove global variable
    : : ERASE('global.foo');
    : : Note: global variables are always VARCHAR2(255);
    : : MS Ganesh (guest) wrote:
    : : : Dear OTN Members,
    : : : I would like to pass values between forms,
    : : : I know it is possible to do it by using Parameters.
    : : : But I would like to know how to use global variables to
    : : : accomplish the same task.
    : : : Thanks in Advance.
    : : : Bye
    : : : MS Ganesh
    null

  • With installation of 10.1 I lost finder search function. The finder window appears, but no matter what I put in the search window, nothing is found. I re-installed it with initial success, but it failed again very soon.

    With installation of 10.1 I lost finder search function. The finder window appears, but no matter what I put in the search window, nothing is found. I re-installed it with initial success, but it failed again very soon.
    MacBook Pro (15-inch, Mid 2010)
    OS X 10.10.1

    Hey Reoh, 
    Thank you for contributing to the Apple Support Communities. 
    If searching for files in Finder doesn't return any results, try using the steps in this article to reindex the Spotlight search index of your MacBook Pro hard drive:
    Spotlight: How to re-index folders or volumes - Apple Support
    Sincerely,
    Jeremy

  • I lost the camera function. I get a dark blank screen.

    I suddenly lost the camera function on my iPod touch. When I tap the icon I now get a dark blank screen. Any easy solution?

    Had the same problem on vacation. Decided to google it. So glad the Support Center was there to help. What a quick fix. Camera function is working again. Have to confess I did not know the sleep button was the little button on the topside right of the ipod.

Maybe you are looking for

  • How do I connect an external HD camera to my MacBook Pro?

    I have a Sony HD camera using HDMI output, going to a Thunderbolt adapter, into my MacBook Pro.  How do I use my MacBook Pro as an external monitor for the video camera?  When using iMovie, only the MacBook internal camera is available.  When using F

  • Nothing happens when i type a subject in the status bar

    when I type a subject or something I want to find e.g. wikipedia or red sea, dogs etc in the box in middle of screen, nothing happens. I am not rerouted to any page. The only way I can access a page is to write the address in the menu bar at the top

  • Muse CC 2014: Text box position not rendering accurately

    While trying to get into Muse CC 2014, i just did a most simple intro page for some friends who want to start their first online business. I am a total stickler for single pixel precision, but when i uploaded the simple design to their server, the ta

  • Using distinct in where clause

    Greedings, I am trying to execute some kind of distinct using rowid in where clause but for some reason im not getting the appropriate result. Any guidance is welcome SELECT acnt_code,cat,cat_desc,buc FROM so_budgets_cat where Trim(buc)='S03' and NOT

  • Fresh Install Mac - Licensing for this product has stopped working  Error: 6

    We just got the new macbook pro refreshes at work and decided to make the switch to standalone CFBuilder.   We downloaded the trial and installed.  On launch we get this error, "Licensing for this product has stopped working  Error: 6".  Every macboo