Flex :: Get String Of Variable Name In ActionScript?

Jan 26, 2011

Does anyone know some ActionScript api to get String of a variable name like following:

var foo:int;
var variableName:String = getName(foo);
trace(variableName);

The console need to show "foo" as the result of trace(variableName);

View 2 Replies


Similar Posts:


String :: Flex - Download A String Variable As A File To The Local Machine?

Sep 21, 2011

I have a String variable in my flex (flash builder 4) application containing CSV data. I need to allow the user to download this data to a local file. For example, giving them a "csv" button to click and it might present them with a save file dialog (and I would be sending the contents of my string variable).Is this possible / how ?I am using the ResuableFX component for the datagrid to csv. This the code I ended up with that works to save the string to a text file for the user (in a web browser):

var dg2CSV:DataGrid2CSV = new DataGrid2CSV();
dg2CSV.includeHeader=true;
dg2CSV.target=adgEncounters;

[code]......

View 1 Replies

Xml :: Flex - Access The Value Of An Attribute Using A String Variable?

Aug 1, 2011

Using 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?

View 1 Replies

Flex - Embed Image With A String Variable Which Contains A Filename?

Jun 26, 2010

I try to embed images in a mx:tree:

<mx:Tree labelField="name" id="tree"
folderOpenIcon="@Embed(source='assets/images/test.png')"
folderClosedIcon="@Embed(source='assets/images/test.png')"
defaultLeafIcon="@Embed(source='assets/images/test.png')">
</mx:Tree>

This works fine, but I will embed the images with a String variable.

[Code]...

View 3 Replies

Flex :: Get A Substring From String Variable Which Is Having HTML Tags?

Mar 4, 2011

I have a string variable assigned with some Content in HTML format.[code]...

But in the output i am getting as This is <b. Basically it considering HTML related tags also as text. But my code has to omit the HTML tags while calculating sub string.

View 2 Replies

Flex :: Set Name Property Of Spark State Declaratively To A String Variable Value?

May 20, 2011

I have spark States declared in mxml. I also have a class with string constants. I want my states names to match the string constants. Is it possible to do that directly in mxml and how? [code]...

View 1 Replies

ActionScript 2.0 :: Create A String Variable...and Then Use The Value Of That Variable To Declare Another Variable?

Jan 3, 2006

f you know PHP...then you know that you can create a string variable...and then use the value of that variable to declare another variable. like this:

PHP Code:

<?php$foo = "haha";$i{$foo} = "success";print $i{haha};?>

and it would display "success"...or like this:

PHP Code:

<?php$foo = "haha";$$foo = "success";print $haha;?>

and it would also display "success".

View 6 Replies

ActionScript 2.0 :: String Variables - Consentrate A String To Call That Variable?

Mar 16, 2002

If i have an ASP page that is returning variables (and I can see them in the debugger) how do i consentrate a string to call that variable?

