473,394 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

saving external variables in a class

12
Hello,

For my flash project I want to read variables from a text file and store them locally in flash variables. This workes fine if I put everything directly inside the flash project file (actions belonging to a certain frame). Because I need to write a lot of code I want to put it all inside an external actionscript file / class(es).
When I define a variable (like 'dummy' in the example below) and copy a value read from a text file to it, it fails (that is, the 'trace' returns 'undefined').
If I move the 'dummy = 2' line directly after 'function getInfo[..]{' it works fine. What goes wrong in the code below? And how can I fix it (that is, 'dummy' should still hold the assigned value (2) after the reading process).

Note: I left out the actual reading actions inside the 'if(success)' part for simplicity reasons.

Expand|Select|Wrap|Line Numbers
  1. class readMatchData 
  2. {
  3.    var dummy:Number;          
  4.  
  5.    // Constructor function
  6.    function readMatchData()
  7.    { ; }
  8.  
  9.    function getInfo(roundNum:Number):Void
  10.    {
  11.       var lv:LoadVars = new LoadVars();
  12.       lv.onLoad = function(success:Boolean):Void 
  13.       {
  14.          if (success)
  15.          {
  16.             dummy = 2;  //this.dummy = 2; 
  17.          } 
  18.       }     
  19.       lv.load("round"+roundNum+".txt");       
  20.       trace(dummy);
  21.    }
  22. }
Thanks in advance!
Jun 21 '08 #1
1 2188
Omega
12
By the way, adding

Expand|Select|Wrap|Line Numbers
  1. else dummy = 3;
  2. trace(dummy);
  3.  
between line 17 and 18. Results in the following trace:

Expand|Select|Wrap|Line Numbers
  1. undefined
  2. 2
  3.  
In other words, it appears that the second trace is executed before the first. (???).
Jun 21 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Newsnet Customer | last post by:
Hi, Is an external variable a variable that is defined outside of a method? or a variable with the extern modifier prefixed to it? and what's the difference with external and global variables? ...
0
by: DDE | last post by:
Hi all, I have an application (number of web Services) in which I define different application variables, like application etc. Besides that, I have a couple of assemblies containing classes and...
4
by: Fred Nelson | last post by:
Hi: I'm a VB.NET programmer who is attempting to write my first C# web application. Everything is going VERY well however I have hit one snag: In the VB.NET world we can easily save classes...
0
by: Stu | last post by:
Hi, I want to be able to come up with some way of navigating around a system that allows me to save certain screen info (Say combo box setting) so that when returning to the screen from a link...
3
by: Peter Oliphant | last post by:
Trying to save/load a class instance to a file is tough. The reason is because there is no way to preserve its type other than by conventon. For eample, one can save all the states of the members...
2
by: ras26 | last post by:
I have a WebSite "App1" which has an external assembly "Lib1". Inside this external assembly we have developed some classes that derive from "System.Web.UI.Page". One of these pages is called...
6
by: Jeff | last post by:
Hey (and thank you for reading my post) In visual web developer 2005 express edition I've created a simple website project.. At this website I want users who register to be able to upload a...
6
by: sadegh | last post by:
Hi I have a problem with my program in VC++6 When I compile it, the following errors are listed. I spend a lot of time on the groups.google.com to find its reason, but none of comments could...
1
by: ramvenkat | last post by:
hi is it possible to save a external file through flash application in a particular folder specified in the flash application? means 1)would like to specify a folder while saving a particular...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.