ActionScript 3.0 :: Making A Variable Name With A String?

Jan 12, 2010

I've moved to actionscript 3.0 from PHP, and there are some things I just do not get. For example, making a variable name with another variable.Let's say I have movieclips called object1, object2, object3 and so on. I used Math.round() and Math.random() to get a random integer number, and I want to select one of my movieclips according to this number I get.
In php, you can do this:

PHP Code:
<?php
$objectNumber 1;//Let's say this is a random number

[code].....

View 8 Replies


Similar Posts:


ActionScript 3.0 :: Making A String Contain The Name Of Another Variable?

May 3, 2010

var myNumberArray:Array = new Array;
myNumberArray[1] = new Object;
myNumberArray[1].myProperty = 10;

[Code]....

This obviously traces out the string "myNumberArray[1].myProperty", completely disregarding that there's already a variable/property called myNumberArray[1].myProperty, which has a value of its own.

Tracing out this[myStringVariable] just gives an 'undefined'.

Is there any way to get it to trace "10", using only the 'myStringVariable'? In other words, to make AS understand that myStringVariable contains the name of another variable/property?

View 4 Replies

IDE :: Making A Global String Variable Visible To MovieClips?

Jun 4, 2009

I mostly use flash for the animation, so my action script tends to be mostly functional.

I am now however having an issue, i am using a variable called language which I am setting in frame one as "dutch", "english" , "german" etc... Im then using this to set dynamic text as appropriate in each frame as necessary.(and yes i may switch this to case statements )

if (language == "dutch")
{ tcMC.peasantBubble1.peasantSpeech.text= "Bescherm je een schat?"};

My problem is however that one Movieclip does not see the language variable.

Is there anway in CS4 i can direct it to where it is, or define the varibale instead to be global (perhaps id have to change it from a string though)?

View 2 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 3.0 :: Making A String Into A 64 Bit Bytearray?

Feb 23, 2012

