IDE :: Use Data In Var Outside The Function?
Jul 22, 2009how to use data in var outside the function;
event function like
var m:Number;
function anything(e:MouseEvent)
{
m +=1;
}
how to use data in var outside the function;
event function like
var m:Number;
function anything(e:MouseEvent)
{
m +=1;
}
I am trying to load a variable from data in a text file.I can read the text file fine but the variable data seemsonly to be available with in the function that reads it. I need to use the variable data outside of the function.This is the actionscript code i'm using.
var pathVars= new LoadVars();
pathVars.onLoad=function(ok) {
if(ok)
[code].....
I am trying to load a variable from data in a text file.I can read the text file fine but the variable data seems only to be available with in the function that reads it. I need to use the variable data outside of the function.
This is the actionscript code i'm using.
var pathVars= new LoadVars();
pathVars.onLoad=function(ok) {
if(ok)
{
[code]....
This is where the path_var becomes undefined
trace("This is outside the function... "+path_var);
pathVar1="This is outside the function... "+path_var;
I have 2 functions, 1 loaded before another. Some value are determine by the other function data, but since one of it has to load before the other 1, how should I get the data that is loaded after current function?
private function wMessage():void {
Message.width=Name.width+20;
}
[Code]....
I've taken out some other unnecessary codes, but as you can see Name position is set according by the position + width of Message, but I want Message's width to be not smaller than Name
I have a set of data (in ArrayCollection) and I need to fit a power function { f(x)= B + x^alpha } to it, before display in LineChart. As result I need the alpha and B paremeter.
View 1 RepliesI'm having troubles trying to pass data from an array inside a function and make it available globally:
Code: Select allfunction getDials_Result(dialAry) {
for (var i:Number = 0; i<dialAry.length; i++) {
trace(dialAry[i]);
}
[Code].....
If I put the trace outside the function everything is undefined.
How can I set this up so the variables are declared globally so I can get them elsewhere.
So, my situation is like this: I have an XML file. I load the file to flash and display data. But this XML file can be changed by some other system, updates data,.. Now, i want to update my data in flash also. What i have done is use timer and check XML file every... let's say second. And i don't wanna do that...
I just want to know what the data in XML file changed and update at that time, otherwise do nothing.
So, i was wondering if that is possible. Is it possible for AS3 to get an event or something, when XML file changes.
I know i could do that with FMS or Red5 and shared objects... but let's say that that is not the best option in our case.
So, can I listen to changes in XML file??
I can't figure out why this doesn't work. I need to pass the text in the xml file to an object that needs to be created outside of the onload function so i need access to the data out side of that function. I've declared variables to store the data at the class level which i thought would give me access to the databelow is the code:
Code:
package {
import flash.display.MovieClip;
[code].....
I want a comboBox that will allow the user to select what colour palette they want the application to have.I am using a comboBox to do this and want to have a function with arguments as the data in the comboBox item.I've managed to do it and pass arguments but these are running when the comboBox is set up. I only want the function to run when the user presses the submit button. How can I prevent the function from running on set up?Here is my code:
Code:
package
{
[code].....
There's a RadioButtons group (=Group3) and event listener applied on it. The value of _root.choices3.a3.data is "a". The code is following:
trace("DATA BEFORE" + _root.choices3.a3.data);
var rbListener3 = newObject();
rbListener3.click = function() {
trace("I am inside.")
trace("DATA INSIDE" + _root.choices3.a3.data);
}
_root.choices3.Group3.addEventListener("click",
rbListener3);
If I compile it, the output is:
DATA BEFORE
I am inside.
DATA INSIDE
Why can't I read the value of _root.choices3.a3.data inside the function?
My previous several posts had to do with this, but now it's driving me nuts. I'm trying to use the same imgArray data in the xmlLoaded function in the initThumbs function.[code]...
View 1 Repliesi have a Problem to send a value from the DataGrid to a function- this is my function:[code]Now i have my DataGrid which receives Information from an XML File. Everything works fine. All Information is shown correctly with that Tags:[code]except the Button. The Function "browseLoc" only has the text {codeworxx.pages.page[selectedPageIndex].url} in it - not the value. How do i do it?
View 1 RepliesI've some strange behavior using ObjectUtil.copy() and ByteArray.writeObject/readObject(). I clone an ArrayCollection and sometime the result is two identical instance of the class. Example :
[Code]...
I want a comboBox that will allow the user to select what colour palette they want the application to have.I am using a comboBox to do this and want to have a function with arguments as the data in the comboBox item.I've managed to do it and pass arguments but these are running when the comboBox is set up.I only want the function to run when the user presses the submit button. How can I prevent the function from running on set up?Here is my code:
ActionScript Code:
package
{
[code]....
I want to be able to track data changes and then call a function.
[Code]...
Problem: How can I write a function so that it assigns the retrived data to a variable?
Setup:
data.txt contents: "This is my data."
Code:
// Simplest way to get String data from a txt/php file:
function queryData(_url:String):void {
var dataSource:URLRequest = new URLRequest(_url);
[Code]....
Just when I think I understand something! How come, when I load an xml file as follows, I can't access the data from outside of the loading function? This code returns a null object reference error.
Code:
var instituteList_XML:XML;
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("instituteList.xml"));
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
[Code]...
I have a datagrid with itemRenderer in datagridcolumn as my custom component(c1). I am getting the dataprovider data in custom component by overriding the set data function, it is fine. But now my custom component(c1) is also having another custom component(c2).
Now the doubt is - how to get the dataprovider data in c2 component?
I am attempting to build a generic XMLLoader class with a static LOAD method, with the intent to use it as follows...
private var _data:XML = XMLLoader.LOAD("path/to/xml_file.xml");
Then I could use it in any client and go-to-town with e4x.
The general problem I am having is with the URLLoader's COMPLETE event, which necessarily calls a different function to set the XML data.This is preventing me from being able to return the XML from the LOAD method, since the data is being set outside that function. Obviously I need to wait for the COMPLETE event in order to make sure the data is available.
I though, perhaps, I could create and return a _waitForData function, which recursively calls itself until the _data is set, then returns the data. But it seems redundant (since Event.COMPLETE is doing that anyway), and the way I tried it generates a stack overflow error.[code]...
In flex, I am handling event like this,
myImage.addEventListener(MouseEvent.CLICK, redoOperation);
Now, I want to pass some value to redoOperation. (function redoOperation myId:String)) How can I pass String to it?
Is there any library or open source function that approximate the area under a line that is described by some of its values taken at irregular intervals?
View 1 RepliesTrying to make a grid based question answer game and load variables from a text file using for loops into an array. I wanted to reduce redundant code and use for loops to populate my arrays. The issue I am having is with my arrays being lost/destroyed outside of the loader function.
I understand that if an array is declared inside the function, naturally the array would be destroyed upon exit of the function. However I am declaring the arrays outside of the function so the arrays should remain intact after I exit the function.
BTW - I'm not having an issue with the loading of the data. The data is loading correctly. The array is simply being destroyed after the data has loaded.
//Create the arrays to hold the
//categories, questions, and answers
var categoryArray:Array = new Array();
var quesAnswArray:Array = new Array();
[Code].....
so I'm not just new here, but definitely new to actionscript (though I have a MINOR amount of OOP experience in matLAB). I was wondering if someone could clarify something (though I'm sure this thread will grow out of my own confusion)?
[Code]...
how can i use data in variable inside function in ouside
var m:Number=0;
function bClick(e:MouseEvent):void
{
[code]....
when i trcae (m); out side this function said 0
I'm using setInterval and the issue is "how can i send data to function that are called from setInterval?". Now I have this: ActionScript Code: si = setInterval( startLoading(dir + "/" + f[i]) , t); If i send the function parameter in setInterval the function do all her job but the setInterval don't work. Wich are the best pratice to do this?
View 2 RepliesI have a child swf loaded that needs to receive an array that the parent creates in a function. The child swf must be the one to call that function.
View 3 Repliesif you look at the code:: barn is an instance of an MC on stage. I have a few buttons stored in an array which i want to attach scripts with a for loop. Why does adding an item from the array not work when placed inside the function call?
[Code]...
in a for loop i am passing 60 movieclips to the stage at runtime.now after that I trigger a function that fires every second.But inside that timer function, i can not trace what items are in my array in other words, every second i want to trigger a movieclip inside the array.(this will later destroy a random ipad or iphone processor :p)
heres my code:
Code:
var circle_array:Array;
var seconds_counter:uint = 0;
var myTimer:Timer = new Timer(1000);
[code]....
How would you write this into a function that lies on frame 1:
onClipEvent(data){
this.sendSent.text = "MESSAGE WAS SENT";
this.textEmail.text = "EMAIL";
this.textSubject.text = "SUBJECT";
this.textName.text = "NAME";
this.textMessage.text = "MESSAGE";
}
i have got a Flash Projector which is to be deployed onDC/DVD rom. I am using an XML menu to load various chapters andsections of html content, images etc. The client is now asking forthe capability to search within the "books" content.Is there any way of doing this? I have found an Extensionthat allows me to search within a text field, but what aboutexternal content files?
View 3 Replies