IDE :: How To Create Create Dynamic Variables?
Feb 24, 2009I am trying to create dynamic variables. Lets say: I read a file where I have: building, restaurant and hotel.
[Code]...
I am trying to create dynamic variables. Lets say: I read a file where I have: building, restaurant and hotel.
[Code]...
This gives me syntax errors.
var ["Dp"+ event.target.name]:Boolean = new Boolean()
I am trying to create dynamic variables.I read a file where I have this strings: building, restaurant and hotel.Then, will load them like
X = building.
Y = restaurant
Z = hotel.
Now I want to create variables like: building = 123; restaurant = "abc"; hotel = 2.5; So on how to use the value (building, restaurant, hotel) on naming or creating variables to use them later?
This is what i want to accomplish.This gives me syntax errors.Can you do something similar to this?
var ["Dp"+ event.target.name]:Boolean = new Boolean()
This is what i want to accomplish.This gives me syntax errors. [url]...
View 3 Replieslets say i need a variable what is changing after period of time, by increasing in a number.
"variable = variable1" after a second it changes to "variable = variable2" .
I have multiple movieclips on my stage. Im bringing in figures from a xml file which i will used as my movieclip._y positions. So as the figures change in the xml file, my movie clips should hopefully float up and down.
I have assigned them a starting position, bring in the first array of positions and they float there nice. When i bring in their next aray of position they jump back to their first position then float to their second new position?
I'm trying to send variables to a payment gateway (dibs) and need to post variables to the likes of[code]...
In creating a dynamic variable I'm doing this, which works. But it's not posting the values to the php-page. (The "normal" variables are being posted just fine, so the error isn't there) [code]...
I have the code below but I need to generate it with a for loop. What is the proper way to do this? I don't initially know how many points i will have. I just want to create a for loop to loop through a variable that holds the point count such as "var totalPoints=10"
//1
var p1oint = new Point();
points.addChild(p1);
[code]......
I am building a Gallery/Case Study application and I am running everything off of XML, and I need to be able to add images/text to the application whenever, without causing any problems. On the sideshow portion of the application, I am putting dynamically generated textfields under the picture viewer, with the number of the current image, highlighted. Similar to the one here:[URL] the first slide haha this was one of the best examples I could find. Anyway I've created the textfields, that display the correct numbers (that is, from "01" until say "07" depending on the .length(); of the XML tag <image>), but that is all they do so far. I am setting the type in the textfields by doing this
Code:
_tf.text = "0" + myIndex as String
myIndex is a varibale incrementing as long as var i:Number is less than the length property of the XMLList I'm using to store the image URL's. I am adding the _tf var to the stage using addChild(); and multiplying i by like 20 or something to make the x values different for every _tf. My problem is that if i try to reference the myIndex value when the textfield is clicked, it says the value of myIndex is 7, which is what it was set to when the last iteration of the loop executed. Basically I need to be able to store a value somewhere, that is unique to each textfield so I can load the corresponding image from my XMLList. I've tried messing around with the .name property of MovieClips, but I'm not exactly sure how it works. I use it earlier in the code with my Loader instance, but I don't know how to use it with MovieClips.
i am trying to do a loop to create several variables to aasign each one of those variables one number.when i write
[Code]...
Ive searched and so far not finding results. Can you create an xml file dynamically in AS3.[code]...
View 1 RepliesI want to create a directory where I can control what happens next with a movieclip because of what it says in the xml, for example:
HTML Code:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<xmlIndex>
<album>
[Code]....
I know this doesn't work, I've tried it, but I don't understand why? all I've done is created variables from the XML and tried to link it into 1 click event, instead of doing one for ever button, would i need some sort of for loop?
I am tryng to create a dynamic datagrid that receives dynamic columns:
PHP Code:
for (i=0; i<DadosModelos.total_produto_modelo_recebe; i++) {
var coluna:DataGridColumn = new DataGridColumn();
coluna.width = 75;
[Code].....
Now i want to add a row that receives a value for each column that i add dynamic above, i tried all but nothing..
I'm wondering if it's possible to create variables in a for loop that uses an incrementing number in the variable name.
This is the code I've tried (as a long shot) but isn't working:
var i:Number;for(i = 1; i < 10; i++){ var ["number" + String(i)]:Number = i;}
trace(number5);
What I'm trying to create here is a series of variables called "number1", "number2", "number3", etc. Is there another way of doing it? I'd need them to be public (I think that's the term?), so they can be used elsewhere in the script.
I'm wondering if it's possible to remotely create variables/properties on another object. Specifically, the stage.
I'd like to do something like this
public var stage.myArray:Array = new Array(1,2,3,4,5);
Perhaps that's not the right syntax. But assuming the array doesn't already exist there, can i create it (from an object that is on the stage)
I have an onEnterFrame function controlling all the movie clips in an array. The motion of each of these movie clips is controlled by a few variables speed, acceleration, etc that are modified on each enterFrame. I can't figure out how to create unique variables for each element in the array. At the moment my variables are the same for all the elements, and so the motions for each movie clip are the same.
I have used this code to add my movie clips into the array:
for(i = 0; i < starNumber; i++){ duplicateMovieClip(star, "star" + i, i); starArray.push(this["star" + String(i)]); }
Do I need to do a similar thing to create unique variables for each? Or is there something I need to do in my for(myClip in myArray) loop that is contained in my onEnterFrame function?
Can you use a
for(x:int=0; x<100; x++)
{
var varname+x:Type = (x, something, something);
}
To create one hundred unique variables? Basically I need to make 100 variables and am wondering how you create 100 vats with out resorting to Declaring them all by hand. the problem is var whatever+x just creates a variable with whatever+x instead of creating whatever0, whatever1... to whatever99.
After I've created a movieclip, how do you create a variable from the main timeline in that movieclip? I thought I could do either of these:
ActionScript Code:
spy1.speedMax = 7;
// or:
with (spy1) {
var speedMax:Number = 7;
}
By tracing speedMax, I found it was available on the main timeline, but not in an event listener
ActionScript Code:
function OEF(event.EVT):void {
trace(event.target.speedMax);
}
These two methods are available in AS2...
My issue is that I have 10 small audio clips and I want to make them into variables that i can access later in the code. But I'd be happy if I didn't have to write the same code 10 times down over and over to create/access them.[code]...
A question on the side, is there any built in sound generator in actionssccript 3.0?
If I have multiple variables of the same type, can I create an array and loop to create them or do I need to create them individually.
For instance,
var ajArray:Array = new Array(mc1, mc2, mc3, mc4, mc5, mc6, mc7, mc8, mc9, mc10, mc11, mc12, mc13);
for (var i:number = 0; i<ajArray.length; i++){
var [ajArray[i]]:MovieClip;
}
[code]....
A friend was asked to create a calculator which adds several variables together and produces an output which has other pre-determined variables added or subtracted...[code]The problem now is that the people that asked for it forgot to say they needed a further calculation which between us we just can't work out! Basically, if net_estate is under 285000, then tax_liability is to be 0. but if it's over 285000 then tax_liability = 40 / 100 * net_estate (as in the above code).
View 2 Repliesi am trying to "dynamically" create variable names inside a for loop and add them to an array...
[Code]...
// ' this["thumb" + i] ' is definitely not the way to write it.. so how should i write it?
I want to dynamically create variables that will create and place instances of a movie clip on the stage at runtime.[code]
View 5 RepliesI'm trying to create a series of Loaders in a for loop whose names are created from an Array.If "eval" existed in AS3, the code might look something like this:
var i:int;
var tnArray:Array = new Array("tn0","tn1", "tn2");
for (i = 1; i <= 10; i++){
[code].....
I'm having a little issue understanding scoping in this package environment. My question is this: Is it possible to declare globally visible variables and constants? I tried this with no successful results:
PHP Code:
package {
import flash.display.Loader;
import flash.display.Sprite;
import flash.net.URLRequest;
import games.mineAllMine.MineAllMine;
[Code] .....
I'm trying to create an application that receives variables passed through FlashVars and makes use of the new TLFTextField. I have run into an issue with accessing the FlashVars after declaring a TLFTextField variable.
The code I have is as follows:
ActionScript Code:
import fl.text.TLFTextField;
var tf:TextField = new TextField();
[code]....
The HTML file is passing a FlashVars value of "title=ThisIsTheTitle" If I run the code, the tf TextField is empty. If I comment out the last line that creates the TLFTextField, the FlashVars come through fine and the tf TextField displays the "title" variable that was passed through FlashVars.If I change the last line to read:
ActionScript Code:
var titleTLF:TextField = new TextField();
It works fine (the "title" variable from FlashVars is show in the tf TextField). I don't understand why delcaring a TLFTextField prevents the FlashVars from being accessed.
I need to create a multidimensional array with a certain number of rows/columns from variables that store the number of rows/columns. For example say I have:
var r:int = 5;
var c:int = 10;
I want a multidimensional array that has 5 rows and 10 columns, every space within the array filled with the value 0.
I'm trying to create a series of scripts that will create some custom event listeners.
I have three movie clips on my stage. One is a movieclip who's sole function is to hold array's and the event listeners. A second which moves around the screen. And a third that is motionless.
The problem is that the argument I want to test (which activates the custom event) is held within a string.
What I want to know is, how do you test to see if the string argument is true?
Is it something similar to this:
var myCode:String="1<0";if(myCode){
trace('one is smaller than 0'); //Strangely apparently one IS smaller than 0!!!
}
I think I'm going about this in the wrong manner, however this is the only way I can think of this working... (since I need to be able to dynamically create these events)
I'm trying to create a flash program that uses it's own code to send and create images. Each square has a colour and that colour gets added into the array. A black, then grey, then white is:
filecode = ["Bl", "Gr", "Wh"];
That works fine, but when I try to paste it into an Input text box it will only fill in the first part of the array.
filecode = ["Bl,Gr,Wh"];
So the program has NO idea what I want.The only ways I can think of fixing this is by putting in 402 text boxes to suit every box...But every one of them needs a Variable Name.Or by sending the information straight into the array. But this way you are just looking at what you just drew, and that is not at ALL practical.