Actionscript: Get Object From Its String Name
Hello everyone
I've put many instances of single movie clip on 'scene1'. I named them 'car11', ..., car'55' (array 5x5) Now in actionscript I need to change their visibility, but I have only strings with their names.
After some calculations I get: i=4; j=2; So name would be: name = "car" + i + j; Now I would like to hide this movie clip 'car42'. I can't do this: _root.name._visible = false; becouse 'name' is only a string object not a movie clip object. How can I create a movie clip variable from this string? Is it possible? or do I have to find a different workaround?
Tek-Tips > Adobe(Macromedia): Flash Forum
Posted on: 5 Apr 03 3:33
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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.
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?
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
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?
Object To String?
I have an object that reads this in the output window:
_level1.scroller.tmp_mc.instance7.cont_3.cont_1.co nt_1.cont_1.cont_1.link_1
im trying to create a function which counts how many levels there after the first "cont_". ive tryied this function, and many other simaler combinations:
function find_level(obj) {
myString = obj.toString();
i = myString.split("cont_", 2);
myStringTwo = i[1];
stages = myStringTwo.split(".");
levels = stages.length;
return levels;
}
String To Object?
Hey Folks,
I've got an easy one for ya'll...
I want to turn text into an object reference.
For example, I have:
3 movie clips whose instance names are "myMc1", "myMc2",
and "myMc3", and a text box (instance name "tb") the user
will enter 1, 2, or 3.
I want to use that text variable (1, 2, or 3) to construct
an object name to access either myMc1, myMc2, or myMc3. Code
is pasted below...
///// create either myMc1, myMc2, or myMc3
var theName = "myMc" + _root.tb.text;
///// end code
Now, how would I use theName to reference the movie clip?
I've tried new object (theName). Am I on the right track?
Thanks for the help in advance,
Tripp Lowe
The University of Georgia
School of Forest Resources
GIS Lab Manager
String To Object
How do I convert a data string to an Object in flash?
Would I just use
foo = new Object(textString)?
Specify Object, Not String... Please Look.
when i'm creating an array it's not recognizing that i am inputting the names of objects, not just strings. how do i specify that something is an obnject without creating a new object?
Xml Object To String
im having trouble converting a xml object value to a string.
I am trying to get the node value and then place the node value in an alert component (yahoo flash astra alert component).
When i try to do so i get the following error "TypeError: Error #1034: Type Coercion failed: cannot convert global@5669f101 to flash.display.DisplayObject."
i have tried xml.tostring and xml.nodeValue and neither work.
Code:
function sendBtnCLICK(e:MouseEvent)
{
var msgXML:XML;
statusMessage._visible = true;
function urlSendToPhoneLoader_complete(evt:Event):void
{
msgXML = new XML(urlLoader.data);
//traces fine and gets the value
trace("xml reads:" + msgXML);
var msg:String = msgXML.message.toString()
AlertManager.createAlert(this, msg);
}
}
why am i getting an error if i have .tostring and have datatyped it a string? What am i doing wrong?
String To Object Name
during component developing i've used this way mostly.
i think it is very usefull.
var outArr:Array;
var myString:String = "myArr";
var myArr:Array = ["part_0", "part_1", "part_2"];
outArr = eval(myString);
trace(outArr);
String To Object ?
Hello all,
I started with Flash/Actionscript a week ago, a have some programming expirience, but it seems i still haven't fully understood the oop.
I'll keep it short.
I want to fade away the movie instance: p1pic_mc
the trace tells me that the Object "test" is "p1pic_mc" but why doesn't the Tween function accept it? casting problem?
thank's for any help !
Code:
var activePlayer:Number = 1;
function done(){
var test:Object = new Object("p"+activePlayer+"pic_mc");
new Tween(test, "_alpha", none,100,0,15,false);
trace(test);
};
Object Name To String
a little example at first:
if i do trace(_root.myMovieClip) it returns _level0.myMovieClip wich is good.
is there any way to transform this "_level0.myMovieClip" to a string?
don't ask me why but i want to make a subtr on this thing.
hope i'm clear enough
thanks in advance
String In Object Name
hi, wondering if someone can help me,
i have some script in which the object name will be created from a string and now i need to call another object within the object and not sure how to do it.. here is some code:
u will see on the first line of the code an object is duplicated with a new name
and on the last line i need to change the value of an object within that new object i duplicated.. no i am not show how to do it with it's new object name, at the moment i just tried pic+i
u see on the 2nd line i am able to do it because i am able to put the object path within " ".
hope it not to confusing.
Attach Code
for (var i:Number = 1; i<fashionarraynames.length; i++) {
_root.mainboard.fashion_pics.pics.loadclip.duplicateMovieClip(("pic"+i),depth,{_x:imgpos, _y:0});
loadMovie("http://www.urlhere.com/portfolio/thumbs/"+fashionarraynames[i], "_root.mainboard.fashion_pics.pics.pic"+i+".button.img.imggoeshere");
_root.mainboard.fashion_pics.pics.pic+i+.button.imgurl.text="value here"
}
Edited: 09/23/2008 at 03:20:58 AM by PixelPaul1
String Vs Object - ?
To ask this as simply as possible I will water down what I am trying to do.
ActionScript Code:
pwn_ab.onPress = pwn_bb.onPress=function () { var piece = new Object(this._name); if(piece == "pwn_ab"){ this.startDrag(false, 19, 57.4, 19, 207.4); }
I have two buttons on the stage, pwn_ab and pwn_bb - say I press button pwn_ab, the code works just fine. The problem is, see how I have ("") around pwn_ab in the ifStatement, this means my variable "piece", is a string - how can I make the variable "piece" not a string so the code below will work? Notice I removed the (“”) from pwn_ab in the ifStatement.
ActionScript Code:
pwn_ab.onPress = pwn_bb.onPress=function () { var piece = new Object(this._name); if(piece == pwn_ab){ this.startDrag(false, 19, 57.4, 19, 207.4); }
String To Object
hi everyone,
i guess there have already been dozens of people asking this question, and i am sorry to ask again, but i did not find alone:
i would like to create lots of copies of lots of different clips (the original clips are called _root.model_a, _root.model_b, _root.model_c ... ...) and then asign them a position depending on variables. i am using inside a loop:
cnt++;
duplicateMovieClip("_root.model_"+utype, "copy"+cnt, cnt);
"copy"+cnt._x = ux;
"copy"+cnt._y = uy;
then an error message tells me that the thing on the left side of the assignement "=" is not a varriable / property.
i would like it to be a property, but to do so i guess i need to transform the thing in red (a string) to the reference to the object that has the same name.
in this tutorial the problem is solved by putting the 2 critical line inside the clip that will be duplicated and by puting:
this._x = ux;
this._y = uy;
but i do not have only 1 clip that will be duplicated and i don't want to put some code in each (if that is possible).
in fact i would like to make an externall call to the object that is called "copy"+cnt instead of an internall call using this.
please tell me what i should do
String Object
I'm not sure exactly what the point of this is, but I've basically reconstructed a String object in PHP.
It requires PHP5, as it uses Interfaces:
PHP Code:
<?php
/*************************************
/* PRIMITIVE CLASSES
* -----------------
*
* Basically, this extends the default
* functionality of primitives and
* their related functions to be more
* OOP. I'm not sure exactly what use
* it has yet...
************************************/
class String implements Iterator {
/* Future Features:
* Ha! Caught up for now...
*/
public $string;
private $position;
public function __construct ($string) {
$this->string = (string) $string;
}
public function getStr () { return $this->string; }
public function __toString () { return $this->string; }
/** STRING FUNCTIONS **/
// The destructive ones
public function prepend ($str) { $this->string = $str.$this->string; }
public function append ($str) { $this->string .= $str; }
// The non-destructive ones
public function strmsk ($char_list) {
// Masks string to only contain letters in $char_list
$haystack = str_split($this->string);
$newstr = array(); // Array containing correct string
foreach($haystack as $letter) {
if(strpos($char_list,$letter)!==false) $newstr[] = $letter;
}
return implode('',$newstr);
}
// Iterator functions
public function rewind () { $this->position=0; }
public function current () { return $this->string{$this->position}; }
public function key () { return $this->position; }
public function next () { return $this->string{$this->position++}; }
// Post-transform to include all letters in loop
public function valid () { return ($this->position<strlen($this->string)); }
}
?>
Any suggestions for making this useful? Well, currently I find it really useful, as you can iterate through a string… I've always wanted this. But anything else?
String To Object
I have this function that receives a string which has the name of the movieClip I am attaching:
function contentsFadesin(movieFadesin:String):Void {
attachMovie(movieFadesin, movieFadesin,1);
lastSelectedMovie._visible =false;
movieFadesin._x = 369;
movieFadesIn._y = 54;
movieFadesIn._visible = true;
movieFadesIn._alpha = 2;
movieFadesIn.onEnterFrame = function() {
if (movieFadesIn._alpha<=100) {
movieFadesIn._alpha += movieFadesIn._alpha*1;
} else {
delete this.onEnterFrame;
lastSelectedMovie = movieFadesIn;
}
};
}
The movieClip is attached just fine, but then the rest of the function should fade the movie in. The problem is: the variable "movieFadesin" is passed as a string (so I can use attachMovie), but the rest of the function only accepts and "Object" variable in order to work properly.
My questions is how can I change the string value of movieFadesin into a object?
String Vs Object - ?
To ask this as simply as possible I will water down what I am trying to do.
ActionScript Code:
pwn_ab.onPress = pwn_bb.onPress=function () { var piece = new Object(this._name); if(piece == "pwn_ab"){ this.startDrag(false, 19, 57.4, 19, 207.4); }
I have two buttons on the stage, pwn_ab and pwn_bb - say I press button pwn_ab, the code works just fine. The problem is, see how I have ("") around pwn_ab in the ifStatement, this means my variable "piece", is a string - how can I make the variable "piece" not a string so the code below will work? Notice I removed the (“”) from pwn_ab in the ifStatement.
ActionScript Code:
pwn_ab.onPress = pwn_bb.onPress=function () { var piece = new Object(this._name); if(piece == pwn_ab){ this.startDrag(false, 19, 57.4, 19, 207.4); }
String To Object
hi everyone,
i guess there have already been dozens of people asking this question, and i am sorry to ask again, but i did not find alone:
i would like to create lots of copies of lots of different clips (the original clips are called _root.model_a, _root.model_b, _root.model_c ... ...) and then asign them a position depending on variables. i am using inside a loop:
cnt++;
duplicateMovieClip("_root.model_"+utype, "copy"+cnt, cnt);
"copy"+cnt._x = ux;
"copy"+cnt._y = uy;
then an error message tells me that the thing on the left side of the assignement "=" is not a varriable / property.
i would like it to be a property, but to do so i guess i need to transform the thing in red (a string) to the reference to the object that has the same name.
in this tutorial the problem is solved by putting the 2 critical line inside the clip that will be duplicated and by puting:
this._x = ux;
this._y = uy;
but i do not have only 1 clip that will be duplicated and i don't want to put some code in each (if that is possible).
in fact i would like to make an externall call to the object that is called "copy"+cnt instead of an internall call using this.
please tell me what i should do
Getting A String Object's Name
I'm trying to create a string method that prints a variable's name and it's value and eventually some other stuff.
string.prototype.print() = function () {
return stringname add "=" add this
}
I just don't know how to use the string's name in the function that it's calling. In other words if I had a string called defined as below:
truck = "chevy";
how would I access the word "truck" in the function?
Any suggestions?
-Maurice
String To Object Conversion ?
the movie clip color is not changing. Whats wrong in this code..can anyone help me with this????
Set("finalDir",this.path) ; //path is variable I'm getting from ASP
mc = _root.finalDir; // storing it in a local variable
myColor = new Color(eval(mc)); //mc is not null and i've checked that
myColor.setRGB(0x006666);
Any Way To Control An Object With A String Of With The Same Name?
Okay, first, the example I'm giving is not what I'm using it for so anything like "this is a better way to do that" really is not helpful at all, this is just an example.
Alright.
Within Flash I have a script that concantanates two variables into a string, I then run a script that removes unnecessary characters from the string, essentially leaving something like 'Movie1A".
On the stage I have a bunch of clips like "Movie1A" "Movie2B" "Movie3A"..etc.
Now, the string itself can't be used to control the clips...I've tried. _root.Movie1A.play() does nothing (was worth a shot) and every extrapolation there of.
Is there any way I can look up an object with the same name (in this case 'Movie1A') in hopes of being able to manipulate it (play and resize, etc).
Reason I'm doing it like that is I want to do it from one piece of script and the movie could be anything from Movie2C to Movie22D, so an abnormal amount of data would have to be used for an array or anything else.
So within my current structure, does anyone know a way to control an object with a varaible that has the same name?
String To Object Conversion
with my gallery component i am completley changing the way it sources and handles information. i am switching from using multiple arrays to a more OOP approach. It now also sources from xml.
the xml is easy to transform into a object from the node resources, however i am having trouble with the text file input.
the string system looks like this
dir = "gallery_0:[], group_0:{gallery_0:[], group_0:{gallery_0:[], gallery_1:[], group_0:{gallery_0:[]}}, group_1:{gallery_0:[]}, group_2:{gallery_0:[]}}";
and i am trying to create an object that looks like the following.
Code:
[Object]
|[group_0]
| |[group_0]
| | |[group_2]
| | | |[gallery_0]
| | |[group_1]
| | | |[gallery_0]
| | |[group_0]
| | | |[gallery_0]
| | |[gallery_1]
| | |[gallery_0]
| |[gallery_0]
|[gallery_0]
however i am having trouble with it setting it up so it can be split into arrays and then an object. wondering if anyone could either create a code a quick code to do this or give me advice on a better string structure for spliting into an object
thanks
Casting A String To An Object
I'm having trouble passing an object parameter using a string concatenation in a for loop...
in the for loop, I duplicate movieClips, copying a movie called "glass" and try to register it's speeds with the register() function below.
for (i = 1; i <= numObjects; i++) {
duplicateMovieClip(glass,"glass" + i, i);
register("glass" + i,20,20,20);
}
function register(object, xspeed, yspeed, rspeed) {
objects.push(object);
object._xspeed = xspeed * (2 * Math.random() - 1);
object._yspeed = yspeed * (2 * Math.random() - 1);
object._rspeed = rspeed * (2 * Math.random() - 1);
}
unfortunately, when passing tmp as "glass" + i, register thinks its a string, not an object. The object appear on stage, but doesn't move. If I hard code register() passing in as register(glass2,20,20,20) it does move.
How do I cast the string I pass in as an object?
Using A String As An Object Placeholder
Wasn't really sure how to word the title, hard to explain this in just a few words:
Basically, I have code which checks a HitTest between a ball and various surfaces every frame. Each surface is laballed square1, square2, square3, etc, so the code just goes through a for loop checking "square" + i; each time, and that works fine. However, then when I want to find out the *rotation* of the square, it doesn't work so well. If squareCount = "square" + i;, for whatever reason, if I say squareRotation = _root.squareCount._rotation, it cant understand it (despite the fact that this should work in normal Java). Here's the code more clearly:
code:
while (i < _root.squareCount){
currentSquareCount = ("square" + i);
if(_root.square1.hitTest(this._x + radius, this._y + radius, true)){
squareRotation = _root.currentSquareCount._rotation;
}
i++;
}
This doesnt work. However, this DOES work (although defeats the purpose of the code, hence the question):
code:
while (i < _root.squareCount){
currentSquareCount = ("square" + i);
if(_root.square1.hitTest(this._x + radius, this._y + radius, true)){
squareRotation = _root.square1._rotation;
}
i++;
}
[F8] Object String Reference
hello,
I have a problem using Strings and referncing to them within a function.
I have a tick box that i have created on stage that on release makes the tick visible or not visible.
however i want to pass on that visible state to another box that has the same instance name as the 1st but with a "_1" on the end. To do this i made the instance name as a String and passed that into the function, and then referenced this using '_parent[boxName]._visible = ...' As soon as i changed the reference to a String it stops working. ANY help please. I am trying to learn to write AS using relative code and not absolute, also i want to insert this AS principle into a larger project that will have 20+ of these check boxes.
The TickForum.fla is the work in progress, the tick working3 is just to help explain what i am trying to achieve visually.
Code:
function tickBox(myName:String){
var PrintBoxName:String = myName + "_1.mcTick";
trace(myName);
trace(PrintBoxName);
if (_parent[myName].mcTick._visible == false){
_parent[myName].mcTick._visible = true;
_parent[PrintBoxName]._visible = true;
trace("visible = true");
}
else if (_parent[myName].mcTick._visible == true){
_parent[myName].mcTick._visible = false;
_parent[PrintBoxName]._visible = false;
trace("visible = false");
}
}
/************************************************************
Call functions
*************************************************************/
leu1.onRelease = leu2.onRelease = function () {
var target:String = this;
trace(target);
tickBox(target);
}
[MX04] String To Object
I have this function that receives a variable that has a string value which has the name of the movieClip I am attaching:
function contentsFadesin(movieFadesin:String):Void {
attachMovie(movieFadesin, movieFadesin,1);
lastSelectedMovie._visible =false;
movieFadesin._x = 369;
movieFadesIn._y = 54;
movieFadesIn._visible = true;
movieFadesIn._alpha = 2;
movieFadesIn.onEnterFrame = function() {
if (movieFadesIn._alpha<=100) {
movieFadesIn._alpha += movieFadesIn._alpha*1;
} else {
delete this.onEnterFrame;
lastSelectedMovie = movieFadesIn;
}
};
}
The movieClip is attached just fine, but then the rest of the function should fade the movie in. The problem is: the variable "movieFadesin" is passed as a string (so I can use attachMovie), but the rest of the function only accepts an "Object" variable in order to work properly:
movieFadesin._x = 369;
movieFadesIn._y = 54;
etc...
My questions is how can I change the string value of movieFadesin into a object?
Give An Object The Name Of A String Value.
Hi. Im pretty new to as3 so this may sound pretty stupid.
Im trying to asign an object the value of a string as its name.
Code:
for(i=0;i<5;i++){
name = "myCard"+i;
var this[name]:Card = new Card();
}
is there a way i can do this?
Forsan
Object Path To String
Hi all,
I've been looking for a nifty function to convert the path of an Object to a String, but with no luck.
Example:
items.item[2].name //Object type
to...
"items.item[2].name" //String type
Anyone seen one?
Thanks
Nick
Creating An Object From A String...
Hi,
I'm currently trying to create a game object from a string.
This is the syntax I use:
Code:
var baseObj = new ["BaseObject"](_object);
The class name is BaseObject. This method does not work. Im trying to create object that way because I want to create objects from a text file.
Does anyone knows a better solution on how to create a new object using a string?
Thanks,
Steve
How To Convert A String To An Object?
Hi all,
I have a problem I ws hoping someone could help me with. I am trying to build a generic function that takes in an event object from a mouseover event, renames the target name (ex. old target=h1 , new target name=b1) with regexp then calls that new object instance to play a frame (b1.gotoAndPlay(2)). This is so I can have h1, h2, h3 event activate target play on b1, b2, b3 with regexp.
Code below:
// events
h1.addEventListener(MouseEvent.ROLL_OVER, over);
h2.addEventListener(MouseEvent.ROLL_OVER, over);
function over(evt:MouseEvent):void
{
var newTarget:String;
var oldTarget:String = evt.target.name;
newTarget = oldTarget.replace('h','b');
//??? this doesn't work because its not an object but string currently
newTarget.gotoAndPlay(2);
}
Any thoughts? I could always do a if loop (if h1 then b1.gotoAndplay, if h2 then b2.gotoAndPlay etc.. but seems like bad practice... )
PLease let me know if you need more information, this is my first time posting to a technical forum
Thanks in advance.
Create An Object With Name From A String
I'm having some difficulties to describe my problem, but I hope someone still understands it
I have a method called switchPage which receives 1 String parameter (the classname of the Object that should be created). The problem is that I don't know how to make that String into a new instance of an object with the parameter name.
Here's an idea of basically what I want to accomplish.
ActionScript Code:
private function switchPage(pageID:String):void
{
var contentPage:pageID = new pageID();
}
How I Can Reference To Object By Its String Name?
Hello,
I need to get reference to object by it's STRING name. How it can be done?
ActionScript Code:
someVariable = new Object():Object;
anotherCopy = getValue('someVariable');
so what function instead of getValue I must to use to get the value of someVariable?
Converting String To Object
Hi all.
I'm trying to convert a String into an Object, but it's not working.
When I'm trying to make the String become an Object, it's still remains a String.
I've also tried using the eval function, but it did nothing, and only returned "undefined".
How can I make this String become an Object:
Attach Code
{metadata:{listLength:2},response:[{name:"Moshe",id:200},{name:"Dudu",id:202}]}
Changing An Object Name To A String
Is there any way to do this?
Say I have a global variable called yarr:
_global.yarr = textbox;
and I want to change that in to a string, I want to change it to "textbox" instead of textbox. Is there any way to do that?
How To Create Object With String?
Hi all,
Is there anyway to create an object with a string?
For example :
var myClassString:String = "myClass"; // myClass is my real class
then create an object with something like :
var myObject object = new myClassString(); // I need to create the object from the string ....
Anyone please? Many Thanks in advance.
Best Regards
Can A String Be Converted To An Object Name?
- I have multiple mxml elements: " ... id="myName1, id="myName2 ... id="myNameN>
- I want to call a function to act on all these elements such as ...
function doSomethingRepeatedly () {
for ( ... ) {
var thisName:String= ... concatenate "myName" & sequential numbers
doSomething(thisName)
}
}
function doSomething(whichElement) {
... convert the string contained in "whichElement" to an object name "thisElement"
thisElement.someProperties=someData
}
1) Can I convert the string input to an object this way?
2) Is there a better way to do this?
Thanks in advance for any help.
Changing An Object Name To A String
Is there any way to do this?
Say I have a global variable called yarr:
_global.yarr = textbox;
and I want to change that in to a string, I want to change it to "textbox" instead of textbox. Is there any way to do that?
How To Create Object With String?
Hi all,
Is there anyway to create an object with a string?
For example :
var myClassString:String = "myClass"; // myClass is my real class
then create an object with something like :
var myObject object = new myClassString(); // I need to create the object from the string ....
Anyone please? Many Thanks in advance.
Best Regards
How To Create Object With String?
Hi all,
Is there anyway to create an object with a string?
For example :
var myClassString:String = "myClass"; // myClass is my real class
then create an object with something like :
var myObject object = new myClassString(); // I need to create the object from the string ....
Anyone please? Many Thanks in advance.
Best Regards
String Object Question
Here is an easy one.
I have this working in Flash5
this[i].gotoAndStop(ord(c));
Now that ord has been deprecated, how can I re write this statement for 6?
Split Method Of String Object
Can anyone give me a small example of how the split function works? For example I have a string say
myString="Peg,Lindeberg,111-11-1111"
Now if I do
customerdata=myString.split(",")
shouldn't it give me customerdata as an array of length 3 with customerdata[0]=Peg,customerdata[1]=Lindberg and customerdata[2]=111-11-1111
What am I doing wrong? I could not find much example anywhere on split. Any help would be appreciated.
How Do I Pass Variables Into String Object?
Hi,
Im trying to count the number of characters in a string using the string object. I can do this OK when I count the number of chars in a form field but I need to count the number of chars in a variable. Someone told me to use the code "+test+" below to count the variable named 'test', but all this does is return "6". This seems to be just counting the string +test+ (i.e. 6 chars.) rather than a variable
on (release) {
test = "ThisShouldDisplay19";
result = "+test+".length;
}
Can anyone help?
Cheers...John
How Do I Convert A (String + Variable)'s Value To An Object?
I hope I can explain this correctly.
How do I convert a (String + variable)'s value to an object?
This is an abstract of the code below:
Code:
createTextField(String("tf"+i),i,"tf"+j._x + "tf"+j._width,0,50,17);
I have tried String(); so that I can convert the value to an object but I don't think String is correct here. I have also tried Boolean(); but to no avail.
Can anyone please help me with this. Your help is graetly appreciated. Thank you.
Code:
for (i=1;i<3;i++) {
if (i==1) {
createTextField("tf1",1,391,0,50,17);
tf1.autoSize = "left";
tf1.selectable=false;
tf1.text = t1;
tf1.setTextFormat(myformat);
} else {
j=i-1;
createTextField(String("tf"+i),i,"tf"+j._x + "tf"+j._width,0,50,17);
this["tf"+i].autoSize = "left";
this["tf"+i].selectable=false;
this["tf"+i].text = this["t"+i];
this["tf"+i].setTextFormat(myformat);
//trace(tf+i._x);
//trace(this["tf"+j]._x + this["tf"+j]._width);
}
}
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
Reference XML Object From Value Saved As String
I'm trying to access an XMLList object from an href in a textField.
For instance, I have an object: plogXML.day[0].file[0].@url. I want to be able to reference that object when the user clicks on a hypertext link in a text field.
For instance, <a href="event: plogXML.day[0].file[0].@url">Text to click</a>.
Clicking on the link calls the event handler, but how do I access the corresponding XMLList object from a string value. I can do trace(this["plogXML"]) but not further down the food chain than that.
As always, any help, yada, yada,
Jennifer
String Literal To Object Reference
Hi,
I have the name of a clip in a string variable, "current". I want to move the clip using that name to currentx, currenty. The name is the full name of the object, eg current == "_level0.myClip". How do I move it? This doesn't work:
[current]._x = currentx;
Thanks.
spin
|