ActionScript 3.0 :: Use Of A Variable To Reference A Text Box In An Instance?
Aug 16, 2009
Lets say I have 3 Movie Clip Symbols in my Library : Movie0, Movie1 and Movie2
Each movie has a dynamic text box: "TextBox1"
I want to be able to write a function that can manipulate the alpha(or any attribute) of the TextBox1 in all three MovieClips.
In my limited experience I thought I could do something like the following:
for (var row:int = 0; row < dataArray.length; row++)
{
Movie(row).TextBox1.alpha = 1;
}
I hoped that this would loop through 3 times and set the alpha of the TextBox1 in all three movies to 1.
Is this possible? Can you reference an instance with use of a variable?
View 2 Replies
Similar Posts:
Nov 28, 2010
i want to use a variable(text) to refrence a movieclips instance name
Code:
function InventoryShow(event:Event):void
{
var SC:URLVariables = new URLVariables(event.target.data);
[Code].....
View 1 Replies
Mar 8, 2011
set to null a reference in this case?
private function initGame():void{
var game:Game = new Game()
}
[code]......
View 2 Replies
Nov 26, 2007
I'm creating a dynamic movieclip and the name/instance name is stored in a variable. How can I reference the instance if its stored in a variable?This is what I'm using and it doesnt seem to work (for obvious reasons). I know in php that you do this "blah blah" . $variable.
View 1 Replies
Mar 8, 2011
Theres any need to set to null a reference in this case?
private function initGame():void{
game= new Game()
}
[code].....
View 1 Replies
May 25, 2010
How do I reference the variable pointed to by the variable text but pointed to by more than one function?Say I have:
engine_level = 5;
tank_level = 3;
v_name = 'engine';
[code].....
View 4 Replies
Jan 5, 2012
How do I reference the variable pointed to by the variable text?
Say I have:
engine_level = 5;
v_name = 'engine';
pb_name = v_name + '_p_button'; // so pb_name = 'engine_p_button';
level = v_name + '_level'; // so level = 'engine_level';
[Code]......
View 2 Replies
May 21, 2011
Alright so lets say I have a number of movieclips or text fields or something with instance names test1, test2, test3 and so forth. Now say I want to fill these text fields with text that I have in an array and I want to do this with a loop, how do I do this? What I'm really asking is if there is a way to use a variable in an instance name if you catch my drift.
[Code]...
View 1 Replies
Nov 6, 2009
There's a movieclip, lets call it myMovieClip. Inside this movieclip there is a dynamic text box, lets call this one myText. Now to change the text within this text box that is embedded in a movieclip, it's simply:
[Code]....
However, what if there is a variable, called myVariable that stores the instance name of the text box. With only one text box I know it's pointless, but for the sake of example, lets leave it simple. So, suddenly the code looks like:
[Code]....
View 2 Replies
Oct 20, 2009
I want to be able to reference the text of a text box within an MCThe MC is called "box1", the text field is called "field1"...I have many MCs (all with field1 in them)... box1, box2, box3 etc etcObviously I can set the text to being something by saying...box1.field1.text = "set_this_text"However, I'm using a variable to come up with the "box1" bit. (Using an array and a loop to figure out which box I want to update based on where the user clicked). So, let's say I have a variable... and I want to say..boxClickedon = box1 //will be defined by userSo I don't know in advance about box1... I can only access it through "boxClickedin" variable, but
boxClickedin.field1.text = "set_this_text"
or
[boxClickedin].field1.text = "set_this_text"
[code]....
View 1 Replies
May 7, 2011
I have 10 text fields named "text1", "text2" etc;
I'd like to use a for loop to pulate each one, so that each text filed is populated with whatever i is:
for (var i:Number=1; i<=10;i++) {
"team"+i.text = i;
}
I keep getting errors with regards to how the text filed name is referenced.
What is the correct way to increment the text filed name and reference it?
I've tried:
["team"+i].text = i;
"team"[i].text = i;
but they don't work.
View 1 Replies
Jan 19, 2011
So i have an external text file organized like this:
/* $file: data.txt */
&title0=Sacrum
&detail0=Detail text for Sacrum
&title1=L5
[Code].....
There are 28 of these 'title' and 'detail' pairs. The 'title' text is to fill a dynamic text box and the 'detail' to fill another dynamic text box depending on which section the user is mousing over.
My issue is getting the text from the file stored into arrays. For my test loop I keep getting undefined as the stored value, and i know it has something to do with converting a string value to object..
var lv:LoadVars = new LoadVars();
lv.onLoad = handleDataLoad;
lv.load('data.txt');
function handleDataLoad (success:Boolean) {
[Code]....
View 1 Replies
Jan 6, 2012
i have instance of "HelloClass" class on my main movie : _root.mc.HelloClass.variable1.fullurl
so my HelloClass exteds movieclip and has var named Variable1 that also class with var fullurl
i want to access fullurl string value dynamically , somthing like: _root.["mc"].["HelloClass"].["variable1"].["fullurl"]
so i can access every var from external swf
View 1 Replies
Jan 6, 2012
i also write this question in as2 forum, but i need it also for as3i have instance of class "HelloClass" on my main movie :_root.mc.HelloClass.variable1.fullurlso my HelloClass exteds movieclip and has var named Variable1 that also class with var fullurli want to access fullurl string value dynamically , somthing like:_root.["mc"].["HelloClass"].["variable1"].["fullurl"]so i can access every var from external swf
View 2 Replies
Feb 12, 2012
I have a base class I've used on 6 different MC's. Then when I use these MC's my function runs an if statement to check which one to add.
if(id=design) var obj = new design();
if(id=team) var obj = new team();
I want to make it a bit more dynamic and use the id:String to evaluate which new instance to create.
ActionScript Code:
public function loadChapter(id:String):void {
var obj = new instance_of( id )();
}
View 5 Replies
Apr 14, 2011
I'm creating a little game - The player controls a character that follows the mouse. Pigs run away from the player, and the player has to get them all into a pen. To make the game a little more difficult I'm trying to add an enemy - wolves, that attempt to perform a 'hunt' method every x seconds. This method sends a reference of the wolf instance to Main (my document class) and Main then loops through the pigs on stage to see if there's any nearby. Now as far as I know this works - my problem is I'm unsure how to send the pig instance reference back to the wolf that called the hunt method, so it can then 'target' the pig, and then attempt to pounce on it.
This is my Wolf class:
Code:
package
{
import flash.display.MovieClip;
import flash.events.Event;
[Code].....
View 7 Replies
Jan 7, 2010
As we know whent here is no such variable of null value assignment to a variable or instance flash throws this kind of Error.In one of my Application i need to get more flashVariables, They may or maynot come as FLASHVARS. But when i miss any variable flash thows this error as an alert box. is there any simple solution to avoid this kind of issue
when i use try,Catch statement the issue will not come, But i don't like to write Bunch of try,catch statement for all this kind of variables.
View 4 Replies
Jul 24, 2009
I've got a set of arrays being dynamically generated with paths to nested movieclips. The paths are coming in as strings, and I can't seem to get them to work as movie clip instance variables.as example, a string would be:
siteMC.b1MC.b1f1MC.rMC
(that path works fine outside of the array)
How do I get that kind of nested path from the string to something flash wont spit out as null?
View 4 Replies
Apr 13, 2010
I thought since a Sprite is a display object container and I can add an instance of a MovieClip to it I should be able to reference the MC through the Sprite.
var bh1:Sprite = new Sprite(); beerChan = new BeerChan(); bh1.addChild(beerChan); trace("bh1 "+bh1); trace(bh1.beerChan);
1119: Access of possibly undefined property beerChan through a reference with static type flash.display:Sprite.
View 10 Replies
Oct 2, 2009
I have a movieClip and would like to run a hitTestPoint() if statement on it, but only for a particular instance within the movieClip.
Would: 'movieClipName'.'InstanceName'.hitTestPoint () { work?
View 1 Replies
Mar 16, 2010
I have 6 movieclips on the stage, each with a unique instance name. I just want to put them in order determined from an external xml file.I can get the name and order of each instance name evident from a trace, but I can't use that xml variable name to position the x on the stage.Seems simple, but it won't let me use the variable as an instance name:
//begin AS3
var loader:URLLoader = new URLLoader();
var xml:XML = new XML();
[code].....
View 2 Replies
Dec 10, 2010
Quick question. I have been Googling this all morning, but it's either not there, or else written in a way that doesn't register. I am inclined to believe the latter, as this seems like it should be something completely trivial to me. I made a small Flash file using AS 3.0, and this is the first time I've really been able to stick to the OOP way of doing things and not hack together a mix of stuff from the timeline to get around not having everything work in the classes.
So I'd like to keep it that way, but one thing is eluding me: I can't call a method of an instance of another class (than the one I'm calling from) without resorting to "DocumentClass(root).instanceName.method." Intuition tells me there has to be a better way of doing this (like, without having to reference the document class every time I call another class instance's function; and CERTAINLY without having to use the word "root" - that just seems so Flash 5 to me. Does anybody have a better way of doing this that they can share?
[Code]....
View 1 Replies
Nov 15, 2009
I have a script on frame 1 that onRelease of button should tell dynamic MovieClip instances which have been added by attachMovie on frame 2 and 3 to go to a particular frame , here's the code:Frame 1:numdests is set to 2pagesAmount is set to 4
btn_submit.onPress = function(){
for (var i = 0; i<numdests; i++){
for (d = 1; d < pagesAmount + 1; d++){
[code].....
View 9 Replies
Jul 15, 2011
Is it possible to control an object/element on a instance? If so, how is it done through actionscript? There is an instance "instance140" off of the root, that has an element named img4 that i need to reference... does anyone know how I would go about that? using root.instance.object form returns undefined.
View 1 Replies
Nov 15, 2009
I have a script on frame 1 that onRelease of button should tell dynamic MovieClip instances which have been added by attachMovie on frame 2 and 3 to go to a particular frame , here's the code:
Frame 1:
numdests is set to 2
pagesAmount is set to 4
[Code].....
Currently the movies that are added using AttachMovie don't move when button on frame 1 is pressed.
View 0 Replies
Sep 6, 2010
I have movie clip Ball what has public function glow[code]...
full access to Ball is MainMenu.ImagesPanel.Ball
I want to send command from server in text like:
string="MainMenu.ImagesPanel.Ball.glow"
How to convert sting to structure?
View 0 Replies
Oct 14, 2010
i'm playing around with Senocular's brilliant transform tool. Here's the code that I'm having issues with - it targets the instance name, which is great and works perfectly.
ActionScript Code:
_transformTool.targets = [pasteBoard];
_transformTool.activeTarget = pasteBoard;
Here's the issue. When I have an MC placed on the stage with the instance name of 'pasteBoard' the above code (which tells the transform tool what to transform), works just great. However, when I place the MC on the stage with AS and name it, the transform tool can't find it . Here is the code I'm using to place the MC:
ActionScript Code:
var pasteBoard:_pasteBoard = new _pasteBoard();
addChild(pasteBoard);
pasteBoard.name = 'pasteBoard';
pasteBoard.x=128.00;
pasteBoard.y=300.00;
Now, surely this should work as I'm even giving it an instance name? But it does not, it does not work even with no instance name, or when the class object name is different than the instance name. Weird huh? Surely this should work just fine as I'm doing exactly the same thing as placing it on the main timeline, just doing it with code. But the transform tool, referenced by the code at the top of this post, can't find pasteBoard.
Do I need to alter the code at the top to find pasteBoard by class instance? how would I do that?
View 4 Replies
Jul 14, 2011
Is it possible to control an object/element on a instance? If so, how is it done through actionscript?There is an instance "instance140" off of the root, that has an element named img4 that i need to reference... does anyone know how I would go about that?
View 0 Replies
Mar 23, 2012
I created an Array of lrgIcons that contains several MovieClips, they are then positioned within a second MC and pushed to a second array of lrgIconsOnStage, they are enabled as buttons and assigned an event listener (all of this works fine). Problem is, I want to know which lrgIcon is selected and react to it with an if statement. When I trace the array of lrgIconsOnStage I get [object amazonLrgIcon],[object emailLrgIcon],[object gmailLrgIcon],[object messagesLrgIcon],[object missedCallsLrgIcon] and when I trace e.target I get [object amazonLrgIcon] (depending on which item I selected, which in my mind, should trigger the code correctly, but it does nothing, Why?
Code:
var currButton:String;
var lrgIcons:Array = new Array(amazonLrgIcon,emailLrgIcon,gmailLrgIcon,messagesLrgIcon,missedCallsLrgIcon);
var lrgIconsOnStage:Array = new Array();
var lrgIconPosY:int = 69;
var lrgIcon:MovieClip;
[Code] .....
View 7 Replies
Nov 21, 2010
1) I have a movieclip instance on stage (simple graphical element that represents platforms for a hero to run and jump along). I have placed it on the stage with an external class engine.as and in this class it is called myPlatform and is an object of Platforms.as. The movieClip is called platforms and from a trace(myPlatform.name) the instance name is instance3.
2) I am attempting to access the properties of myPlatform in an Enterframe event loop in my character control and collision class (called hero.as)Basically here is the bit of code I am trying implement within Hero.as :
if (myPlatform.hitTestPoint(x,y,true)) { // if a platform is hit
trace("hitME");
y--;
tGravity = 0; // reset
break;
}
Here's the error that I get:
1120: Access of undefined property myPlatform
This all worked when I was writing actionscipt within the FLA file, on the timeline frame 1.I simply don't know how to access myPlatform from within the external Hero.as class! Do I need to create a variable?
View 1 Replies