ActionScript 3.0 :: Find All Variable Names In Class?
Nov 9, 2009Is there a way to find all the public variable names in a class (given the instance of the class)?
View 2 RepliesIs there a way to find all the public variable names in a class (given the instance of the class)?
View 2 RepliesHow do you make a new instance of a class with a dynamic name.
var dynamicname = new dynamicname()
i try something
var this["test"]:Class = new ["Test"]()
but offcourse its not this...
I need this couse i have a librairy with SWC fonts they are only reference.. I get the font name from a CSS file and after i need to make a instance of the SWC file so the font is embedded.
I started a thread about a reference to a symbol House, in the output window, which was: House_1. A lot of people said some useful things about that. All day I've been thinking about it, and I came to the conclusion that I don't understand things, at a very basic level.
Consider:I make a movieclip which I give the Symbol name Drawer. (I don't export it for AcitonScript.)On the stage I manually place two instances of this Symbol. The first one I give the Instance Name drawer (in the properties panel). The second one I leave nameless.Now if I trace the names of both these clips, by
trace(this.getChildAt(0).name);
trace(this.getChildAt(1).name);
the output window gives me
drawer
instance2
Now I know that the so-called "instance name" which I gave in the Properties Panel (drawer) is, in reality, a variable name which Flash gives my first instance behind the scenes. And instance2 is a name that Flash gives my second instance. What exactly the nature of that name is, I do not know.My point is: both names (drawer and instance2) are the .name property of these movieclips. Otherwise I could not have traced them through asking for the .name property, in the above. Yet only the first of these two can be manipulated:
drawer.x can be set;
instance2.x can (as we know) not be set.
But...why? What is the real difference between these two kinds of names? How can they both be the .name property of their underlying movieclip, yet be of such a different nature? What IS the nature of the instance2 name? If it's a String, how come the .name property of one movieclip can be a variable name, while the .name property of another (but identical) movieclip is a String?
I've searched every bit of web page on the net I could find. But it looks as if nobody addresses this issue. We all just work with it - but it makes no bloody sense. A name property = a name property, you'd think. Whether Flash set it or I set it should not make a difference. The x property of a clip, for example, does not change in nature according to who set it - me or Flash.So, again, just to emphasize the problem: how can a property (the name property) of a movieclip change in NATURE depending on who set it? After it's been set, shouldn't the name property of a clip be of exactly the same nature as the name property of another clip?
I am working on making a photo flip animation between 5-7 photos but i have to duplicate this 70 different times. So what i have done is made a scene for each set of 5-7 photos, they are externally being pulled in through an AS3 script to prevent a large .swf file from happening with all those photos. The problem i am running into so that i cant seem to run a find and replace search to replace the instance name values.
View 1 Replieslet's say you're passing an object to a function {title:"my title", data:"corresponding data"} how can I get the function to know what the names of the items/sub-objects are (title and data) without specifying them?
View 2 RepliesI'm still learning flash and actionscript 3 and i am having trouble with variable and object names. I need to be able to combine variable names together (in the same way as php can combine by doing var1.var2).
My swf contains 4 loaders (image1_loader, image2_loader etc..) which are a child of (image1_content, image2_content etc.....)
I then have 4 buttons which load an image into the loader and while doing so they define the currently active loader.
Finally i have 4 control buttons - scale up/down and rotate clockwise/anticlockwise which should only control the currently active loader (as set by the buttons above)[code]...
I'm still learning flash and actionscript 3 and i am having trouble with variable and object names. I need to be able to combine variable names together (in the same way as php can combine by doing var1.var2).
My swf contains 4 loaders (image1_loader, image2_loader etc..) which are a child of (image1_content, image2_content etc.....)
I then have 4 buttons which load an image into the loader and while doing so they define the currently active loader.
Finally i have 4 control buttons - scale up/down and rotate clockwise/anticlockwise which should only control the currently active loader (as set by the buttons above)
So my buttons as well as loading the image have the event listener:
image1_btn.addEventListener(MouseEvent.CLICK, setCurrentSelection);
image2_btn.addEventListener(MouseEvent.CLICK, setCurrentSelection);
(and so on..)
function setCurrentSelection(e:MouseEvent):void {
[Code]...
So within the rotateClockwise and rotateAntiClockwise functions i need to be able to recognise which is the currently active loader and have that number instead of the X - so if it is image1_loader - it needs to be image1_content, if 4 - image4_content... I had tried to do it as this but it doesn't like it being a string:
rotateAroundCenter((activeLoader+'_content'), 10, ptR);
I'm still learning flash and actionscript 3 and i am having trouble with variable and object names. I need to be able to combine variable names together (in the same way as php can combine by doing var1.var2).My swf contains 4 loaders (image1_loader, image2_loader etc..) which are a child of (image1_content, image2_content etc.)I then have 4 buttons which load an image into the loader and while doing so they define the currently active loader.Finally i have 4 control buttons - scale up/down and rotate clockwise/anticlockwise which should only control the currently active loader (as set by the buttons above)So my buttons as well as loading the image have the event listener:[code]So within the rotateClockwise and rotate Anti Clockwise functions i need to be able to recognise which is the currently active loader and have that number instead of the X - so if it is image1_ loader - it needs to be image1_content, if 4 - image4_content.I had tried to do it as this but it doesn't like it being a string:[code]
View 3 RepliesI'm currently working on an advanced preloader and i'm creating loads of different variables etc. based on the percentage loaded. I need the variables to be named Number + percentage, so in the end I will have Number1, Number2, Number3, Number4 etc. How can I create variable names using my percentage variable? Can't seem to find anything that answers my question.
View 2 RepliesI'm attempting to build a menu using a XML. I have read the tutorial on the site and I am attempt to do it in a slightly different manner. Anyways, I am trying to make dynamic variable names for my text fields. And because of the way I am doing this I found it easier to try to use XML to hold the field name. But when I try to use the name from the XML file it won't work. I can trace it and get the proper word but when used in the script it breaks.Below I want to replace 'popMenu' with the fieldName variable.
Code:
mainMenu.menu1.onRollOver = function(){
listLength = menu_xml.childNodes[0].childNodes;
[code].....
How do I concatenate variable names in AS3?Something like this:
for(var i:int=0 ; i<5 ; i++) {
var "myVar"+i:Array = new Array();
}
I'm working on a project using google maps. For part of it the user must enter coordinates and click a button in order to add a marker to a map. The code I have written so far allows this to be done once:
play_btn2.addEventListener(MouseEvent.MOUSE_DOWN, submitdata);
function submitdata(e:Event){
var marker9:Marker = new Marker(
[code]....
As it is the only one marker can be added as it keeps getting replaced. I want to make it so that the variable name changes each time a marker is to be added.
I'm looping over an array named shopData and need to use values within that array to create new variables. Inside the loop, I'm trying something like this: shop_(shopData[i].shopName).keyword = shopData[i].keyword; but I'm having trouble with the portion in () and can't seem to find the right syntax for this. Assuming shopData[i].shopName = "foo" I need to create a variable named:
[Code]...
I'm trying to loop through a set of textFields that I created in the Flash IDE, and named them through the property panel with name called "dot_text1, dot_text2, etc...). These textfield elements are nested in another movieclip called "bouquet".
My issue is that I'm trying to loop through all of them and store them into an Array for later use, but I keep getting undefined when I trace it out. I'm writing the script in the root of the file.
[Code]...
I am using loadVars to get strings from a text file and then I loop it to put them all in an array. But as indicated in the code, I want to check the variable name so a certain named variable will be put into a different variable, not the array. I have not been able to find how to check this...everything I try gives me undefined.
ActionScript Code:
myVars.onLoad = function(success) {
if (success) {
[code].....
I'm working on a simple form in AS2 that will send some variables via POST. These are being sent to a CMS in the background. Unfortunately, the CMS mandates that the variables must be named a certain way. They must be named fields[thefieldname] which really messes up the Actionscript involved. Does anyone have any thoughts about how I could escape these [ ] characters so they don't get interpreted wrongly as an Array by actionscript?
Code:
on (release) {
var msg:LoadVars = new LoadVars();
[code]......
Can I use the # sign in AS2 variable names?
like ->> var item_#_productName = "test"
I must use a list of preset varilable names but I am getting a syntax error when I use the # sign.
How/can you pass a array into a variables name?
var urlRequestArray:Array = ["home.txt", "contact.txt", "about.txt"]
var reqNameArray:Array = new Array("homeReq","contactReq", "aboutReq")
for (var i:uint; i < buttons.length; i++){
[code].....
I'm having a few issues with incrementing numbers in variable names, was wondering if I could getThe below code is what I'm trying to implement, but I keep getting errors.
Code:
for( var i = 0; i < __values.length-1; i++)
{
[code]......
I send flashvars to flash. Those variables are one user id variable and unknown number of corresponding friend and relation vars (friend1, friend2, relation1, relation and so on, all the items from DB).I get the of course from an object:Code:var flashVars=this.root.loaderInfo.parameters;and check how many friends did the php send to me . There is one user id variable and an even number of friends and relations so the way i check how many mates do i have is:
After some further testing, I found out that under Actionscript 3 XML (E4X) I'm unable to use dynamicaly created variable names...
The famous:
Code:
var i:number = 111
this["someVarName" + i] = "actual_value"
trace(someVarName111) // = actual_value
does not work for me with E4X lingo...
Code:
var myXML:XML
myXML = "...." //asume valid XML content here
trace(myXML.XMLData.@Memo_EN)
[code]....
This is an example of the kind of issue I'm trying to solve. Say I'm looking to set 10 text fields (text_field_1 to text_field_10) within my movie clip 'myMovieClip' to the value of i. Now if the for loop and the text fields are in the place (_root) all I would have to do is:
ActionScript Code:
for (i=1; i<10; i++)
{
[code]....
I want to parse the image names in the following XML into an array:[code]What would the variable name be to get to the start of the image names?[code]
View 1 RepliesHaving a problem with a Flash/ASP/Database project.I've seen tutorials that pulls address book listings dynamically from the DB. When you hit "next" button it just populates dynamic text fields with variable names like "name" "address" with the appropriate info. Problem I'm having is.. what if you want to display all the entries on the same screen.If the variable names on the dynamic text fields are hard coded named "name" "address" "phone number" etc. , how can the second set of info display underneath the first one properly and not just pull the same text from the first record into the text fields? (name2, address2, etc.)
Is there a way to dynamically change the variable name of a dynamic text field? I'm thinking you should be able to have it note how many records there are, then loop until it reaches the end of the record set. So, can the variable names be dynamic so it will populate the text fields with the appropriate info?
dynamically assign variable names from XML? For instance, if I have an XML file with a list of variable names and their respective values, can I make my Flash movie create these variables?
View 5 Repliesuse a loop to create a set of variable names. The forums have figured out how to do this in AS2. This works in AS2...
PHP Code:
for(var x=0; x<3; x++) { this["var"+x] = x;}trace(var1); // 1trace(var2); // 2
I use AS3 in Flash to read XML from an external document. I'm wondering how to tell AS3 to read and treat some of the incoming XML values as variable names. For example, in the beginning of my Actionscript, I have defined the variable:
var playerAge:Number;
and some of the incoming XML nodes look like:
<whichVariable> playerAge </whichVariable>
<whichValue> 10 </whichValue>
Now, upon reading these two nodes, I want to make a function that adds the value of the second node to the variable with the name contained in the first node. However, I can only get AS3 to read the value of the first node as a a string ("playerAge"). How do I get it to make the 'connection' between the XML node and the variable with the same name?
I'm creating a pacman game and basically I'm having trouble coding the enemies (ghosts), the code works perfectly with just one ghost, as soon as I add another it starts to go wrong.Firstly I've got this function which places the enemies:
Code:
//places the enemies
function placeEnemies() {
[code].....
I have a program where I have multiple classes derived from a base class. I want to take all instances of the different subclasses and put them into an array. Is there a way I can search for anything derived from the base class?For example, right now a get the number of children, then see what they are, so:
for (var i = 0; i < this.getNumChildren(); i++)
{
if (i is "type")
[code].....
am trying to load xml and make button for its length, and try to make function for each button i have i make buttons and i give them a unique name , but i can't make function for every one?here is the code
/////////////////////////////
var xmlLoader:URLLoader = new URLLoader();var my_Arr:Array= new Array();var arr_posX:Array =new Array();//= ["350","350","350","350"]var arr_posY:Array=new Array();//= ["80","120","160","200"]xmlLoader.addEventListener(Event.COMPLETE, showXML);xmlLoader.load(new URLRequest("Models.xml"));function showXML(e:Event):void { XML.ignoreWhitespace = true; var songs:XML = new XML(e.target.data);
[code]....