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


Similar Posts:


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

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

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 3.0 :: Calling Object With String?

Feb 15, 2011

my library is filled with a movie clip for each letter in the alphabet (26 movie clips). I also have a blank symbol on the stage. When the movie starts, it generates a random 8 letter string from an array of letters. The next part is supposed to take the first letter of the newly generated string, pull the corresponding movie clip from the library, and display it in the blank symbol on the stage. After that, it moves to the 2nd letter, and so on. Ultimately I'm trying to have 8 random letters from the alphabet array set the corresponding movie clips on the stage.

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

ActionScript 3.0 :: Assigning String To Movieclip Name Then Calling It?

Dec 1, 2010

So I'm having trouble calling my movieclips that I created and assigned strings to their names.So I'm trying to create 3 movieclips with 3 different instances and add them to the stage.here's the code:

for(var i:int = 3; i > 0; i--){
var myMC:MovieClip = new MovieClip();
var myMCName:String = "MCName"+String(i);

[code].....

View 3 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

ActionScript 3.0 :: Converting String To Function And Then Storing, Not Calling Until Later?

Feb 23, 2011

I'm parsing out a greensock easing function as a string from an XML (as in "Strong.easeOut"), but then I need to store that in a variable as a Function type to call later. how is this done?

everything else i've found has been how to call a function from a string, as in this["functionName"](). i don't even know if using "this" is the correct scope for a static function in another class?

View 9 Replies

Actionscript 3 :: Dynamic - Loading/Calling Sounds From String Array?

Mar 7, 2010

i'm attempting to instantiate a bunch of sounds by creating a string array containing each sound's filepath (or name).

var soundByName:Object = {};
var channelByName:Object = {};
var soundName:String;

[code]....

View 1 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

ActionScript 2.0 :: Calling A Variable From Php To Second Swf?

May 29, 2011

The website is build from a main swf file. "main.swf" which is basically the backround with menu and the first thing that opens in index.html. Then there is a second flash. called login.swf which is loaded onto the main flash.The second flash is loaded using next code:

Code:
cont._lockroot = true;
cont.loadMovie("login.swf");

[code].....

View 5 Replies

ActionScript 3.0 :: Calling New Several Times On A Variable?

May 2, 2009

What happens if I have a previously allocated variable (new), then I set such variable to null in order to mark it for GC but then a few seconds later I call new again on it (not knowing if it has been GCed), and the GC still has not cleaned the memory address containing the variable.Would the first (new) allocation be garbage collected

View 5 Replies

ActionScript 3.0 :: Calling Variable In One Function From Another

Dec 6, 2011

I have a function that has a For Loop inside it. Inside that For Loop I am defining a button and calling to another function if clicked. The issue is (since I shouldn't put functions inside other functions) how do I get the variable being processed in the For Loop to be considered in the function that was just activated by pressing the button.

Here's the code. All variable are defined elsewhere in the code.
function populateBox(DataInput:XML) {
linkAmount = DataInput.country[boxPartNum - 1].link.length();
/// defines amount of links being made
for (k=0; k<linkAmount; k++) {
myLink = new LinkClass();
[Code] .....
I need to trace the "K" used in the For Loop.

View 3 Replies

ActionScript 1/2 :: Calling A Variable In An Instance Name?

Mar 16, 2012

Basically I'm creating a question with 4 answers (i.e. a,b,c,d).I have my question working fine, but I'm having a problem adding a check mark beside the answers once the user clicks the submit button.I've created four instances of my check mark; rightAns1_mc, rightAns2_mc, rightAns3_mc, rightAns4_mc.  I've set them all to _invisible = false; I've also set up a variable; nCheck:Number = 0; and when the user clicks one the radial buttons I have the variable change (i.e. if they click A, it set to nCheck = 1; if they click B, it sets to nCheck = 2; etc)So in my if statement for the submit button I figured I could have rightAns(nCheck)_mc._visible = true;

View 1 Replies

ActionScript 2.0 :: Calling A Dynamic Variable?

Sep 14, 2011

i have the following script, i'm just doing tests over failed attempts, I have a "cnc+i" dynamic variable, wich is a BitmapData type, i'm sure it's declared since the trace function returns true at the output, what i have a problem with, is at the moment of attaching the Bitmap, i don't know how to call it, and i don't want to do it manually like this: cnc1. Since i am planing on putting the attachBitmap inside a for loop:

ActionScript Code:
import flash.display.BitmapData;
this.createEmptyMovieClip("CNC",this.getNextHighestDepth());
CNC._x=50;

[Code].....

View 1 Replies

ActionScript 3.0 :: Calling Two Tweens Using Same Variable?

Dec 20, 2009

A very simple question. Can two tween events be called one after the other using the same variable name? (so that they occur simultaneously, no callbacks or anything like that).

Code:
var outTween:Tween;
outTween = new Tween(big_play_btn,"alpha",None.easeNone,1,0,1,true);

[code]....

View 6 Replies

ActionScript 3.0 :: Calling A Variable (tween) From Another Frame?

Jul 29, 2009

This is my first time working with flash and actionscript. when my project increased in size, it became frustrating to look through 2 or 3 hundred lines of code to find my mistakes. I decided to code in frames, so that one animation or movieclip could be handled by each frame, making it easy to edit each individually. So far so good, but i am trying to reuse a tween from an earlier frame, and it doesn't seem to work. I was under the impression that if you define a variable in a previous frame, you can use it in a later frame.

here's what it looks like

(frame 5)
var closeMenu:Tween = new Tween(mainMenu_mc, "x", Strong.easeOut, 238, 900, 3, true);

there is a frame in between that does: gotoAndStop(20);I want the animation to start right when it gets to frame 20:

(frame 20)
closeMenu.start();
TypeError: Error #1009: Cannot access a property or method of a null object reference.

I can copy and paste the original var and change the name from closeMenu to, say, closeMenu2 and it will work fine, but I feel like what I did should work.

View 0 Replies

ActionScript 2.0 :: Dynamically Changing Variable Calling?

Jan 27, 2011

Beginner question here. Basically I have the following code:

if (_root.obj1 == 1) {
n = _root.invArray.length;
_root.obje1._y = _root.inve(n)._y;

[code].....

View 1 Replies

ActionScript 2.0 :: Basics Of Calling A Function With A Variable?

May 27, 2011

I'm trying to get to grips with having a function that can accept an input that is passed to it as it is called, and then use that input in its workings.As I'm writing more code, it's becoming clear that this is something that I need to pick up, but despite reading and playing about with it, I'm still a little confused.The code is designed for a character's "level up" screen. When the button next to a stat is pressed, I want it to pass the name of that stat to the statUp function, which will increase the selected stat by one.In my main file I have this code, to call the function when the button is pressed. (In this example, it is the Strength button)

ActionScript Code:
_root.buttonStr.onPress = function()
{

[code]........

View 6 Replies

ActionScript 2.0 :: Calling A Function Based On Variable's Value?

Feb 16, 2005

say I want to declare a global variable in my main movie on a mouse event (button) and give it a value "functionA".

then I want to load an external .swf into a clip (with the same mouse event)

then I want some code in the loaded .swf to execute a function of the same name "functionA"

how would I code this?

this way I could load the same .swf but execute different functions depending on which button triggered the load... comprende?

View 5 Replies

ActionScript 3.0 :: Calling A Variable From Inside A Movieclip In Flash CS4?

Nov 14, 2011

I am trying to trace a variable string from inside a movieclip which is inside another movieclip on the main timeline using:

[Code]...

View 6 Replies

ActionScript 2.0 :: Photo Gallery - Calling Variable From XML File

Apr 8, 2006

I have a photo gallery for a painter rotating through images via XML. She wants a little sold sign to appear on ones that have been sold. I'd like to figure out a way to make it appear/disappear with a _visible = true/false statement that I can call from via the XML file.

Something like:
<node>
<img>"img.jpg"</img>
<sold>true</sold>
</node><node>
<img>"img2.jpg"</img>
<sold>false</sold>
</node>

Is this possible? I know that may not be a correct syntax, I can't get it to work.

View 3 Replies

ActionScript 2.0 :: Pass A Variable To Function When Calling It With Interval?

Jan 30, 2009

How do I pass a variable to function when calling it with interval.

This:

Code:
doFlip(1);
to something like this:

Code:
myInterval = setInterval(doFlip(1),2000);

View 2 Replies

ActionScript 3.0 :: Calling Subclass Method Through Variable Typed To Superclass

Nov 26, 2008

It's early days in my AS3 learning, and I'm looking for a little clarification regarding a variable typed to a superclass (in this case var mySpinner:MovieClip) which contains a reference to an new instance of a subclass (in this case Spinner.) I am trying to get my head around why my code compiles and runs and I am able to call the method rotater() on mySpinner even though mySpinner is typed as MovieClip, and the MovieClip class does not contain the method rotater().

On page 163 of the official Adobe Programming ActionScript 3.0 documentation it says the following, which I believe is related to my situation, but I am still in need of clarification:
"Because each class defines a data type, the use of inheritance creates a special relationship between a base class and a class that extends it. A subclass is guaranteed to possess all the properties of its base class, which means that an instance of a subclass can always be substituted for an instance of the base class."

View 2 Replies

ActionScript 3.0 :: Flash - Calling Variable From Scene To Movie Clip?

Dec 9, 2011

tes is a movie clip.when i click zkanada button. movie clip will appear and play from frame 1.

Code:
//scene 1
var detail_temp:String=null;

[code].....

View 1 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







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