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.

Similar Messages

  • Please help me understand making and loading variable classes

    Hi guys ,
    I know that I am stupid but I just can't get this!  AS3 says you need to load variables into a class?  Please please give me a simple example
    my variables look like this... (the whole point of playing around with variables was that if I had to make a change I could access one place and change them...
    but now I realse that I can't access or call them outside the movie clip they are in:(
    please hlep me!
    var ans1="";
    var ans2="";
    var w1="ABN";
    var def1="An ABN (Australian Business Number), is a personal number for your business that makes it easier and quicker to deal with  government and other businesses.";
    var w2="ACN";
    var def2="An ACN is an Australian Company Number, which is a special number that each company gets to identify it.  No two companies can have the same ACN";
    var w3="Action Plan";
    var def3="A business Action Plan will show What needs to be done and When it needs to be done by."
    var w4="Advertising";
    var def4="Advertising is producing information to let people know about your business and try to increase sales."
    var w5="Promotions";
    var def5="Promotions are where your business tries to increase the sales of a particular item through offering a good deal, advertising or a special display.";
    var w6="Benefit";
    var def6="A benefit is something good that you get.  One benefit of doing exercise is getting fit, another benefit is losing weight.";
    var w7="Business Mentor";
    var def7="A business mentor is a trusted guide. Someone who has experience and has been successful in business and can help and advise you.";
    var w8="Business Name";
    var def8="A Business name is the name a business uses to do its work.  It lets customers know who you are.";
    var w9="Business Registration";
    var def9="When you start a business you need to register your ABN, you may need to register your business name.";
    var w10="Cash flow";
    var def10="Cash Flow for a business is having enough cash saved to be able to pay your bills when they are due.";
    var w11="Characteristic";
    var def11="The characteristics of something are describing words about that thing.";
    var w12="Charges";
    var def12="A charge is something you have to pay, an expense.";
    var w13="Company";
    var def13="Is the same as a corporation. A company is a type of business that needs to be registered (either State or Federal) and has special legal status.  A company can put Pty. Ltd after it’s business name.";
    var w14="Competitor";
    var def14="A competitor is another business that is challenging you for customers.";
    var w15="Constitution";
    var def15="A constitution in business is a list of rules and principles that a company has agreed to follow.";
    var w16="Corporations Aboriginal and Torres Strait Islander Act";
    var def16="In the 1960s and 1970s, various reviews advised the Australian Government of the need for legislation to make it easier for Indigenous communities and organisations to form corporations. As a result, the ACA Act was passed, allowing Aboriginal and Torres Strait Islander groups to form corporations for any social or economic purpose.";
    var w17="Corporations Act";
    var def17="The Australian Securities and Investments Commission (ASIC) have laws that apply to corporations and these are found in the Corporations Act.";
    var w18="Cultural knowledge";
    var def18="Cultural knowledge is special information that is held by a particular cultural group, this could include technologies (e.g. special ways of using materials, making and using tools), stories, language and song, cultural rules, taboos, regulations and oral history.";
    var w19="Customer";
    var def19="The customer is someone who is buying something from a business.";
    var w20="Debt";
    var def20="Is something that you have to pay back. If you borrow 20 dollars you have a $20 debt.";
    var w21="Direct competitor";
    var def21="Is selling exactly the same thing as your business and competing for your customers.";
    var w22="Dividend";
    var def22="A dividend is money that is paid to shareholders regularly out of the company’s profits.";
    var w23="(Microsoft) Excel";
    var def23="Microsoft Excel is a computer program that lets you keep lists of numbers and also add up totals and do other sums to those numbers.";
    var w24="Fees";
    var def24="A fee is something that you have to pay, an expense.";
    var w25="Financial Management";
    var def25="Financial Management is the planning, organising, checking  and controlling of the income, expenses and Tax for a business.";
    var w26="Franchise";
    var def26="A franchise is a type of business you can buy. When you buy a franchise you set up the same type of business that has been successful somewhere else.";
    var w27="General ledger";
    var def27="A general ledger for a business is where all of the income and expenses for that business are kept in a document.";
    var w28="Goal";
    var def28="A goal is a target that you set yourself or your business.  Something that you want to achieve.";
    var w29="Growth opportunity";
    var def29="A growth opportunity is a chance for a business to get bigger.";
    var w30="GST";
    var def30="The Goods and Services Tax is paid when you buy things. Some items like food and medicine do not have the Goods and Services tax charged to them.";
    var w31="ICN";
    var def31="Indigenous Corporations Number is a special number given each indigenous corporation to identify it. No two indigenous corporations can have the same ICN.";
    var w32="Incorporate";
    var def32="Incorporate is what people do when they create a company or corporation.";
    var w33="Indirect competitor";
    var def33="An indirect competitor is selling a similar product or service to your business.  E.g. If you had a pizza shop, a fried chicken shop is an indirect competitor because it sells food and your customers might want to eat chicken instead of pizza.";
    var w34="Labour";
    var def34="Labour is all the work done by people (including you) in your business.";
    var w35="Legal name";
    var def35="Your Legal Name is the name that is on your Birth Certificate.";
    var w36="Legal protection";
    var def36="Legal protection means you are protected under the law from certain things happening.";
    var w37="Legal structure (business)";
    var def37="Legal structure is the type of business, sole trader, company, partnership.";
    var w38="Liability";
    var def38="A liability is something you are responsible for.";
    var w39="Licence";
    var def39="A license is proof that you have permission to do something.  For example, if you have a driving license you can drive a car.";
    var w40="Lodge";
    var def40="To lodge a form means to send it to where it has to go.";
    var w41="Manufacturing";
    var def41="A manufacturing business makes things.";
    var w42="Marketing budget";
    var def42="A marketing budget is the amount of money you have set aside for advertising and promotion for your business.";
    var w43="Minor criminal convictions";
    var def43="A minor criminal conviction is something small you have been in trouble over with the police.  Shop lifting is an example of a minor criminal conviction. ";
    var w44="MYOB";
    var def44="MYOB is financial management software for business.";
    var w45="Networks";
    var def45="A network for business is all of your contacts, customers and the people you know through doing business. ";
    var w46="Obligations";
    var def46="Obligations are things you are responsible for.";
    var w47="One off";
    var def47="A “one off” cost is something that only needs to be paid for once.";
    var w48="Operating budget";
    var def48="The Operating Budget is a record of the income and expenses of a business.";
    var w49="Overheads";
    var def49="Overheads are the expenses or costs in running your business, the things you have to pay for.";
    var w50="Partnership";
    var def50="A partnership is where two or more people own and run a business.";
    var w51="Permission";
    var def51="Permission is where you ask if you can do something.  If you ask and the person, group or council and they say yes, you have permission.";
    var w52="Permit";
    var def52="A permit is a special license or permission to do something";
    var w53="Personal assets";
    var def53="Personal assets are things that you own, like your car, house and furniture.";
    var w54="Personal protection";
    var def54="Being part of a company offers the shareholders some personal protection from legal and debt liabilities. This means that they have less responsibility than a Sole trader.";
    var w55="Photo identification";
    var def55="Photo Identification is a document that shows who you are and has your photo on it, like a Driver’s License, 18+ card or a passport.";
    var w56="Postal address";
    var def56="Your postal address is the address where you get your mail sent.  It might be different to the address where you live.";
    var w57="Pricing structure";
    var def57="Pricing structure is where prices for something can change depending on how much the customer orders.  The bigger the order the cheaper the price becomes.";
    var w58="Private";
    var def58="Private means not part of government.";
    var w59="Profitable";
    var def59="Profitable means that there is money left over after a business pays for all of its expenses out of the money it has made.";
    var w60="Promote";
    var def60="When you promote something you try to advertise or increase the amount of people who know about it.";
    var w61="Public liability insurance";
    var def61="Public Liability Insurance gives legal protection to the business owner against getting sued by a member of the public for things like injury or property damage. ";
    var w62="Quickbooks";
    var def62="Quickbooks is financial management software for business. ";
    var w63="Registered";
    var def63="Registered means that you have recorded your information on an official list.  You register your car to be able to drive it on the road.";
    var w64="Regulations";
    var def64="Regulations are rules or laws that control what you can and can’t do.";
    var w65="Retail";
    var def65="Retail is where things get sold in small amounts to customers.  Retail usually happens in a shop and the prices are higher.";
    var w66="Service";
    var def66="A Service business provides a service, like lawn mowing or accounting services.";
    var w67="Shareholders";
    var def67="Shareholders are people that own part of a company.";
    var w68="Sole trader";
    var def68="A sole trader is where one person owns and runs a business.";
    var w69="Start up budget";
    var def69="A Start Up Budget is the first Budget that gets done for a starting business and includes all of the costs involved in setting up the business.";
    var w70="strategy";
    var def70="A strategy in business is a plan of attack, or a plan of how to get something done.";
    var w71="system";
    var def71="A system is business is a set of detailed plans and rules for how to do something in your business.";
    var w72="Vision";
    var def72="Vision in business is being able to imagine and see something in the future.  To set up a new business you need to be able to see something new that wasn’t there before.";
    var w73="Wholesale";
    var def73="Wholesale is where things get sold in large amounts, usually for a cheaper price. The Wholesale price. A wholesaler is usually a big shed where goods are stored. Wholesale is not usually available to just anyone.";

    no, that's not a reason you would use a class file.
    anyway, your document class variables are defined on the main timeline so to reference them from any timeline you can use:
    MovieClip(root).w36;  // for example  (but it's really undesirable to have coding in more than one timeline)

  • Static Class Function vs. Instance Variables

    I'm making a Wheel class to spin the wheels on some toy
    trains as they move back and forth.
    Each wheel on the train is an instance of the Wheel class and
    there are several of them.
    I thought it would be great to just have a static class
    function to tell all the Wheels to start turning:
    Wheel.go();
    The Wheel class keeps a static array of all of its instances
    so I thought I would just loop through all of those instances and
    issue the wheelInstance.roll() method.
    So far it all works. But I was planning to use a setInterval
    to call the roll() method and each instance has its own rollID
    property that I would like to assign the setInterval ID to. Here is
    the problem.
    Since the rollID is an instance property I can't access them
    from a static class function. Is there any way to do this?
    Currently I"m just using an onEnterFrame which doesn't require me
    to use the instance properties.

    Technically yes, realistically for this class no.A
    class will probably take several hundred bytes at
    least to load, with no data of your own. So adding4
    bytes for a int is less than 1% of the total size.
    And if you are loading millions of differentclasses
    then you should rethink your design.If you don't instantiate the class when you reference
    a static variable why would you consume memory for the
    class other than the variable itself? I don't
    understand what you are talking about with the
    "millions of different classes", it's not germane to
    the question. Bottom line, referencing a static
    variable more than once will save memory.Using a class, static or by instance, requires that the class be loaded. A loaded class creates, at the very least, an instance of java.lang.Class. Any static members of the class are in addition to the storage space needed for the instance of java.lang.Class and for any internal storage needed by the JVM in addition to that.
    Thus if one has a static data member when the class is used in any way, the static data member takes storage space. However a member (non-static) does not take storage space.
    Of course the meta data for the member could take as much space as the static member so the point could be moot. Is that what you were referring to?

  • [svn:bz-trunk] 20936: Pass in the MessageBroker class loader to the FactorySettings:: createFactory() function.

    Revision: 20936
    Revision: 20936
    Author:   [email protected]
    Date:     2011-03-21 13:40:50 -0700 (Mon, 21 Mar 2011)
    Log Message:
    Pass in the MessageBroker class loader to the FactorySettings::createFactory() function.
    The supports situations where the MessageBroker class loader is not the same as the one that loaded ClassUtils (e.g. OSGi).
    Modified Paths:
        blazeds/trunk/modules/core/src/flex/messaging/config/FactorySettings.java
        blazeds/trunk/modules/core/src/flex/messaging/config/MessagingConfiguration.java

    SpryAccordion.css
    You have an error that is killing the rest of your code shown below in red.  Remove it.
    .AccordionPanelContent {
        margin: 0px;
        padding: 2px; /**suggest using 12px or more**/
        background-image: url(../infobkgd.png);
        background-attachment: fixed;
        background-repeat: repeat;
        font-family: Verdana, Geneva, sans-serif;
        font-size: 12px;  /**suggest using 16px or more**/
        color: #FFF;
        overflow: hidden;
        height: 40
    [x;
        height: 100%;
    Nancy O.

  • How to pass a variable from one class to another class?

    Hi,
    Is it possible to pass a variable from one class to another? For e.g., I need the value of int a for calculation purpose in method doB() but I get an error <identifier> expected. What does the error mean? I know, it's a very, very simple question but once I learn this, I promise to remember it forever. Thank you.
    class A {
      int a;
      int doA() {
          a = a + 1;
          return a;
    class B {
      int b;
      A r = new A();
      r.a;  // error: <identifier> expected. What does that mean ?
      int doB() {
         int c = b/a;  // error: operator / cannot be applied to a
    }Thank you!

    elaine_g wrote:
    I am wondering why does (r.a) give an error outside the method? What's the reason it only works when used inside the (b/r.a) maths function? This is illegal syntax:
    class B {
      int b;
      A r = new A();
      r.a;  //syntax error
    }Why? Class definition restricts what you can define within a class to a few things:
    class X {
        Y y = new Y(); //defining a field -- okay
        public X() { //defining a constructor -- okay
        void f() { //defining a method -- okay
    }... and a few other things, but you can't just write "r.a" there. It also makes no sense -- that expression by itself just accesses a field and does nothing with it -- why bother?
    This is also illegal syntax:
    int doB() {
          A r = new A();
          r.a;  // error: not a statement
    }Again, all "r.a" does on its own is access a field and do nothing with it -- a "noop". Since it has no effect, writing this indicates confusion on the part of the coder, so it classified as a syntax error. There is no reason to write that.

  • Error editing task sequence: Failed to load dynamic properties for class "SMS_TaskSequence_ApplyWindowsSettingsAction" From XML into WMI

    I've started getting an intermittent error editing my Windows 7 OSD task sequence.  Sometimes I can open the TS to edit, but when I try to apply changes I get the error.  Other times I get the error when trying to open the TS.  If I try again
    right away, I still get the error, but if I wait a few minutes and try again sometimes it will open the TS. 
    The error reads:
    ConfigMgr Error Object:instance of SMS_Extended Status{Description = "Failed to load dynamic properties for class \"SMS_TaskSequence_ApplyWindowsSettingsAction\" from XML into WMI";Error Code = 2147943746;File = "e:\\qfe\\nts\\sms\\siteserver\\sdk_provider\\smsprov\\ssptspackage.cpp";Line = 3454;Operation = "ExecMethod";ParameterInfo = "SMS_TaskSequencePackage";ProviderName = "WinMgmt";StatusCode = 2147749889;}
    Coinciding with this error, I show the following entries in the TaskSequenceProvider.log file: 
    [PID: 7608] Invoking method SMS_TaskSequence.LoadFromXml
    TaskSequenceProvider
    Failed to protect memory buffer, hr=0x80070542
    TaskSequenceProvider
    Failed to load dynamic properties for class "SMS_TaskSequence_ApplyWindowsSettingsAction" from XML into WMI 0x80070542 (2147943746)
    TaskSequenceProvider
    Failed to load node Apply Windows Settings from XML into WMI 0x80070542 (2147943746)
    TaskSequenceProvider
    Failed to load children steps for node "PostInstall" from XML 0x80070542 (2147943746)
    TaskSequenceProvider
    Failed to load children steps for node "Execute Task Sequence" from XML 0x80070542 (2147943746)
    TaskSequenceProvider
    Failed to load children steps for node "" from XML 0x80070542 (2147943746)
    TaskSequenceProvider
    Failed to load XML for the task sequence into WMI 0x80070542 (2147943746)
    TaskSequenceProvider
    [PID: 7608] Done with method SMS_TaskSequence.LoadFromXml
    TaskSequenceProvider
    Setting status complete:  status code = 0x80070542; Failed to load dynamic properties for class "SMS_TaskSequence_ApplyWindowsSettingsAction" from XML into WMI
    TaskSequenceProvider
    I exported the task sequence and checked in "object.xml" for the "ApplyWindowsSettingsAction", to see if there was something odd in the xml, but I don't find anything that jumps out as being wrong.  Here's the section of XML for
    that step.  I've removed identifying info, and replaced it with a generic term in bold.
    <step type="SMS_TaskSequence_ApplyWindowsSettingsAction" name="Apply Windows Settings" description="" runIn="WinPE" successCodeList="0" runFromNet="false"><action>osdwinsettings.exe /config</action><defaultVarList><variable name="OSDLocalAdminPassword" property="AdminPassword"></variable><variable name="OSDComputerName" property="ComputerName">%_SMSTSMachineName%</variable><variable name="OSDProductKey" property="ProductKey"></variable><variable name="OSDRandomAdminPassword" property="RandomAdminPassword">false</variable><variable name="OSDRegisteredOrgName" property="RegisteredOrgName">COMPANY NAME</variable><variable name="OSDRegisteredUserName" property="RegisteredUserName">COMPANY NAME</variable><variable name="OSDServerLicenseConnectionLimit" property="ServerLicenseConnectionLimit">5</variable><variable name="OSDTimeZone" property="TimeZone">Central Standard Time</variable></defaultVarList></step><step type="SMS_TaskSequence_ApplyNetworkSettingsAction" name="Apply Network Settings" description="" runIn="WinPEandFullOS" successCodeList="0" runFromNet="false"><action>osdnetsettings.exe configure</action><defaultVarList><variable name="OSDDomainName" property="DomainName">DOMAIN.COM</variable><variable name="OSDJoinPassword" property="DomainPassword"></variable><variable name="OSDJoinAccount" property="DomainUsername">DOMAIN ACCOUNT</variable><variable name="OSDEnableTCPIPFiltering" property="EnableTCPIPFiltering" hidden="true">false</variable><variable name="OSDNetworkJoinType" property="NetworkJoinType">0</variable><variable name="OSDAdapterCount" property="NumAdapters" hidden="true">0</variable></defaultVarList></step>
    Is there any other log I should check for a clue on this issue?  What could be causing this error?

    Thanks for sharing that!  I tend to save contacting MS support until after I've exhausted other options.  I'm always afraid that I'll spend the $500 to open a case and then it turns out to be something simple that I would have found if I had just
    kept working on it myself a little longer.
    It looks like that link is for an update released in February as KB3023562.  I downloaded and installed it. I'll try opening/editing/saving the task sequence a few times today to see if the issue is resolved.  
    After I had already installed it, I thought to look up that update in configmgr.  The update is listed as superseded by 2 other updates.  The newest of those is KB3046049, which just installed last night with the other March patches, so it's possible
    that I didn't need to install KB3023562 after all.  

  • Putting Loader in a custom class: events, returning to main ... asynch challenges

    I'm creating a custom class to retrieve some data using URLoader.
    My code is below, doing this from memory, plz ignore any minor typos.
    The challenge I'm encountering: when my custom class calls the loader, the event handler takes over.  At which point the context of my code leaves the function and it's not clear to me how I then return the data retrieved by the loader.  I sense that I'm breaking the rules of how ActionScript really runs by putting a loader in a separate class; at least, that's my primitive understanding based upon the reading I've done on this.
    So can I do this?  I am trying to create a clean separation of concerns in my program so that my main program doesn't get clogged up with code concerned with retrieving remote data.
    Thanks!
    Main program;
    import bethesda.myLoader;
    var ldr:myLoader = new myLoader;
    var data:String = myLoader.getData("someurl");
    My custom class:
    package bethesda {
         public class myLoader {
              function myLoader(url:String):String {
                   var loader:URLLoader = new URLLoader();
                   var request:URLRequest = new URLRequest(url);
                   loader.addEventListener(Event.COMPLETE, completeHandler);
         function completeHandler(event:Event):void {
              var ld:URLLoader = new URLLoader(event.target);
              data = loader.load(); // here's where I don't know what to do to get the data back to my main program

    I think you are on the right track in abstracting loading from other code.
    Your class may be like that:
    package 
         import flash.events.Event;
         import flash.events.EventDispatcher;
         import flash.net.URLLoader;
         import flash.net.URLRequest;
         public class myLoader extends EventDispatcher
              // declare varaibles in the header
              private var loader:URLLoader;
              private var url:String;
              public function myLoader(url:String)
                  this.url = url;
              public function load():void {
                  var loader:URLLoader = new URLLoader();
                  var request:URLRequest = new URLRequest(url);
                  loader.addEventListener(Event.COMPLETE, completeHandler);
                  loader.load(request);
              private function completeHandler(e:Event):void
                  dispatchEvent(new Event(Event.COMPLETE));
              public function get data():*{
                  return loader.data;
    Although, perhaps the best thing to do would be to make this class extend URLLoader. With the example above you can use the class as following:
    import bethesda.myLoader;
    import flash.events.Event;
    var ldr:myLoader = new myLoader("someurl");
    ldr.addEventListener(Event.COMPLETE, onLoadComplete);
    ldr.load();
    function onLoadComplete(e:Event):void {
         var data:String = ldr.data;

  • How to load variables from a .txt file

    Hi.
    I usually make a flash aplication in colaboration with a php
    programmer. But i want to test my swfs without having to wait for
    him. So i want to do that through a text file. I know that flash
    can load variables from text files. The problem is i don't know how
    to format the text file ( example.txt).
    Thank you

    Here's a couple of ideas.
    First you probably want to change what you have...and put
    your 'if (pVar==1' etc inside a separate function and call it from
    the onLoad handler after you have assigned the value to pVar...
    because the onLoad will run at some unknown point in time after
    loading has finished (actually in the test environment this might
    work... but that wouldn't be the same as what happens in a
    production setting).
    To create test files for loadvars... simply create a new as2
    file and put this code on the first frame and test movie:

  • 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>

  • Set an undefined Loaded variable's alpha to 0

    Hi, I'm trying creating a flash navigation bar that can be edited via a simple text file. I'm able to load my different variables properly but i also want to give the user the ability to remove links. I can simply leave the variable from the text file blank and and have the text in the swf disappear but i also want to be able to set the alpha of the movieclip behind the text to zero when the variable is left blank. Alternatively, even if the user could simply set the variable to the string "Blank" and both the alpha of the dynamic text and movieclip would change to zero that would be functional as well. Here is the code i have so far.
    NavLoadVar = new LoadVars();
    NavLoadVar.load("navigation.txt");
    NavLoadVar.onLoad = function() {
         b1.text = NavLoadVar.b1text;
         b2.text = NavLoadVar.b2text;
         b3.text = NavLoadVar.b3text;
         b4.text = NavLoadVar.b4text;
         b5.text = NavLoadVar.b5text;
         b6.text = NavLoadVar.b6text;
         b7.text = NavLoadVar.b7text;
         b8.text = NavLoadVar.b8text;
    if (NavLoadVar.b1text == "Blank") {
         divider1._alpha = 0;

    Something like the following should work...
    NavLoadVar.onLoad = function() {
         for(i=1; i<9; i++){
              if (NavLoadVar["b"+i+"text"] == "Blank") {
                   this["divider"+i]._alpha = 0;
              } else {
                   this["b"+i].text = NavLoadVar["b"+i+"text"] ;

  • Use of variables from other class

    hallo,
    i have two classes A and B
    i would like to access a variable of the class B out of A class
    without class A extends B or
    A classA = new A();
    to use
    i attempted it with a constructor
    class A{
        B klb;
        public A(B b1){
        this.klb = b1;
       int a;
       a= klb.varausB;
    }with that I get, however, a NullPointerException
    in a similar form i saw it already once and it functioned
    somebody can help me?

    that is it what I mean
    public class ClassA {
    ClassB clb;
    public ClassA (ClassB cb){
    this.clb = cb;
    public static void main(String[] args) {
    System.out.println("Var from class B:
    class B: "+clb.varb1);// there is an error, i know
    but how it is right?
    public class ClassB {
    public String varb1 ="var b1";
    }nevertheless so similarly it should function, or?So if you create an instance of ClassA, clb will be initialized. But you don't do that in main. Hence your errors:
    1) You're not calling the constructor, so clb is null
    2) You're trying to access an instance variable without having an instance, so clb is not only null, it actually doesn't exist.
    public static void main(String[] args) {
      Class A myA = new ClassA();
      System.out.println("Var from class B: "+ myA.clb.varb1);
    }You're outside of any object, ehnce you need to address clb through an instance of ClassA.

  • Error when defining a variable from a class

    Hi,
    I'm getting this error message when trying to define a
    variable from a class:
    '1086: Syntax error: expecting semicolon before left paren.'
    I can't see where the error is.
    The scripts Question.as and Codeframe.as is located int the
    folder Mycomponents under the project.
    Regards
    /Acke
    **** Main app *****
    <mx:Script>
    <![CDATA[
    import mx.controls.Alert;
    import mx.events.CloseEvent;
    import myComponents.*;
    var Question():myComponents.Question=new Question(); // !!
    This line causes the error !!
    other code goes here....
    ]]>
    </mx:Script>
    **** The class definition ******
    package myComponents
    //import other classes needed
    import Mycomponents.Codeframe
    public class Question {
    // Define properties and methods.
    // Define public vars.
    public var Qtype:string;
    public var Condition:string;
    public var Qnumber:string;
    public var Qheading:string;
    public var Pretext:string;
    public var Qtext:string;
    public var Posttext:string;
    public var Codeframe():string;
    public var Reserved:string;
    public var EditableFrom:string;
    public var EditableTo:string;
    public var Decimal:string;
    public var SetQfactor:string;
    public var Logic_if():string;
    public var Logic_then():string;
    // Public constructor.
    //public function Question(){
    // do stuff to set initial values for properties
    public function Question(Type:string,
    Condition:string,
    Qnumber:string,
    Qheading:string,
    Pretext:string,
    Qtext:string,
    Posttext:string,
    Codeframe():string,
    Reserved:string,
    EditableFrom:string,
    EditableTo:string,
    Decimal:string,
    SetQfactor:string,
    Logic_if():string,
    Logic_then():string,
    ):Void
    this.Type=Type;
    this.Condition=Condition;
    this.Qnumber=Qnumber;
    this.Qheading=Qheading;
    this.Pretext=Pretext;
    this.Qtext=Qtext;
    this.Posttext=Posttext;
    this.Codeframe()=Codeframe();
    this.Reserved=Reserved;
    this.EditableFrom=EditableFrom;
    this.EditableTo=EditableTo;
    this.Decimal=Decimal;
    this.SetQfactor=SetQfactor;
    this.Logic_if()=Logic_if();
    this.Logic_then()=Logic_then();
    }

    1.
    It should be
    var theQuestion:Question = new
    Question(sType,sCondition:string,sQnumber,sQheading,sPretext,sQtext,sPosttext,
    sCodeframe,sReserved,sEditableFrom,sEditableTo,sDecimal,sSetQfactor,sLogic_if,sLogic_then )
    As you don't have default values in the constructor - you
    should specify the parameters.
    2. why do use type "string" ? It should be "String" if you
    refer to a standard type
    3. What are you trying to say by this:
    public var Codeframe():string;
    public var Logic_if():string;
    public var Logic_then():string;
    There should not be any parenthesis in the variable
    declaration.
    4.
    this is wrong
    var Question():Question=new Question();
    this even wronger
    var Question():Array=new Question(); // I'm trying to create
    an array here anyway...could this be the problem??
    no parenthesis!
    var Qs():Question=new Question();
    hmmmm....
    .var Qs()=new Question();
    I think you should start reading from the following link to
    get more understanding of the variables, types & declarations:
    http://livedocs.adobe.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDo cs_Parts&file=00001863.html
    Cheers,
    Dmitri.

  • Static variable error in main function

    Dont know why it would be doing this. It is bascially telling me that every class I call in my main function needs to be static which is crazy.
    import javax.swing.*;
    import java.awt.*;
    class Frame extends JFrame
         public Frame()
              setTitle("My Empty Frame");
              setSize(300,200);
              setLocation(10,200);
              this.show();
    public class Main extends JFrame
         public JFrame frame;
         public Main()
              frame = new JFrame();
         public static void main(String[] args)
              System.out.println("CS348 Project 1");
              frame.setVisible(true); <--------------------ERROR
    }Thanks for the help.

    The problem (basically), is that you could do the following if you felt like it:
    import javax.swing.*;
    import java.awt.*;
    class Frame extends JFrame
         public Frame()
              setTitle("My Empty Frame");
              setSize(300,200);
              setLocation(10,200);
              this.show();
    public class Main extends JFrame
         public JFrame frame;
         public Main()
              frame = new JFrame();
         public static void main(String[] args)
              Main main1 = new Main();
              Main main2 = new Main();
              Main main3 = new Main();
              //what frame is this talking about??
              frame.setVisible(true); <--------------------ERROR
    }What you would want instead is probably something like this:
    Main main1 = new Main();
    main1.getFrame().setVisible(true);This leads to a few other questions: why are you extending JFrame if you have a JFrame variable in the class? Does that class have a JFrame, or is it a JFrame? You should almost definitely go with the "have" answer.

  • Binding variables of application class in bsp application.

    Hi,
    I know it is possible to bind the variables of model class like "//MODEL/VARIABLE" but is it possible to bind the variables of applicaiton class?
    Thanks and regards,
    Santosh.

    You have to remember that BSP evolved over several releases.  In 6.10 BSP released with no support for MVC - just the Application class. The application class was simply the way to share values between views and store them between requests in stateful applications.  It doesn't support any data binding.  In 6.20 BSP began to support MVC with the introduction of controller classes and model classes.  You data bind UI elements directly to model attributes only.  There is no concept of context.
    WD is completely different in that you only data bind UI element to the a context. The MVC structure is much cleaner because the view layout never has visibility to the model (regardless of what you consider the model). 
    Over time the assistance class has become the defacto standard for models in WDA, because unlike WDJ there is no direct model object.  It originally was intended mostly as a way of having text elements for WDA components.  However it is still perfectly acceptible to use service calls (proxy objects, function modules, class methods) as your model. I personally prefer to always wrap calls to my service object up in an assistance class for clear design.

  • Movie refuses to load variables from text file

    Hi,
    I'm sure you can solve my newbie problem in less than 1
    minute...
    I'm pulling my hair out on a template I bought 2 days ago
    from templatemonster.com
    I am using Flash 8 Pro.
    All I want to do is change an existing textfield that is
    Static to Dynamic and load variables from a text file.
    The Action Script I use to do so comes directly from
    Macromedia documentation (see attached)
    It works fine when I create a brand new movie, but doesn't do
    anything when inserted into the template.
    It doesn't even complain about not finding the text file if I
    rename or delete it!
    Here are the FLA and text file:
    Edit : Link to source file removed
    The textfield I would like to change is in the txt2 symbol.
    Here is how I proceed:
    When I open HEADER.FLA, Flash tells me I'm missing a font,
    ok, so I click on Use Default, I'll deal with this later.
    I open up the Movie Explorer, go to Layer 30, go to Frame 75
    and click once on txt2
    I name the instance "myMovie_mc" and save (converts from
    Flash MX to Flash 8)
    I double-click on the Movie Clip, select the word
    "Automobile" on the Stage, change from Static to Dynamic and call
    that instance "myText_txt"
    Still in the Movie Clip, I create a new layer I call
    "actions", and in Frame 1 I copy the attached Action Script:
    This script works when I create a new flash file, but it does
    absolutely nothing in this template.
    I know I'm doing something wrong, but I wonder what?
    Many thanks to any helping soul!
    Ferris.

    try this:
    // Load text as variable and assign it to the
    // dynamic text field
    var features_lv:LoadVars = new LoadVars();
    features_lv.onLoad = onText();
    features_lv.load("safetyFeatures.txt");
    function onText(success:Boolean) {
    if (success) {
    myText_txt.text = features_lv.safetyfeatures;
    } else {
    myText_txt.text = "unable to load text file.";
    or this
    // Load text as variable and assign it to the
    // dynamic text field
    var features_lv:LoadVars = new LoadVars();
    features_lv.onLoad = function(success) {
    if (success) {
    myText_txt.text = features_lv.safetyfeatures;
    } else {
    myText_txt.text = "unable to load text file.";
    features_lv.load("safetyFeatures.txt");

Maybe you are looking for

  • "Save As" Forms In Acrobat X

    I have created multiple forms for my organization in LiveCycle that allow trainers to evaluate new hires. All of the forms are located in a Portfolio that are on the main server. The trainers are able to fill out part of the form, save it, and return

  • Mx-DAQ multiple tasks

    Hello, Im using LV7.1 with NI-Daq 7.4. in my Application i use multiple tasks, a few for aquiring analog and digital input from my first 6024E and one to aquire digital input from my second 6024E. In most of the time this works very well, but from ti

  • Parsing Documents

    I'm using Oracle XmlParser for java in order manage XML documents. The only metod I foud in order to read an XML document from a file is : create a DOMParser and use the parse method. If I do that and the document is malformed I get an error. If I se

  • How can i set up my HP photo smart premium printer with my new iPad Air

    i don,t know much about these things at all so the answer has to be very easy

  • SAP BI BEx Analyser Info - Required

    Hello Gurus, I have to prepare  end user training Material onSAP BI  BEx Analyser for  : "End - User" and "Adminstrator" for my company. Could plz provide me some end user sample material which i can use. or could you please let me know how to go abo