ActionScript Code:
private var counter:Number = new Number( 0 );
private function sequence(seq:Array):ByteArray
{

[Code].....

Maybe im just too blind to see it. I have this string with 0's and 1's and im just trying to turn it directy into a bytearray. I'll optimise it later, im just getting really annoyed at the fact that this isn't working.. Edit: I even tried working with an array. The data is there it's just not being written into the bytearray properly.

View 2 Replies

ActionScript 2.0 :: Making A Game Like String Avoider?

Jan 5, 2010

[URL]I have made the string and its movement is also done the problem i am facing is is to fix the position of the mouse on enterframe. As, you can see in the game(link given above), the level starts when the mouse touches the start button in the game. How can i implement that?

View 3 Replies

ActionScript 2.0 :: Making Banner - Var From URL String Query

Jun 9, 2009

I'm working on making a banner that sends some informations to a Url
Like this
Code: Select allbmi.aspx?hojde=2&kon=male&alder=4&vaegt=45

The itself is working like a dream, but now I want it to be more userfriendly. I want the banner to check if ex. the var from the query string "hojde" exist if so then pt this value in the text field for "hojde". If it doesn't exist then set a standard value of 100. For now I've worked only on the "hojde" var, so that's where you should look

View 1 Replies

ActionScript 3.0 :: Sockets And Making A String Equal To Multiple Lined Text

Jun 24, 2010

I've been making something using sockets, and I've run into a problem. The outstanding data from the socket is loaded into a string, like so:

[Code]....

To check if a sentence started with PING, I wouldn't be able to, because it will only acknowledge the first line (even though I can append all of it to a text box fine). I also tried testing scenarios with strings containing multiple lines, but found that by making a string equal to multiple lined text, it produces this error:"1094: Syntax error: A string literal must be terminated before the line break.", and I checked, I didn't miss out any speech marks.

View 7 Replies

ActionScript 2.0 :: Making A Variable With X And Y Position?

Feb 12, 2009

I am working on a client who wants a "Game-like" tour of their facilities on their website. I can use flash and do some very basic actionscript ..especially cutting and pasting

At any rate, I have character that moves on the main tour map and he starts in the parking lot...he can go from one screen ( scene ) to another. But when the character returns to the main tour map he always starts at the same location. As opposed to starting where he just came from. Such as if he just went into the "Process Plant" he should start on the main map at the "Proccessing plant" ... Can I set the X Y coordinates in some type of variable that remembers where he came from when he exits another scene and returns to the main map...?

View 6 Replies

ActionScript 3.0 :: Variable Making Loop

Sep 7, 2010

[Code]...

so what i want it to do is making 10 varibles named Name1 - 10

View 9 Replies

ActionScript 2.0 :: [FMX] Making A Random Variable?

Dec 24, 2002

Making a random variable?

View 9 Replies

ActionScript 2.0 :: Making A Variable Available Outside A Function?

Feb 20, 2006

Basically I'm trying to load a variable from an external file and then make that variable available for anything.

Code:
var where;
locSource = new LoadVars ();
locSource.load("source.txt");[code]....

I've tried all the variations of this I can think of. I've defined "where" as a global variable both outside and inside the function, tried to define a separate global value within the function (and changed the syntax of the trace accordingly in either case), nothing works. Basically, the function is being loaded properly; if I put the trace inside the function it shows up perfectly, but the variable isn't available for anything else, which is what I need to happen.

View 4 Replies

ActionScript 2.0 :: Making Filename A Variable

Apr 21, 2006

it's possible to have AS take the filename of itself and make it a variable. I need it to be done by AS only. I know it's possible in PHP, but I'm not sure about AS. I'm guessing if it's possible it's one line of code. I'm using Flash 8 but publishing at Flash 6, AS 2.

View 2 Replies

ActionScript 3.0 :: Making One Variable Available To Multiple Classes?

Jan 15, 2011

I'd have thought this to be simple, but nothing works. I have a game I'm working on, and in it, there will be a speed stat. The fast you are going, the faster everything else has to move to make it look like you are moving faster.The problem is, the speed stat (obviously not called speed) is one of the upgradable stats, and needs to be available for the class handling upgrades for it to be changed, and it needs to be read by the class handling moving objects.The second class however, has absolutely no idea the variable even exists. I've tried for weeks to look up a tutorial on it, but there doesn't seem to be any at all that I can find. (I am using public variables, and have tried various ways of trying to point at the class it's from but apparently I must be using the wrong syntax)

View 12 Replies

Making Something Happen After A Variable Has Been On The Stage For A Certain Time?

Dec 13, 2011

I'm making an Elder Scrolls type game and I want my enemies to hurt me after a certain time.So pretend like 5 seconds after they come on the stage they would take 5 hp off me.Then when one of the enemies die it stops until another enemy comes on the stage then it counts how long its been on the stage.This is what I have so far:

Actionscript Code:
var tmr1:Timer=new Timer(2800); var tmr2:Timer=new Timer(5000);

[code]...

View 1 Replies

Professional :: Making And Loading Variable Classes

Feb 13, 2012

AS3 says you need to load variables into a class?my variables look like this... (the whole point of playing around with variables was that if I had to make a change I could access one place and change them but now I realse that I can't access or call them outside the movie clip they are in.[code] The Wholesale price. A wholesaler is usually a big shed where goods are stored.

View 7 Replies

ActionScript 3.0 :: Making A Universal Variable As A Counter?

Aug 19, 2009

I've got an animation that plays, and then at the end of the timeline plays a movieclip. This movieclip displays a piece of text, which is extracted from an XML file, the piece of text is selected at random currently out of a list.

Then when the clip is pressed (button), it goes back to the previous timeline, and then plays through again, including the movieclip, and now a new piece of text is picked at random and displayed.I now want to make the pieces of text display sequentially, but am having some trouble.

put in a counter, and the text that is displayed from the array corresponds with the number on the counter, unfortunately, this gets wiped every time it plays, because the counter gets remade. Is there any way to create a variable outside of the timeline maybe, in a actionscript file maybe, so that I can just add to this. I have been running a trace, and can't seem to get it to not wipe.

View 3 Replies

ActionScript 3.0 :: Making A Local Variable Global?

Sep 7, 2011

I have a problem where I make a variable in one class and change it using the constructor method in another.Is there anyway that I can make that variable available in all methods in this class? Here is the code:

[Code]...

View 3 Replies

ActionScript 2.0 :: Making A For-loop With Button Variable?

Jul 31, 2002

The situation is like this:I have Five buttons named button1 to Button5.What I want is to make one button invisible.To to this I have a for 1 to 5 -loop and I want to make one button invisible if it meets certain criteria.Is this possible without make an if-line for each button or not??

View 4 Replies

ActionScript 2.0 :: Making An Imported Variable ( From Php ) Into A Number

Nov 2, 2004

im importing a few variables with this [code]but now how do i make a variable say root.cash into a a number which can be used in equations or used for logical compariosons such as < > ==

View 2 Replies

ActionScript 2.0 :: Making A Imported Variable ( From Php ) Into A Number?

Nov 2, 2004

im importing a few variables with this

Code:
myVars = new LoadVars();
myVars.load("getinfo.php?user1="+userN+"&pass45="+passN+"&random="+refresh1,"0");

[code]......

View 2 Replies

ActionScript 2.0 :: Making Button Invisible Using Its Instance In Variable

May 1, 2006

I am just trying to make a button disappear using a variable set to it's instance name. When I say invisible I also mean deactivated. The code I've got is this..
Code:
[test]_visible = false;
but it doesn't work - any offers?

View 5 Replies







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