ie:
variables being returned are named:
"res1", "res2", "res3"...etc
for (var i = 0; i < 10; i++) {

[Code]...

View 4 Replies

Regex :: Replace Portion Of String With A Variable String?

Feb 10, 2012

Trying to replace a portion of a string with a "-" if it matches a string variable in AS3.

var re:RegExp = new RegExp(imageArray[j][1],"gi"); trace(imageArray[jTemp][2].replace(re,"-"));

imageArray[jTemp][2] is a string imageArray[j][1] is a string as well I'm not getting the result I expect. I would like trace above to return 'permanentContainer-' Here are the traces for the above variables

permanentContainer-temporaryContainer- temporaryContainer

View 2 Replies

Actionscript 2 :: Function's Local Variable Through A Concatenated Variable String?

Mar 7, 2012

how you would target a function's local variable through a concatenated variable string.For example:

var txt = "Hello World";
function testing(msg) {
var test1 = msg;[code].........

I'd expect the trace to be "Hello World" but rather is given "undefined". So if variables created outside functions are created on the main timeline, where are local function variables created and how would you access them?

View 2 Replies

As3.0 :: Append A String To A Variable So Flash Reads It As A Variable?

Sep 27, 2010

i'm getting a value from a class that gives me e.g "icon1" as data. i want to use this within a function to control the visibility of an item nested in a movieclip on the stage. the nested movie has the same name as the data being sent.

// here's what i want it to do:
mymenu.icon1.visible = true;
// but i cant append the 2 together as flash will see it as a string not read it as path.

[Code]....

View 1 Replies

ActionScript 3.0 :: Change String Variable To A MovieClip Variable?

Oct 10, 2008

I have been banging my head against a brick wall regarding the following problem which must be very simple to fix, just can't see the answer.I have a class assigned to a movieclip called canvas. The class is called drawClass. I have called the instance of canvas on the stage 'drawingCanvas'.When I trace "drawingCanvas" I get object drawClass] which is fine. Tracing drawingCanvas.name gets me the instance name 'drawingCanvas'.This is a String variable.Basically what I am trying to do is pass the MovieClip name to another class. In my example the class 'toolBar', which can then interact with the MovieClip.

The problem is passing 'drawingCanvas.name' results in a String, so I get an error saying :TypeError: Error #1034: Type Coercion failed: cannot convert "canvasArea" to flash.display.MovieClip.I can't for love or money find a way to convert a String variable to a MovieClip variable! I have the name of the MovieClip, I just need to tell the toolbar class. But I can't find a way of doing this as the instance on stage is an object of drawingClass, not a MovieClip (unless MovieClips with attached classes are not treated as standard MovieClips?).

View 9 Replies

Flex :: Access To Object Property When The Propety To Access To It's In A String Variable?

Oct 20, 2010

It'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?

View 2 Replies

ActionScript 3.0 :: String Variable In Place Of Int Variable?

Jan 2, 2012

This is sort of difficult to explain but I'll do my best. I've got 6 score variables that go up over time.

[Code]...

Each corresponds to a different color of "Monster" class I reated. "GreenMonster", "BlueMonster", etc. are all custom classes. Each class has a string property called "MonsterColor". So "Blue1.MonsterColor = "Blue".

To save lines of code, and learn, I'm trying to use a local string variable to take the place of whichever of these 6 int variables I need. So inside a for loop, I've created a variable called "colorscore".

[Code]...

View 5 Replies

ActionScript 2.0 :: Use A String Variable To Instantiate A Variable

Jun 11, 2002

I would like to dinamically create array variables, depending on a XML file. The problem I have is that I don't know how to create them dinamically using a name I have constructed into a string variable. What I would like is something like this:

var strVarName;
...
strVarName = "Var" + i;
var strVarName = new Array();
...

So I would have n arrays called Var1, Var2, ... Varn.

View 1 Replies

String :: Flex - Embedded String Resource Encoding?

Apr 13, 2004

I embed a text file into my Flex project and read its contents using code like this:

[Embed(source = "../../data/abc.txt", mimeType = "application/octet-stream")]
private var r_Abc:Class;
var xx:ByteArray = new r_Abc();

[code].....

View 9 Replies

ActionScript 2.0 :: Variable Name To String?

Sep 11, 2009

Is it possible to convert a given variable name to a string?

Code:
function vartostring(mystring:String) {
//something like var newstring:String = parsevarname(mystring)

[code].....

View 3 Replies

String Variable With GotoAndPlay?

Apr 8, 2009

I am trying to go about a "smarter" way of setting up multi paged full flash sites. This has got to be something very simple that i can't seem to put my finger on.

I'm trying to create a variable called 'currentScen' that i can declare off the start and change depending on what page the viewer goes to in the site.

I could put a bunch of 'if' statements saying that 'if the current page is this page then do this, if it's this page do this' etc. for each individual page but i thought there must be an easier way.

I am trying to get the following to work:

Code:

// declaring what the starting page is
var currentScen:String = "welcomeMovie";
//function fading in called page with animation used on the 'over' frame label
function animateOn(page:String) {

[Code].....

View 1 Replies

ActionScript 3 :: How To Get Name Of Variable In String

Sep 23, 2010

Example:
public var myVar:Object;
// now I want to get the myVar string
// myVar is not instanced*
public var whatINeedIsThisVar:String = 'myVar';

View 1 Replies

ActionScript 3.0 :: Act On Change In String Variable

Apr 7, 2009

What is the best way to listen for and trigger a function when a string stored in a variable changes? I have a variable named source which is a string. When its value changes I need to run a function newVideo. What's the most efficient way to detect the string has changed?

View 3 Replies

ActionScript 3.0 :: Compare String To A Variable Name?

Sep 9, 2009

Compare a string to a variable name. Is there anyway you can do that?[code]...

View 1 Replies

ActionScript 2.0 :: CS3 Variable String / Boolean

Nov 9, 2009

having an issue with a variable set. It is set as a string to default "no" on the very first frame of my movie, as follows:

var myaccess:String;
myaccess="no";

Within my movie, there is an object. When this object is pressed, it is to change the _root.myaccess="yes"; I am tracing the variable within the movie clip and it shows me: I do not understand why it is changing my string definitition from "no" to false. Because of this, my variable does not seem to change to "yes' on object (button) pressed.

View 1 Replies

ActionScript 2.0 :: String Variable In If Statement

Jan 22, 2010

I have a movie clip on the main timeline that includes a button.When pressed, I want this button to conduct an if statement to check the contents of a textbox on the main timeline and if equal execute the statement.So far I have this but the text does not seem to 'read'. Do I need to pass the textbox contents into a string variable rather than read directly from what is in teh text?[code]

View 2 Replies

ActionScript 3.0 :: Converting A String In To A Variable

Jul 14, 2009

I have a string that stores an object's instance name: var instName:String = e.target.name; and now I need to use its information to do something like this: instName.alpha = 0.3; but since it is a string it causes this error: 1119: Access of possibly undefined property alpha through a reference with static type String.

View 1 Replies

ActionScript 3.0 :: Variable To String Mapping?

Oct 13, 2009

I'm new to flash and working to embed the flash player in a .NET application. It's going "well" for the definition of "well" that adding the COM control and getting it to play a movie was easy and took about 3 minutes.What's not going well is that I cannot find documentation on the variable to string mapping used the SetParameter variable parameter. To coordinate between the apps, I want to be able to say: "flashPlayer.SetVariable("flash_variable", "value_to_set"). Obviously SetVariable does this. What's not obvious is how "flash_variable" is constructed.
 
For example, in the actionscript for a button called "OneBigButton" I have the following code:
 
OneBigButton.addEventListener( MouseEvent.CLICK, onClick );var testSetValue = "value";function onClick(evt:MouseEvent):void {    trace("got the click " + testSetValue);    outputText.text = testSetValue;}
 
When I try this:
 
flashPlayer.SetVariable( "testSetValue", "foo" );
 
The results do not get set in testSetValue.
 
I'd love a pointer to the documentation on how namespaces, class instances, etc affect the string construction used in SetVariable and GetVariable as I can't find it anywhere.

View 3 Replies

IDE :: Pass A String To A Function And Use Its Value As The Variable Name?

Dec 21, 2009

Is there any way that you can pass a string to a function and use its value as the variable name you wish to change. For example.

Code:
var text:String = "Goodbye World";
function myfunction ( varToChange)
{
varToChange = "Hello World";
}
myfunction("text")

View 2 Replies

ActionScript 3.0 :: Cast A String Into A Variable?

Apr 5, 2011

i have a list of items that get returned from a database.  the list is composed of strings. what i need to do is convert each item into a variable so that i can use each item as an array.
 
for instance, my array will look something like this: deviceArray = ["osx106", "osx107", "winxp", "win7"];
 
what i want to do is turn each item into its own array.  in AS2 (iirc) we had an eval() method.  that is no longer supported in AS3.

View 2 Replies

ActionScript 3.0 :: Combine A Variable With A String?

Apr 15, 2011

Im trying to combine a string with varible so that on function can control a variaty of elements, depending on which varible is chosen. Here is my code:

[Code]...

View 1 Replies

Php :: Adding Outputted String To Variable?

Apr 15, 2012

im using PHP with MySQL to send information to my flash file using GETs.Using FlashVars i have managed to get the users 'id' with this i can send my questions/searches to a PHP script which access the database and returns the information to the html page.What i would like to do now is add the information sent back to the html page to a variable inside flash for example:

var usr_name = get_user_name(id) || 'Unknown'; // "Unknown" should just be for offline use.

but this just returns 'Unknown' this is the function used:

public function get_user_name(usr_id){
loadData('search.php',"quest=name",'usr_id='+usr_id);
}[code]......

If i just type the URL into a web browser i get the name outputed.

View 2 Replies

Actionscript 3 :: Calling A Variable Given Its String Name

Nov 29, 2011

var myvar = "this is the value of myvar";
var notMyvar = "this is some other variable";
var thirdVar = "this is some third var";
var nameOfVarToCall = "myvar";
//print the content of the var name specified, in this case "myvar"

I have a string which contains the name of a variable I need. What I want to do is find out the name of var (in this case "myvar") and use the name to access the value of the var (in this case just print out the value). Is this feature available in Actionscript. I know it's available in PHP and can come in very handy.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved