ActionScript 3.0 :: Use A String To Access The Object?
Feb 28, 2012How can i use a string to access the object instanced as : beef : on the stage.
View 2 RepliesHow can i use a string to access the object instanced as : beef : on the stage.
View 2 RepliesIt's too complicate to explain but I'll give you an example
I have an AS3 ResultEvent Object and this object has several propeties which can be accessed by this like:event.result.name or event.result.age and, I have this String variable: eventProperty:String that contains "name" or "age" How do I access to event.result. with the variable?
I'm trying to create a quick access to a object with a String as it's key, so I wrote:
"var map:Object = {};
map["key1"] = object1;
map["key2"] = object2;
..."
Is there any difference about the performance between long key and short key(the length of the String used as a key)? If the key contains many charactors, will it slow down when accessing that object?
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 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 "URL..." and parse out that substring. For example the string could be "Please vist my site at URL...". I would want to parse out the URL...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?
View 2 RepliesI'm working with a web service and am returning an array to a field (that I set the data type as an Array). The result thus far is "[object Object]". How can I get the array values back out as a string?
View 0 RepliesAllright, i receive a string and want to convert it to object. here a test that i have made:
[code]....
this work pretty fine... but i am receiving the object property as follow: "{a:'test',b:'testAgain'}" How can i easily convert it to object properties?
I think i am lost with basics itself. What is the difference between these two. String object is an instance of String Class.
[Code]...
I am developing an application with Flex for the GUI and Restlet for the webservices. I have a strange problem. I put my XML as a property on a generic object, and send it as part of a POST request. But in the Restlet webservice, this XML is irretrievable. How do I retrieve it? I tried initialising the received Representation object to a DomRepresentation, but thats not working. If I put the received Representation object into a Form object, then getFirstValue is returning that XML as a string! I noticed that the contentType of the HTTPService was application/www-form-encoded so I set it to application/xml and its not helping either. I use restlet 2.0m6 and here is the code snippet that I use -
[Code]...
i am trying to access an object within a class and the object is comming up as null but i dont understand why.
this is the object:
btnLMain = new MovieClip(); //variable declared earlier in code
btnLMain.name = "btnLMain";
[Code].....
i am trying to access an object within a class and the object is comming up as null but i dont understand why.this is the object:
btnLMain = new MovieClip(); //variable declared earlier in code
btnLMain.name = "btnLMain";
btnLMain.clickNum = 0;
addChild(btnLMain);
this was created in the class: LanguageButton. here is how i declared the above class within the class i am trying to instantiate it:
var btnL:LanguageButton;
then i try to access the btnLMain from the LanguageButton Class and it, (btnLMain) is comming out null:
btnL = new LanguageButton(cssLoader);
main.addChild(btnL);
btnL.btnLMain.addEventListener(MouseEvent.CLICK, btnLClick);
In AS2, you used to be able to access an array using a string variable by putting it in [].[code]...
Is there a way to do this in AS3 without having to create pointers and references?
I am sending the instance name (i.e. String)of the MovieClip to a function.From that function I need to access that same instance of MovieClip using that name.I have a MovieClip Instance name Planet_mc. And I am sending it to function abc()
abc(Planet_mc.name);
function abc(s:String):void
{
I'm just wondering if it is possible to use a string values as a way to use the addEventlistener function.[code]...
View 5 Repliesfunction fn1(var2)
{
//here i want to trace the name of var1....ie output: "var1"
}
fn1(var1);
how to trace the variable name i am passing to fn1 (ie. var1) as string?
ie. output shoud be
"var1"
ie i want to trace the name of argument variable i am passing
Is it possible to access a certain digit in a string? For example, if i currently had a value '321' then if i clicked on a button for example it changed the 2nd digit in the string to say 5...making it '352'.
This is probably really easy to do but im not sure how to do it!
Is there a way to access a variable via a String? Something like this:
HTML Code:
var myVar1:Int = 1
var myVar2:Int = "myVar1" as variable name
This is obviously doesn't work (and in this case pointless), but is there a way to do this?
In as2 it was very easy to access query string just using _root, but this doesn't seem to work on as3.[code]How do i access value of a? I tried it with _root as well as in flash client tried this userNameTextField.text=root.loaderInfo.parameters.a;But both doesn't seem to work. What can be the problem?
View 3 RepliesUsing e4x in flex:
var attr : String = "foo";
var xml : XML =
<resultSet>
<node foo="1"/>
</resultSet>;
How can I use the variable "attr" to access
xml.node.@foo
I thought I could do it with
xml.node.@[attr]
But this doesn't seem to work. How can I access this attribute by a dynamic value like this?
Both
xml.node.@[attr];
and
xml.node.attribute(attr);
work, as Constantiner suggested.
Updates:
Say I have an XMLList in this form:
var bar:XML =
<resultSet>
<node>value</node>
</resultSet>;
I want to filter the original xml above by matching "foo" attributes with the "value" from node in bar.
Essentially I want a sublist of the original xml such that
xml.node.@foo == bar.value
for each xml row in the original value
As Constantiner mentioned, I can filter the original list by the value in foo, but what if I want to filter on multiple values?
Can I do something like:
xml.node.(bar.node.contains(attribute(foo)) ? attribute(foo) : null);
Or perhaps a cleaner method instead of the null?
Suppose There is one [url]...
I want to access the id="123" from the above URL.
Is there any way of doing it?
my goal is to keep my output window organized so i can follow all my traces more easily. so i wrote a couple of custom functions to achieve that. one of them would be: to more easily trace the following variable for example
[Code]....
I have a Main class that has a public var "foo" which is a string. my subClass is a movi clip that has a text field called txt. I want to access the document variable from the sub class but get error 1119: Access of possibly undefined property foo through a reference with static type flash.displayisplayObjectContainer.[code]...
View 5 RepliesI have movie clip Ball what has public function glow[code]...
full access to Ball is MainMenu.ImagesPanel.Ball
I want to send command from server in text like:
string="MainMenu.ImagesPanel.Ball.glow"
How to convert sting to structure?
I was trying to make a menu for a game, (and I succeded, it works fine) when I noticed that if I store a clip name in a string var I can't I acess it's alpha with varName._alpha (?) or some other ways I tried.
Is there anything wrong in my code, or is there a way to do it that isn't the one I'm trying?
The way I'm doing it, I have a MovieClip for each screen, that in turn contains all the MovieClips and Buttons, etc, that each screen must contain. So sometimes I must specify the path to things with "_root.MovieClipName.thatThing._blah". Although I think this has nothing to do with my problem there, since the vars are all declared in the stage's timeline...
If you don't quite understand how the functions work, here's a call swapScreen function example: swapScreen("overlap", "OptionsScreen", "options");
If "swap", it removes the screen I'm in, and attaches another one in place. If "overlap" it overlaps the current screen with an overlaper screen (like opening the Options menu ingame). restoreScreen() restores to the previous screen that has been overlapped.
ActionScript Code:
function swapScreen(swapType:String, ID:String, screen:String):Void
{
if (swapType == "swap")
{
[Code].....
Now one of the functionality that's added to the player is the "Transcript Button", which shows subtitles in a small window.Well, what I've done is added text on keyFrames of the main timeline,so if the audio says "Hello good evening, welcome,....", I've made a new layer above the audio layer and during that particular part of audio I've added the text on the new layer in a keyFrame.I've done this for the entire timeline.I've used enterFrame and accessed this String value and displayed it in the small window.Everything seems to work well.But if a certain movieClip popup is added on the timeLine, which has its own audio.o necessarily I'll have to add the text to this movieClip as well, but I cant access the text, i.e, display it in the small window.Also I've tried using a global variable like this,...
.as file
package
{
[code]......
So I have two movie clips linked with classes- one with the class "theList" and one with the class "challengeBar". I need to use a function in challengeBar to access a function in the theList. They are both immediate children of the stage.so for now I have this (in the challengeBar class)-
public function populate(){
this.textBox1.text = myList.dequeue();
}
should it be something along the lines of root.myList.dequeue? or stage.myList.dequeue? How can I access that function?
I'm developing a compiler generator in actionscript 3 with flash builder 4. I need to find a way to:
1.- Execute code inside of a string.
it could be very complex code, not just trace() functions but complete code
2.- Another alternative can be to tell to the actionscript compiler to compile the code autogenerated from my compiler generator.
I want to add some custom string into the FMS log file. If I am playing a video and I want to append some string every time when that video is played, which is in some way useful to me in analyzing FMS log, then is there anything provided or some function in which we can just pass the string as an input argument that appends it at appropriate place in the log file.
View 3 RepliesI am fetching some variables from a URL and get the result. While I can iterate through it via e.g.:
[Code]...
I have problem with accessing object created by function imported from another package.
I have 2 packages DragDrop and UserInterface. In UserInterface I create methods for buttons and later add them in DragDrop . I make it in two different ways:
One(this one works):
[Code]....