Changing An Object Property With It's String Name?
If I have the full path name of an object like:
var1 = "parentObject.firstChild.secondChild";
and I want to change the value:
parentObject.firstChild.secondChild.price
How can I do this with access ONLY to the string variable var1?
My situation is more complicated than given above... but essentially it's the problem given above, where I only have access to the string variable.
I've tried something like:
this[var1].price
But that doesn't work.
I can get access to the variable with eval(var1 + price)... but with the rules of the use of eval changed from Flash5, I can't use this.
Any ideas?
Does anyone understand my mad problem?
Any help would be appreciated.
Thanks.
OM
Ultrashock Forums > Flash > ActionScript
Posted on: 2004-09-18
View Complete Forum Thread with Replies
Sponsored Links:
Changing An Object Property With It's String Name?
If I have the full path name of an object like:
var1 = "parentObject.firstChild.secondChild";
and I want to change the value:
parentObject.firstChild.secondChild.price
How can I do this with access ONLY to the string variable var1?
My situation is more complicated than given above... but essentially it's the problem given above, where I only have access to the string variable.
I've tried something like:
this[var1].price
But that doesn't work.
I can get access to the variable with eval(var1 + price)... but with the rules of the use of eval changed from Flash5, I can't use this.
Any ideas?
Does anyone understand my mad problem?
Any help would be appreciated.
Thanks.
OM
View Replies !
View Related
Using String Concatenation To Get Property Object, Please Help Me
Hi, I'm an ActionScript newbie, and I would like to ask you a very simple question because this problem is making me crazy.
This is a simplified part of my script:
Dati_colori = new LoadVars();
Dati_colori.load("immagini/colori/"+_root.num_img+".txt");
The file is this:
&num=3&colore1=0xFF0000&colore2=0x00FF00&colore3=0x0000FF
The first variable is the number of colors (that are the other variables)
After the file is loades, I can access to the values by writing:
Dati_colori.colore1, Dati_colori.colore2, ecc ecc.
Now the problem: I would like to put this in a for cicle:
colors is an array containing the values
for (a=1;a<Dati_colori.num<a++){
colors[a] = Dati_colori.colore+a //this concatenation DOES NOT WORK!! I cannot access this way to the property containing the
}
Maybe it is just a formal problem but I cannot succeed in using string concatenation to get the property value.
Thanks in advance for any suggestion!
Davide (from Switzerland)
View Replies !
View Related
Save Object To String -> Load String And Convert Back To Object?
Wondering if anyone knows if this is possible. First a little explanation:
1. I have container grid where you can add and position MC's
2. The MC's x,y and other data is stored in a 3d object
3. The object is setup like this: matrix (object) -> levels (objects) -> profiles (objects). So basically a grid which mirrors what you see on screen.
This all works great; however, the application needs to have a save feature. My first thought was decode the matrix into an XML and save that.
Then I thought maybe you can just convert the matrix object to one big string and save that.
Questions: when the string is loaded back into the movie how do you (or can you even) covert it back in a object that flash can read?
Any help/input is greatly appreciated.
View Replies !
View Related
_name Property Changing But Not Changing
I am working on an application where a user can select a movieclip that has been dynamically placed on the stage and then choose Send to Front or Send to Back (compared to the other objects on the stage with it).
As part of this process I am renaming the instances using code that basically looks like this: setProperty(myMovieClip, _name, newMovieClipName);
Using the debugger I noticed something unusual. In the properties tab the _name property changes to the newMovieClipName value I am assigning it. But the target it shows remains unchanged (_level0.container_mc.myOldMovieClipName).
I think this is causing problems elsewhere when I try to target these movie clips. Does anyone know how to completely change an instance's name, or is this just the way it works? Any insights are appreciated.
View Replies !
View Related
Changing A String Name In A Loop / Concatonating String Name?
Hey all,
Does anybody know of a way to change a string name as a loop proceeds?
This is the main piece of code that I wish to loop with i incrementing, so that whilst i=0 then:
_root.barARed._visible=barRed[i];
_root.barARed._width=barLength[i];
_root.barAYellow._visible=barYellow[i];
_root.barAYellow._width=barLength[i];
_root.barAGreen._visible=barGreen[i];
_root.barAGreen._width=barLength[i];
infoA.text=info[i];
and i=2 then:
_root.barBRed._visible=barRed[i];
_root.barBRed._width=barLength[i];
_root.barBYellow._visible=barYellow[i];
_root.barBYellow._width=barLength[i];
_root.barBGreen._visible=barGreen[i];
_root.barBGreen._width=barLength[i];
infoB.text=info[i];
and so on...I would use _root.barRedInstanceName[i]._visible=barRed[i]; but I can't give the movie clip (the bar) an instance name such as redBar[1], redBar[2] etc. (system reserved I'm told)
I guess what I am trying to ask in a roundabout way: is how do you concatonate the name, rather than the contents of a string?
Hope you'll forgive me if this is something really simple that I am overlooking, but I only have a very short experience of flash.
Thanks
Al
View Replies !
View Related
What's The Best Way To Parse Out A Url String Using The String Object In Flash
I'm creating a CMS(Content Management System) tool so that users can change text and the changes be reflected in a text window in flash . The text that the user enters in the CMS tool will be stored in the database.
In flash I want to parse the string that I get from the database and look for URL strings that start with http "http://www.someurl.com" and parse out that substring.
For example the string could be "Please vist my site at http://www.site.com". I would want to parse out the http://www.site.com
If I find this url string I want to pre-pend the a href tag <a> and append the closing </a> tag to the string so that this link will be clickable from the textfield.
Does flash have an object that deals with Regular Expressions?
I've looked at the String object in flash but not sure how to achieve this task
I'm currently working on this so any ideas?
View Replies !
View Related
Pass A String, Return Object With Name String
I feel like this should be pretty easy, but I 'm not quite sure how to do this...
I've got a string that is the name of a movieclip which is on the stage. I'd like to write a function which I can pass that string and have it return the object which has the instance name of that string.
Any hints?
Thanks.
John
View Replies !
View Related
What's The Best Way To Parse Out A Url String Using The String Object In Flash
I'm creating a CMS(Content Management System) tool so that users can change text and the changes be reflected in a text window in flash . The text that the user enters in the CMS tool will be stored in the database.
In flash I want to parse the string that I get from the database and look for URL strings that start with http "http://www.someurl.com" and parse out that substring.
For example the string could be "Please vist my site at http://www.site.com". I would want to parse out the http://www.site.com
If I find this url string I want to pre-pend the a href tag <a> and append the closing </a> tag to the string so that this link will be clickable from the textfield.
Does flash have an object that deals with Regular Expressions?
I've looked at the String object in flash but not sure how to achieve this task
I'm currently working on this so any ideas?
View Replies !
View Related
Adding A Property To A Variable String
Hi there, trying to write a little code, I have it working up to the trace but I cant work out how to get the second function to work.
I want to access the following button:
'_root.mapBig.map.shanghaiButton' with a '.onRollOver' trigger, however I cant figure out how to make the sCityPath work with the .onRollOver.
function cityLoader(sCurrentCity:String):Void {
var sCurrentCityButtonName:String = sCurrentCity+"Button";
var sCityPath:String = "_root.mapBig.map."+sCurrentCityButtonName;
trace (sCityPath);
sCityPath.onRollOver = function() {
....
};
};
cityLoader("Shanghai");
Any ideas would be great.
View Replies !
View Related
Object.property.property ?
I'm making a movie that will read data from an object and build some rows and columns of radio buttons, but I'm having some trouble dealing with the objects that I'm using to store data on the _root.
Here's what I'm trying to test:
I have the following code on the root of my movie:
PHP Code:
radio_button_object = new Object ();
radio_button_object.row_2 = 2;
radio_button_object.row_2.radio_button_1 = true;
radio_button_object.row_2.radio_button_3 = true;
Within a movie clip named "radio_button", I've got the following code:
PHP Code:
myObj = eval ("_root." + this._name + "_object");
// inside a for loop I'm going through rows
// inside that for loop, I have another for loop that goes through columns
for (i...) {
for (j...) {
if (myObj ["row_" + i]) {
if (myObj ["row_" + i + ".radio_button_" + j]) {
(eval ("row_" + i + ".radio_button_" + j)).gotoAndStop ("selected");
}
}
}
}
I've tried:
PHP Code:
myObj ["row_" + i ["radio_button_" + j]]
and:
PHP Code:
myObj ["row_" + i] ["radio_button_" + j]
But I've had no luck.
Essentially, I'm looking for object.property.property, except that the object name and all property names are variables.
Can anyone help me out?
Thanks!
cooper
www.pigdogtoad.com
View Replies !
View Related
Gradual Property Changing
What is the most elegant way to make a property of a movieclip gradualy change? Is it making a new movieclip named "timer" with a few frames and in each one is a setProperty() that changes the wanted target? Is there a more elegant way?
I want to make a movieclip of my choice change it's alpha from 100 to 0 but without that object having more frames.Can I do that without a new movieclip? Hmm, it sounds quite nice talking about it.. that could be the nicest way. But allways striving for perfection. I hope I spelled all this correctly..
View Replies !
View Related
Duplicating And Changing Property
hello..
i am working on a small puppet type applet for children.
The puppets are individual movieclips with limited animation that can be controlled by key board input. say move hands or rotate body. Now i want a movie clip to get duplicated in to a plane graphic ( almost like a snapshot of the movieclip at that particular time. say, hands moved up) by a mouse/keyboard event. This should be a stand alone graphic symbol with a different name. I would change the properties of the parent movie clip later but those changes shouldnt occur for the duplicated symbol.
Please help me out.. thanks
anand.
View Replies !
View Related
Duplicating And Changing Property
hello..
i am working on a small puppet type applet for children.
The puppets are individual movieclips with limited animation that can be controlled by key board input. say move hands or rotate body. Now i want a movie clip to get duplicated in to a plane graphic ( almost like a snapshot of the movieclip at that particular time. say, hands moved up) by a mouse/keyboard event. This should be a stand alone graphic symbol with a different name. I would change the properties of the parent movie clip later but those changes shouldnt occur for the duplicated symbol.
Please help me out.. thanks
anand.
View Replies !
View Related
Accessing A Property Of An Object Within An Object
I have modified a simple button object, which I called the OP Button in the library, and it contains two dynamic text fields. I had to add these text fields because I encountered a problem. Having the text above the button caused the button not to activate when the user went over the dynamic text field. Tried to have the text below the button, but the blue highlight with the button made the text fuzzy. I need to have the text dynamic because I need it to hold different values.
I have created the new button. In the library of Flash it is registered as OP Button ( a name I gave the button type ). I can edit the button and see the dynamic text object, which I gave the name of NormalText. I need to know how to change the .text property of the dynamic text located in the modified simple button.
The instance of the newly created button is OP4Button and the name of the dynamic text field within this button is called NormalText. How do I change the .text property from the main stage action script?
The button was created in design mode and not through action scripts. Even though I created in design mode, I need to access it through Action Script. Any help will be greatly appreciated.
Thank you
Edited: 06/16/2007 at 10:49:18 AM by David Cowdery
View Replies !
View Related
Changing _alpha Property Of A Sybol
Alright, i have a button, that would change the background, but the button, is part of a movieClip, and i set the background to a symbol(outside of that movie), i'd like to use _alpha method to make it visible once you click on it, and i medenge to do that as long as the button is not part of a MovieClip. Any one can help me out? How can i set a ClickOn to change a proparty of a particular symbol?
Thanks all
View Replies !
View Related
Changing .text Property From Eventhandler
Code:
var FacilityPassListener = new Object();
LName.addEventListener("focusIn", LNameListener);
LNameListener.handleEvent = function(eventObj) {
trace("listener is LNameListener"); //as expected
if (eventObj.name == "focusIn"){
login_mc.myText._y = row2; //no change
login_mc.myText.text = "enter name."; //no change
}
I'm able to fire the correct event via the inputtext control (LName) but I can't get the code inside the handler to control the text field.
I've reviewed notes on the delegate class but that doesn't appear to apply to this situation. Or does it?
View Replies !
View Related
Changing Text Property Using Script
I'm using 3D Flash Animator. I have an action where I need to change the "text" property of a text element. The problem is the .text property is not changable. I can trace and see the correct output (Example: my element is Text10, the following code outputs the correct value...
Trace(element("Text10").text)
outputs 11 (my original text)
Trace(getDate())
outputs 31 (todays date)
I can use following without errors:
element("Text10").text = getDate()
element("Text10").show()
My element shows, but it's still 11
I need to display and change the current date and it's not feasable to have 31 elements to do this.
ARGH!!!!!!!!!!!!!!!!!!!!!!!!!!
HELP!!!!!!!!!!!!!!!!!!!!!!
my email is webmaster@jerseythings.com
Also, where do I report bugs in 3D Flash Animator?
Thanks in advance.
View Replies !
View Related
Scaling And Changing Property Size
I currently created an exe file to run on C/D for class that is 1024 by 768. Now I would like to scale the main movie and all the movies loading into the main movie to 800 by 600. Is their a way to reduce the size (scaling down) everything on the main timeline and then reduce the property size so that I do not have to go to each element in each layer?
Thank you,
Ruth
View Replies !
View Related
Changing Property Values From Within A Function
I'm wondering how I can change a property of an instance from within a function inside a method. I have some code here... Basically I just need to set _lynn_idle to false when a tween is occuring and _lynn_idle to true when the tween is finished. Unfortunately I can't seem to simply set it to false or true inside these listener functions like I'm able to anywhere else (seems the variable is only local to the function when I need it to access the variable associated with the instance). Any help is much appreciated.
Attach Code
private var _lynn_idle:Boolean;
public function moveToTile(tilecoord:Array):Void {
// move lynn with a tween
var startx:Number = _lynnmc._x;
var starty:Number = _lynnmc._y;
var endx:Number = (30*tilecoord[0])+(30*tilecoord[1]);
var endy:Number = 15*(tilecoord[0]-tilecoord[1]);
// determine how long the tween should take
var movedur:Number = 12;
var moveListener:Object = new Object();
moveListener.onMotionChanged = function():Void {
_lynn_idle = false;
// check depths of props and swap
}
moveListener.onMotionFinished = function():Void {
_lynn_idle = true;
// rebuild floor
_lynn_pos = tilecoord;
_global.room.newFloor();
// doAc() to props
}
var moveLynnx:Tween = new Tween(_lynnmc, "_x", Regular.easeInOut, startx, endx, movedur, false);
var moveLynny:Tween = new Tween(_lynnmc, "_y", Regular.easeInOut, starty, endy, movedur, false);
moveLynnx.addListener(moveListener);
}
View Replies !
View Related
Changing Property Values From Within A Function
I'm wondering how I can change a property of an instance from within a function inside a method. I have some code here... Basically I just need to set _lynn_idle to false when a tween is occuring and _lynn_idle to true when the tween is finished. Unfortunately I can't seem to simply set it to false or true inside these listener functions like I'm able to anywhere else (seems the variable is only local to the function when I need it to access the variable associated with the instance). Any help is much appreciated.
Attach Code
private var _lynn_idle:Boolean;
public function moveToTile(tilecoord:Array):Void {
// move lynn with a tween
var startx:Number = _lynnmc._x;
var starty:Number = _lynnmc._y;
var endx:Number = (30*tilecoord[0])+(30*tilecoord[1]);
var endy:Number = 15*(tilecoord[0]-tilecoord[1]);
// determine how long the tween should take
var movedur:Number = 12;
var moveListener:Object = new Object();
moveListener.onMotionChanged = function():Void {
_lynn_idle = false;
// check depths of props and swap
}
moveListener.onMotionFinished = function():Void {
_lynn_idle = true;
// rebuild floor
_lynn_pos = tilecoord;
_global.room.newFloor();
// doAc() to props
}
var moveLynnx:Tween = new Tween(_lynnmc, "_x", Regular.easeInOut, startx, endx, movedur, false);
var moveLynny:Tween = new Tween(_lynnmc, "_y", Regular.easeInOut, starty, endy, movedur, false);
moveLynnx.addListener(moveListener);
}
View Replies !
View Related
Changing SelectedIndex Property Of Combobox From XML
I have a combobox that holds the states as data. I am returning XML that shows the states in the two letter abbreviation (ex. MN), I need to be able to update the combobox based on the XML returned data. Any ideas on how to implement this?
ActionScript Code:
<mx:FormItem label="State: ">
<mx:ComboBox id="stateCombobox" dataProvider="{statesList.state}" prompt="Select a State" selectedIndex="-1" change="validateForm(event);"/>
</mx:FormItem>
<state label="Minnesota" data="MN"/>
XML:
<User>
<State>MN</State>
</User>
View Replies !
View Related
Changing The Alpha Of A Property When Clicking A Button
I have this code in AS 3.0:
stop();
myBtn.buttonMode = true;
myText_mc.alpha = 0;
myBtn.addEventListener(MouseEvent.CLICK, ClickFunction);
function ClickFunction(event:MouseEvent):void{
myText_mc.alpha = 1;
}
I want the alpha of the movieclip called myText_mc to start at 0 (not seen) and then appear when clicked...it does not work, what did I do wrong?
Thanks
View Replies !
View Related
Object Property Leak
Heres some simple code I was using, but for some odd reason, the points 1-7 appear in the trans object??
In frame 1:
Code:
function new_Mesh(type){
mesh = new Object();
if(type == "cube"){
mesh.numPoints = 8;
mesh.point0 = [-50,50,50];
mesh.point1 = [50,50,50];
mesh.point2 = [50,-50,50];
mesh.point3 = [-50,-50,50];
mesh.point4 = [-50,50,-50];
mesh.point5 = [50,50,-50];
mesh.point6 = [50,-50,-50];
mesh.point7 = [-50,-50,-50];
}
return mesh;
}
function new_IdentMX(){
var matrix =[
[1,0,0],
[0,1,0],
[0,0,1]];
return matrix;
}
function new_XrotMX(deg){
var rad = (deg*(Math.PI/180))
var matrix = new_IdentMX();
matrix[1][1] = Math.cos(rad);
matrix[1][2] = -Math.sin(rad);
matrix[2][1] = Math.sin(rad);
matrix[2][2] = Math.cos(rad);
return matrix;
}
In frame 2:
Code:
MyMesh = new_Mesh("cube");
Trans = new_XrotMX(30);
stop();
put this code in two keyframes, and goto debugger, and look at the contents of Trans. points are there, which shouldn't.
Is this some sort of bug? Most likly not, but its apparent that nothings wrong.
View Replies !
View Related
Object Colour Property
Hey guys,
Is it possible using purely actionscript to draw a box in a specific location, and give it a certain colour value, then 'tween' it to another colour value?
What Im trying to do, is setup a movie which changes scenes by smoothly changing the background colour to the colour of the next scene.
This obviously poses a problem .. because depending on what scene you are in, and what link you chose, the starting and finishing colour of the box must be different in each case.
Any ideas?? Would be awesome
View Replies !
View Related
Object Property Question
Hello,
fieldname = object.name?
I'm curios as to how the 6th line of code works --
-- _root.txtName = c.name. In particular the c.name oop syntax. I thought the correct name property was written as... _name not just ...name? This code only executes if the word "name" is used -- no substitue words will work. I can't find anything on this in Flash Help.
Any enlightment will be appreciated.
Thank You
iaustin
var c = new loadvars();
c.onload = information;
c.sendandload("http://www.digitizedi.com/test.php", c, "POST");
function information(success) {
if (success) {
_root.txtName = c.name;
// Or you can also use:
//_root.txtName = c["name"];
} else {
_root.txtName = "operation failed";
}
}
View Replies !
View Related
How Do U Assign A Property Name To An Object?
here's the problem I want to assign a name to a property in a object dynamicly. Normaly I would just do this
rooms = {}
rooms.bedroom = ["bed", "tv", "hamper"]
but the name of the property is generated dynamicly and is a string. So if i have a string, how do i make it the property name. Example:
rooms = {}
rooms.["bedroom"] = ["bed", "tv", "hamper"]
Any ideas?
View Replies !
View Related
[CS3] Having An Array As A Property To An Object
Hey folks!
Does anyone know how to create multidimensional properties in an Object?! (ie. Having an array as a property to an Object)
This works:
Code:
data = new Object();
colName = "some_name";
data[colName] = "the data";
trace(data.some_name);
trace(data[colName]);
But I need to to this on a deeper level. Like this:
Code:
data = new Object();
colName = "some_name";
data.property.[colName] = "the data";
trace(data.property.some_name);
trace(data.property[colName]);
I been trying several ways to solve this problem. Searching google over and over. But I just can't find the solution!
Does anyone know how to have an array as a property!?
View Replies !
View Related
Limitations Of Object / Property Name
Say I am creating a movie clip like so:
_root.createEmptyMovieClip("someString",someDepthI nt);
What character limiatations are there for the "someString" parameter? For instance, can i have a '.' or a '_' in this string and still be able to access the new movie clip via _root.someString or _root["someString"] ?
View Replies !
View Related
Remove Property From Object
Hi,
I have an ObjectCollection class which I need to allow me to add and remove props from an object.
The adding is easy, and I can remove a property's value, but how do I remove the prop itself:
Code:
delete myObject["prop"]
... removes the value, but if I iterate through the object, the property still remains, just with the value of null. So how do I get rid of the property?
Thanks
View Replies !
View Related
Object Property - Can It Have A Space?
for instance, in a for loop i have the following code
clearly it will not compile because of the "Total Verts" code, is there anyway to make a space in a property?
The reason i ask is because im populating a data grid with the property names, and I wanted the section to be named "Total Verts"
var frameObj = new Object();
frameObj.Total Verts = framesArray[i].totalVerts;
frameObj.Elements = framesArray[i].totalElements;
frameObj.Frame = framesArray[i].frameNum;
View Replies !
View Related
Object Property Typing
heres my problem
slideshowimage[slideshowimages]=new Object;
slideshowimage[slideshowimages].isinshow=true
slideshowimage[slideshowimages].address=testpic1.jpg
slideshowimage[slideshowimages].xoffset=0
slideshowimage[slideshowimages].yoffset=-50
How can i define each of these properties so that they are the correct type
for example :
i would like the property "isinshow" to be defined as a boolean and "xoffset" defined as an int and etc...
Anyone know how to do this?
View Replies !
View Related
Using A Variable To Specify An Object Property
Hey all,
Suppose I have
columnName : String = 'name';
and then I have a dataGrid that I want to add an item to via:
dG.addItem({columnName:'joe'});
This creates a column called "columnName". Is there a way to use the value of the string "columnName" instead as the column title?
Thanks in advance!
fitz
View Replies !
View Related
Object.constructor Property
<definition from ActionScript 2.0 Language Reference>
...constructor (Object.constructor property) ... Reference to the constructor function for a given object instance. The constructor property is automatically assigned to all objects when they are created using the constructor for the Object class ...
//--- --- - - -
i thought i understood this until i started doing some multiple level inheritance ..
imagine three classes:
-- class Object . . . (top level class)
-- class ParentClass . . . (implicitly inherits from Object)
-- class ChildClass extends ParentClass . . . (explicitly inherits from ParentClass)
and three objects:
-- var obj:Object . . . (an instance of Object)
-- var parentObj:ParentClass . . . (an instance of ParentClass)
-- var childObj:ChildClass . . . (an instance of ChildClass)
what we get:
obj.constructor == Object //-- as expected
parentObj.constructor == ParentClass //-- as expected
childObj.constructor == ParentClass //-- i would have thought it would be == ChildClass
//--- --- - - -
furthermore .. if i change my class definitions to be a bit less ambiguous:
class Object . . . (top level class)
class ParentClass extends Object . . . (explicitly inherits from Object)
class ChildClass extends ParentClass . . . (explicitly inherits from ParentClass)
what we get:
obj.constructor == Object
parentObj.constructor == Object
childObj.constructor == Object
//--- --- - - -
if this is the intended functionality of the constructor property i'm not sure i understand what its purpose is .. or am i completely misunderstanding something here .. if anyone has any answers i would be happy to hear them
also .. feel free to ask for clarification (if i was unclear) or more complete code samples.
Edited: 04/26/2008 at 02:16:39 PM by _peabulls_
View Replies !
View Related
Using_alpha Property To Fade An Object::
I'm wanting to ask what actions to apply to an object to make it fade in rather than using a motion tween to achieve this. The reason is that I understand by doing this, you save overall file size because the motion tween makes for larger file size. - Can somone please enlighten me?
View Replies !
View Related
Accessing Object Property Indirectly
Hi. I am trying to set (and retrieve) an object property through a constructed variable.
Items = new Array();
Items[0] = new Object();
propName = "Description";
tempVar = "Items[0]."+propName;
eval(tempVar) = "This is the description";
======
The above eval does not assign "This is the description" to Items[0].Description.
What command do I use to make the assignment?
Many thanks,
Tracy Boland
View Replies !
View Related
Adding An Array As A Property Of An Object
Hi all,
I'm generally familiar with addProperty and all of it's little foibles (ho-hum). The one thing I can't seem to get working is having an array as a property.
code: Tracker = function (){
this.addProperty("_sprites", Tracker.prototype.getSprites, Tracker.prototype.setSprites);
}
Tracker.prototype = new Object();
Tracker.prototype.getSprites = function(){
return this._sprites;
}
Tracker.prototype.setSprites = function(newSprite){
if (!this._sprites){
//the sprites array does not exist, create it
this._sprites = new Array();
}
for (x = 0; x < this._sprites.length; x++){
exists = 0;
//assume the sprite doesn't exist
if (this._sprites[x] == newSprite){
//the sprite does exist!
exists = 1;
theSprite = x;
//mark where it is in the array
break;
//no need to search any more, leave the for loop
}
}
if (exists){
//it exists, so remove it
this._sprites.splice(theSprite,1);
}else{
//it doesn't exist, create it
this._sprites.push(newSprite);
}
};
So, how do you create an array as a property of on object?
I think I see Catbert coming
View Replies !
View Related
Please Help - Variable Object Property Names
I need to create variable object property names for use with the data grid component.
This works:
data = new Object();
data.some_name = "the data";
But this does not:
data = new Object();
colName = "some_name";
data[colName] = "the data";
Can anyone help me? Can object property names be variable?
Thanks.
View Replies !
View Related
Removing Property From A Predefined Object
How do you remove a user defined property from a predefined object?
For example, if I set a property of a movie clip:
myMC.myProp = myValue;
I can retrieve the value with a for..in loop.
Later I want to clear the property so that 'myProp' does not get evaluated in a for..in loop.
How do I do this?
View Replies !
View Related
Using JS SetVariable To Change The Value Of An Object Property
Hi, I know this JS code can change the value of a simple variable which resides on the root ("myVar")
Code:
<SCRIPT LANGUAGE=JavaScript>
<!--
function doPassVar(args){
var sendText = args.value;
window.document.myFlash.SetVariable("myVar", sendText);
}
//-->
</SCRIPT>
link: http://www.macromedia.com/cfusion/kn...fm?id=tn_15683
can this method be used to change a property of a class instance?
Assuming I have a myClassInstance which is an instance of a myClass(), the class has a property named "value".
Will putting this code in the JS change the myClassInstance.value?
Code:
window.document.myFlash.SetVariable("myClassInstance.value", sendText);
View Replies !
View Related
Passing To Object.text Property
I can't understand why the text string will not pass to the variable userAnswer.
AnswA.distractor.text = "My text string here";
userAnswer = AnswA.distractor.text;
trace(userAnswer);
I can't get the string to trace, i've tried other formats including...
trace(AnswA.distractor)//0
trace(AnswA.distractor.text)//0
thank you
iaustin
View Replies !
View Related
Line Object Property -> Array
I am attempting to step through a line and copy information into an array.
I tryied creating a class but got errors.
Code:
class node {
private var x:number;
private var y:number;
private var percent:number;
private var distance:number
}
all the same, even using an array to store my data did not work
Please help!!!
Code:
// create a clip to draw to
_root.createEmptyMovieClip("mc", 1);
// set our line style
mc.lineStyle(1, 0x000000);
// draw the line based on handle locations
mc.moveTo(10,10);
mc.lineTo(100,100);
mc.lineTo(50,150);
mc.lineTo(200,200);
mc.lineTo(100,250);
var myArray = new Array();
var count:Number = mc.length;
trace(count);
trace(mc(0).x);
myArray(0).x = mc(0).x
myArray(0).y = mc(0).y
myArray(0).percent = 0.2
myArray(0).distance=12
//for ( var i=0; i<myArray.length; i++) {
// trace(myArray[i]);
//};
also any help on using the debug to view my variables.
I couldn't see any of my local variables in the debug window.
View Replies !
View Related
|