ActionScript 3.0 :: Create Dynamic Variables
Feb 7, 2011This 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.Can you do something similar to this?
var ["Dp"+ event.target.name]:Boolean = new Boolean()
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. [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]...
picture: [URL].. I am making a boardgame in flash Action Script 3 each position on the board is a buttons like this: button_1_1, button_1_2 etc. Whenever a character is selected you want to move it so the script has to add event listeners for positions around the selected unit
[Code]...
In the rest of the code I have:
function userClickedPosition(position_x:int, position_y:int) it selects or deselect a unit function selectUnit(position_x:int, position_y:int):it uses the listentoButton(1) function to add 8 listeners (the positions around the clicked unit)function deselectUnit(position_x:int, position_y:int): it uses the listentoButton(0) function to delete 8 listeners (the positions around the clicked unit)
My question: adding eventlisteners is no problem but removing them dont seem to work? What did I do wrong?
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..
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'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)
Why does this not work???
Code:
function myFunction(val0,val1,val2){
trace(this["val"+0);
trace(this["val"+1);
trace(this["val"+2);
}
myFunction("hello","test","hi")
All i get is undefined. If i just put "trace(val0)" i will get "Hello" -- so i cannot work out how to get the value of the dynamic variable inside hte function?
How am i to get the variables zombData.zomb0, & zombData.zomb1 from inside the "for loop"
I want this trace command dynamic
Quote: trace(zombData.zomb+i);
it works when i put zombData.zomb0 (a variable sent from a PHP script)but if i want to make it dynamic how it is; It fails & outputs NaN How do i make it dynamic for the loop?[code]...
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?
eval() is a usefull method or function in javascript.. Because we may define our variables via dynamic way..! There are following code is for understanding that how can define dynamic defining variables in javascript.. And Are there a dynamic way for evaluting variables in as3 like following javascript code?[code]
View 3 RepliesI've been working in a new proyect and i came to this problem that is really getting me tired. I'm supposed to make a given number of items (constructed from an extended Sprite)[code]...
View 1 Repliesi've been trying to make stock program in flash. i searched if i could use database with as3 but i did not find any. than i created Objects in as3 and give them all their detail.
[Code]...
most annoying thing for me is as3 does not allow dynamic variables (i've searched a lot but could not find, and i dont think arrays can be used by the way). this is the whole plan. how it can be filtered (categorised)?
AS3 newbie here finally trying to make the transition from AS2. I have a little application that I am trying to build which has some basic math in it based on user input. I have the numbers stored in dynamic text boxes and now I need to have the results shown after the user hits submit.
I have this code on the results page frame.
ActionScript Code:
var resultsmin:Number = Math.round((Number(devsize.text))*(Number(typemin.text)));
var resultsmax:Number = Math.round((Number(devsize.text))*(Number(typemax.text)));
This probably wasn't even the best way to do it in AS2 but it worked, now in AS3 it doesn't. Something to do with the way var is used now?