Actionscript 3.0 :: Changing A String Into A Variable Name?

Jul 9, 2010

To avoid a large segment of code I've set up button names that correspond with movieclips that are located in my library and exported for use with the code. I want to replace the movieclip currently on stage with another movieclip from the library depending on which button you click on. The code works fine, I'm achieving all the values I want, except for the fact that since the variables in the function are strings it gives me a coercion error saying that they're strings and not objects.

Here's the code:
Code: Select all// Holder
var holder:MovieClip = new MovieClip();
holder.x = 122;

[Code].....

View 4 Replies


Similar Posts:


ActionScript 2.0 :: Changing A String Variable To A Number?

Sep 24, 2009

I want to add some input fields together and can't seem to do it..

test_btn.onRelease=function(){
total = Number(input1) + Number(input2);
}

In the total field I get 'NaN'

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

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

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 :: Changing An Object Name To A String

Apr 26, 2004

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?

View 8 Replies

ActionScript 2.0 :: Changing An Object Name To A String?

Apr 26, 2004

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?

View 6 Replies

ActionScript 2.0 :: Changing Specific Character Color Within String?

Sep 7, 2009

Any way to change the specific character's colour within a string in a dynamic textfield. E.g.
String = "There can be only one"
I want all the o's to be orange...

View 1 Replies

ActionScript 3.0 :: Changing Variable In Other Mc

May 3, 2010

I have a movieclip called 'Sitecontent'. Within this movieclip I'm using a variable to determine on which page my website is. The pages are seperate movieclips which I load throug addchild.When I load (for example) page 1, it start playing a openingAnimation which stops at a specific frame. After it stopped, I want to update my variable in the SiteContent mc. How to acces the variable from a other movieclip?

View 4 Replies

Variable Changing But Then Resetting

May 25, 2011

I'm very new to Flash, but I have been learning loads and getting some good results so far. Browsing these forums has been a massive help. However today I have hit a problem in what should be almost the simplest line of code I know how to write (variable = x), and could do with some advice. I have a simple program containing a button which will change a variable when pressed. There is also a text-box that will output that variable. However when I press the button, the variable will change, but then immediately revert to it's previous value.

[Code]...

View 3 Replies

ActionScript 2.0 :: Changing Of A Value Through A Variable?

Jun 16, 2010

I have used setProperty up till now, and it have met my needs needs so far.However, this one thing it cannot help with:

I have several different textfields all within different movieclips. I want to only change the content of only one of these textfields, however which textfield is changing all the time. Therefore the path of the textfield that needs changing has been put into a variable. Now I need to change the text of this textfield by using the variable(tempRevis1). i placed the path of the textfield within a variable:

_root.tempRevis1 = "_root.level1a_mc.AIRB237_mc.textMe1_txt";

Now this is what I hoped to have done:

setProperty(_root.tempRevis1, text, newTextValue);

View 0 Replies

ActionScript 2.0 :: Changing Value Of Variable In Mc From Another Swf?

Mar 29, 2004

I have one swf file that containes a mc using an easing function to move an arrow around.That mc has the instance named myruler. The arrow moves based on the value of a variable named "y". This swf also has a mc that I use as a container to load movies into.The movies that are loaded into the container mc have buttons that I would like to use to change the value of the variable "y" in the movie clip named myruler found in my base swf. Did that make sense? The code I'm trying to use on those buttons goes as follows:

on(release){
_root.myruler.y = 300;
}

The my ruler movie is in the swf that loads the swf with these buttons. So how do I point to that original swf.myruler.y?

View 2 Replies

ActionScript 2.0 :: Changing The Value Of My Variable?

Apr 29, 2003

I�m having some trouble with changing the value of my variable.I declare my variable in the first frame of the _root timeline.

currentSlide = 1;

When the _root movie plays it stops on a movie clip that contains four sub movie clips each is labelled sequentially( slide1, slide2, slide3 and slide4).I would like to know how to increase the value of my variable by 1 each time it progresses to the next slide. I can�t seem to get the variable currentSlide to change its value.

View 1 Replies

Changing The Value Of A Variable By Pressing Keys?

Jun 18, 2010

There is probably a better way to do what I'm trying to do, but I simply want to make a variable change its value when I press the arrows keys. For example if I wanted to cycle through weapons, if weapon=0 then the character is holding a certain weapon, then I press the down arrow key and weapon=1 and if weapon=1 the character is holding another weapon. And if I press up weapon=0 again so he's holding the first weapon again. And say there's 8 weapons, if weapon>8 then weapon=0 again so its a cycle. I tried arrow key functions and all they worked for was making a symbol move. I think I knew how to do this stuff in gamemker pretty well but Flash is very different.

View 2 Replies

ActionScript 2.0 :: Can't Add With A Constantly Changing Variable

Jul 10, 2010

I am making a game in flash, that uses several resources to build different buildings, that help you to gain resources, etc. I'm trying to make it so that the more "_global.food" you have, the faster your resources will go up. I have it so that the variable "_global.woodBoostMeter" goes up as fast as "_global.woodBoostSpeed" and when it reaches 500, it gives you 1 wood. I want it so that "_global.woodBoostSpeed" is modified by "_global.food" divided by whatever 200 is. (So that you will get resources faster for the more food you have)

