ActionScript 2.0 :: Concatenate - Make The Variable Change With The Variable?
Jul 19, 2006I'm trying to achieve something i thought would be extremely easy, but i can't get it to work!
[Code]...
I'm trying to achieve something i thought would be extremely easy, but i can't get it to work!
[Code]...
How do I concatenate variable names in AS3?Something like this:
for(var i:int=0 ; i<5 ; i++) {
var "myVar"+i:Array = new Array();
}
I'm starting out with AS3 and migrating some old code. I have several dynamic variables in AS2 but they are using _root which isnt available in AS3.How would I go about switching the following variable to AS3? I have at least a dozen different variables similar to this one.
Code:
for (i = 0; i < (k-1); i++) {
pivot = _root["AI"+i][i][i]; // existing AS2 code
[code]......
I'm trying to concatenate a name and variable number. Then trace it, so answer3 should output from my loaded xml data "water". Instead all I can get to trace is the word "answer3". If I type "answer3" in the trace I get the variable im looking for. If I type [this.getCorrectAnswerNumber()] in the trace I get number 3. How do I go about concatinating the word answer and a dynamic number.
Heres my code...
Code:
trace("answer"+[this.getCorrectAnswerNumber()]);
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?).
Is there any way to concatenate E4X expressions? If I store "half" a path in a variable, can I concatenate the way I do with Strings?
View 3 RepliesI would like to make a dynamic button on a website I am working on. I would like one button to update a variable, and another set of buttons to add 1 or subtract one from the variable I have buttons on the left side of the page for some bands that load conent into an empty movie clip.
The website: [URL]
I would like to set up some forward and backward arrows above that content on the right, so users can also scroll through the content in order. So if someone loads the content for soul asylum, and click the back arrow, it goes back to the Wailers, and if they click the forward arrow, it goes to Swollen Members. So there is an order of pages: 1. Wailers, 2. Soul Asylum, 3. Swollen Members, 4. Passafire, 5. Beats Antique, 6. SFM Kind of an order of importance. The idea is if somebody starts by clicking #3 Swollen Members, my application will know that it is on #3 and the arrows will go to #2 or #4.
Is there a way for the main artist buttons on the left to reset a variable for the current slide? So if someone clicks on the Swollen Members picture button, a variable called currentselection equals 3 And then when the forward arrow is clicked, it will ad 1 to the current selection and load movie #4
So in VB the main Swollen Members button would be something like: im currentselection as int = 3 Which would reset the current page as 3
Then the forward arrow would have code like:
Dim Nextselection as Int
Nextselection = & currentselection +1 & ".swf"
And the button in flash would be something like:
on (release) {
loadMovie("Nextselection", "rightcontent_MC")}
Which would load 4.swf the slide for passafire.
So how would I do this in action script 2.0?
The Idea is i want to make avariable that stores his value after i close the swf and open ti again,
an example:
i make acounter
var i:int = 0;
var timer:Timer = new Timer(1000);
timer.start();
[Code]....
the value of i will increase but after i close the application and open it again the value will return to 0 , keep the variable stores his value after closing the application ?
I'm creating a board game which has 3 variables, p1Move, p2Move and activePlayer.
p1Move and p2Move store the p1 and p2 location on a game board. activePlayer stored who's turn it is at the moment.
I am loading a value in from a text file which changes the value of move. This all works fine when i designate a player directly:
ActionScript Code:
p1Move = [insert variable name],
but i want to designate dynamically based on who's turn it is.
Something like this:
ActionScript Code:
_root["p"+activePlayer+"Move"] = Number(this.varAmount);
so that flash changes the value of p1Move (or p2Move depending on who's turn it is) to varAmount. varAmount is the variable being read from the textfile.
Hopefully that all makes sense. Basically i want flash to change the variable associated with the active player only.
I've searched around and wasn't able to find any solutions to my problem, which probably just means I'm going about this wrong way, but here it goes...I have a bunch of variables named like so:box0Wbox1Wbox2W
View 3 Repliesf 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".
i have a variable take away another variable which makes answer1 variable i then want answer1 to be to the power of another variable how can i do this in flash
View 5 RepliesIm really new to as3, and im just trying out some stuff, but i cant get a shape to refresh and change when i change its variable using a text field.If i change the text fields text before i test it, it works, but while its running it doesnt change it again.Btw, trying to change the stroke size.[code]i just want is so that when i change the strokeSize_txt text box, it will change the stroke for the shape.
View 2 RepliesCode:
var fruit1:String = "apples";
var fruit2:String = "oranges";
var fruit3:String = "grapes";[code]....
I need the variable fruit1, but for reasons I don't have time to get into, I don't know how to parse these two variables to make a parseable variable.
I have an flash movie with on the main timeline a movieclip "MC1". In this movieclip I have another movieclip "MC2". On the first frame of MC1 I have declared a variable x and I want to give this variable a new value when I click on MC2 but it doesn't work?!
Main timeline: 1 frame with MC1
MC1: 1 frame with MC2
Codes implemented on the timeline:
MC1:
x;
MC2:
onMouseDown = function() {
_root.x=1;
}
Example: [URL]
I am attempting to make a remoddled clone of the game at [url]...so far i have some blobs that slowly move down through a door, then when they're off the screen they jump back above the screen to come back down.my problem is that the door is user controlled using this code on a butten[code]...
View 1 RepliesI'm working on a game were your health variable will add 1 hp automatically every second if the health variable is not equal to 100. How would you do that?
View 1 Repliescan I set variable from QueryString . if yes , then HOW ?
for-Example :
FLASH:
var myvar:String;
I want to change the name of variable (which is already declared in Flash ) from querystring
like myvar+new
is that possible , I change variable name again from QueryString?
I have a variable set up on my actions frame. It is var bucket:Number=0 .I want bucket to equal one if one object hits another.
View 9 RepliesI 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? [code]...
View 2 RepliesWhat 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 RepliesI have a flash movie being loaded inside a parent movie. Inside the loaded movie is a variable called lvl, and its refered to as loadedmovie.lvl in the parent movie.
So if i'm wondering what the lvl is in the loaded movie, I just use loadedmovie.lvl to get the variable.
But I want to know when this variable CHANGES. How am I able to detect when this lvl variable changes? Inside the loaded movie, it's been set to change almost every frame in the movie, but I'm not going to call a function inside every frame of that movie to find out when it changes.
how do I detect a variable change and then make it call a function?
[code]....
need a way to change from tile0 to tile1 through variable [code]....
Can I detect a change to a variable (a data string)?
I am making a AS2 SWF (player level 7) with a combobox page navigation. I have a page name variable that I am changing from outside of the SWF with Director and Authorware using (I believe) FlashVars. The variable (internally) is set by default during SWF initialization. The external variables values allowed are always one of the combobox's data field values. The combobox default variable is not always index positon 0 (zero). Or the order of the data either. The variable can get changed internally by the nav combobox used for navigation independent of the external variable. - this works When the shared nav var is changed from the external source, the combobox needs to change to the match the corresponding combobox's data variable. This is what I am trying to do. I can change the combobox setting programatically (index) but not get it to recognize it as a change event. Or tell it programatically
Can the combobox be selected by the data variable or is the only option to use the index (and loop through index values to match variable to data field)?
And update the combobox selection (and as a result the nav page) by triggering a change event programatically?
Detecting the var change cleanly without the OnEnterFrame trick is my goal - if it even works in the version I have to use (flash palyer 7).
I need to change one variable at the click of a button the problem is that when I enter the first frame i declared a _global var _global.conteudo =null;
In the second frame:
this equal a _global to :
_global.conteudo = "enterprise.swf";
But when I click a button , i need change my _global var for example:
on (release){_global.conteudo="my variable declared";}
I am running an swf preview.swf, How can i change the value of flash variable mode using jquery ??
I have code something like
AC_FL_RunContent(
"src", "preview",
"width", "378",
[Code].....
Is it possible to use an addEventListner(MouseEvent.MOUSE_DOWN... to change an integer in a variable without using a function? So, you could have:
myMC.addEventListener(MouseEvent.MOUSE_DOWN, myVAR = 1); etc?
Obviously I've tried, but I get implicit failures.
I'm trying to get a function(recPlusFunct) to alter a variable(i) outside of the function but it doesn't seem to work, here's my code.
var i:Number = 0;
var recPlus:Function = this["rec" + i];
function recPlusFunct():Void[code]........
how can i change variable name dynamically
ActionScript Code:
i=2
vari + "i" = 7 //these don't work
//i need to trace these code
trace(vari2)
i allways get error. i've tried the bracket none worked for me like these quotation
I've done a search on this and I can't find anything that makes sense
Its the first time I've created a document class and an object class that extends a movieclip. I've tried endless functions and properties to access the public function within the object class, but I'm getting lots of different errors. Both classes are within the same folder as the .fla file. I don't know what I'm doing wrong.[code]...