Here's the code I'm using:

Quote:

_global.woodBoostMeter =0
_global.woodBoostSpeed = _global.food / 200
_global.woodBoostObtainRate =1

[Code]....

I think the problem seems to be with the "_global.woodBoostSpeed = _global.food / 200". it doesnt go up slow like it should, since "_global.food" starts out at like 200.

View 3 Replies

ActionScript 3.0 :: Swf In IE 7 Not Changing Value When Variable Value In Flashvar Changes

Sep 3, 2010

Below is decription of the file

1. I have a flash file which is loading php variable through flash vars.
2. The flash var variable contains the .txt filename in which data is kept.
3. When I open the php page the swf loads with variable having .txt filename and value containing swf path.
4. I have created timer in flash which check for change of value.
5. When value changes the other flash file loads.
6. All this works fine in all browsers except IE 7

View 1 Replies

ActionScript 2.0 :: Flash Changing A Php Variable?

Feb 16, 2009

im making a achievements page and i want flash to change a variable to 1 how do i do it

View 9 Replies

ActionScript 3.0 :: Collision - Why Variable Not Changing

Jun 21, 2011

I'm working on code for collision. My question isn't about how to make it work. I have a bizarre problem with a variable that is NOT changing when I want it to.

ActionScript Code:
public function movement(e:KeyboardEvent){
var yesobject:Number = 0;
var thecode:Number = e.keyCode;
if(thecode == Keyboard.LEFT){
[Code] .....

I've had this problem before. the trace(); commands outputs so why does the variable not change even though it's in the same if statement?

View 1 Replies

ActionScript 2.0 :: Changing Scene With Variable?

Jan 11, 2012

trying to make my first game using flash. I have done the main thing, setup a character which can be moved by the user to catch some falling balls. Every time a ball is caught, the score goes up by 1. To count and display the score, i have used a number variable called "caught" defined in the main timeline with initial value 0. The main timeline has only 1 frame and stopped by codes in the level "action". The "caught" variable is used in many movieclips in the scene and its value changes as the character catches the ball.

Now when the score is 10, i want to go to a new scene that shows a "congratulation you win" animation. For this, I have wrote the following code in the movieclip of the main character -

onClipEvent (enterFrame) {
if (_root.caught == 10) {
gotoAndPlay ("Scene 2",1);
}
}

But this does not work. The score goes upto 10 and then beyond 10.Is there anyway I can use the value of a number variable to determine when to play a particular scene?

View 4 Replies

ActionScript 2.0 :: Changing A Variable After A Certain Time?

Jun 5, 2006

I would like to have a button that when clicked changes a variable for 30 seconds and then changes it back. For example:

[Code]...

View 1 Replies

ActionScript 2.0 :: 'For' Loop Not Changing ._y Variable?

Jul 7, 2004

I have the following code:

PHP Code:

on (release) {
cNum = cNum+1;
for (b=1; b<8; b++) {
trace(["box"+b]);
["btn"+b]._y = ["btn"+b]._y+25;

[code]....

on release, the objects labeled btn1, txt1, box1, btn2..... should all be shifting 25pxs. It doesnt do anything.

View 5 Replies

ActionScript 3.0 :: Accessing / Changing Variable Across Frames

Sep 8, 2009

Its a simple adding "game" where 2 numbers are randomly generated and you have to input what you think the answer is (userAnswer). Then it adds the two numbers it just generated to produce correctAnswer, and checks it against userAnswer. When you hit the check answer button, it moves the the score dialog frame and says whether its correct or not. But I am having 2 problems I think - 1 - I can't get the input textfield to assign the typed-in value to userAnswer (I'm trying userAnswer = inputAnswer.text; )  and - 2 - the second frame that has the score and "Correct!" / "Incorrect!" dialog can't seem to access any variables from the first frame. I've tried using two layers and keeping the variables on the second layer that spans both frames, but then the functions in the frames that you actually see can't change the variable to update it with the user's input.

View 3 Replies

ActionScript 1/2 :: Changing The Value Of A Variable In Movieclip From Scene?

Nov 13, 2009

i have a probleme changing the value of a variable in movieclip from my scene. i explain: I have combobox on my scene containing categories,and in the scene i load an xml file containing links to php files that work with the combobox.Also on the scene i have a movieclip "filmstrip", inside this movieclip on the first frame i have a script loading the php file selected in the scene. i use a load() function with a variable "theUrl" inside like this : T.load(theUrl);.In my scene i want to change the value of "theUrl" inside the movieClip filmstrip. I tried filmstrip.theUrl = url; But it doesnt work
 
the xml file
<?xml version="1.0" encoding="ISO-8859-1"?>
<slideshow>[code]....

View 7 Replies

ActionScript 2.0 :: Retrieve A Value From A Variable Who's Name Is Dynamically Changing?

Feb 13, 2009

I have a problem with setting dynamic variables. How do I retrieve a value from a variable who's name is dynamically changing?

Example:

variable1 = 1,
set variable2 = variableList(variable1);

so...

if variable1 = 5,
then variable2 = variableList5

How do I do that?

View 0 Replies







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