ActionScript 3.0 :: Accessing Variables In A Loop?
Sep 9, 2009
i'm having trouble creating an image preloader with a loop. my apologies, this might be a very simple task that i've been pulling my hair out over for an hour.
i have 8 UIloaders. each named image1,image2,image3, etc. they are inside a movie clip called "allClips_mc".
this VERY long, redundant code works:
Code:
magicBox_mc.allClips_mc.n1.image1.source = "newsClips/images/newscast01.jpg";
magicBox_mc.allClips_mc.n2.image2.source = "newsClips/images/newscast02.jpg";
magicBox_mc.allClips_mc.n3.image3.source = "newsClips/images/newscast03.jpg";
magicBox_mc.allClips_mc.n4.image4.source = "newsClips/images/newscast04.jpg";
[Code]....
View 2 Replies
Similar Posts:
May 5, 2011
Say, I had a loop in a function...
[Code]....
How would I refer to a in another function
View 8 Replies
Dec 30, 2009
Is there a way to make the variables generated from a for loop within a function accessible to other functions? because at the moment other functions are firing errors because the variables refferenced are from a different function.
You may of seen this code from other threads
ActionScript Code:
function nodePoints():void {
//VarName, mcName, XPos, YPos
var row1:Array = ["clientComp", new clientComp(), 100, 200];
[Code]....
View 5 Replies
Apr 2, 2010
how can I access my different array variables in a for loop?what i need to do is for every increment in my for loop i want to change my var array name so that i don't need to use if else condition.
Code:
var ship_array:Array = new Array("spaceship1", "spaceship2", "spaceship3", "spaceship4", "spaceship5", "spaceship6", "spaceship7", "spaceship8", "spaceship9", "spaceship10",
[code].....
View 0 Replies
Feb 21, 2009
How can I make a bunch of variables from a for loop. for example for (var i=0; i<total; i++) {var bunch(i);}. that i make a bunch of variables named bunch1, bunch2, bunch3. I keep getting errors. I program and use so many different languages that I dont know if that can be done with AS3. my only other alternative i can think of is to create some sort of event dispatcher object array. but I dont know how to get them all to send events to one listener with there index number.
View 5 Replies
Sep 14, 2009
I have one .swf file inside a second .swf file. How do I have one .swf access variables from the second?
View 3 Replies
Apr 21, 2011
I have the following PHP file with a variable I am trying to access to place in a dynamic text box on my flash stage.
PHP code:
$returnVars = array();
$returnVars['username'] = "test";
$returnString = http_build_query($returnVars);
//send variables back to Flash
[code].....
The code was adapted from a tutorial using a class. However I do not get on with classes so wont be using any.
View 2 Replies
Jun 16, 2008
I have finally started with AS3 and flip-'eck its a different animal that AS2
I have a swf called login.swf and in it have declared the variables var total:uint=0; and loginState:Boolean=false
All my scripts for logging in sending/receiving variable from/to server scripts are all working!
So... when a user supplies a correct password another swf (userLogged.swf) is loaded (note: in AS3 this process is seriously different than in AS2) swf dont seem to be loaded 'into' another movieclip anymore... and this leads me to the puzzle!
How do I access variables declared in the project.swf, from within the userLogged.swf!
the old AS2 way = trace (_root.loginState);
or trace (_root.project.loginState)!
I am stumped by this new approach of AS3 of loading in other swf files. The _root. options is no longer available in AS3 (that much I've descovered, some tuts say use root. but I cannot get that to work)
trace (root.loginState)
or
var userLoggedIn=root.loginState
gives me the error
1119: Access of possibly undefined property loginStatus through a reference with static type flash.displayisplayObject.
when I try to publish the userLogged.swf
View 4 Replies
Oct 12, 2011
here is the wrong script:
var Var1:int=1;
var Var2:int=2;
var Var3:int=3;
[Code]....
View 2 Replies
Mar 8, 2010
I'm trying to access the AchievementScreen's textfield from a medal object. Point being to have a mouseover event of the medal, change the content of the textfield shown. I tried a trace first: trace(this.parent.parent.parent.parent.textLineCon tainer); 1119: Access of possibly undefined property textLineContainer through a reference with static type flash.displayisplayObjectContainer. trace(this.parent.parent.parent.parent) shows me it is a AchievementScreen object. textLineContainer is the instance name of the MC nesting the textfield (I actually drew the achievement screen then exported it to actionscript.
[Code]....
View 11 Replies
Jul 25, 2011
[Code]....
I want to use the variable var_page3_title for dynamic text boxes in movie clips further on down the timeline. Of course I don't want to repeat this code for every textbox so my question is, how to I access the variables from the function loading();
View 2 Replies
Jun 14, 2009
I have defined a variable in frame 1 and want to set different values in frame 65. How can i access that variable in 65th frame?
View 1 Replies
Jul 14, 2010
I'm trying to create a JW player plugin, a part of the source code is shown below:
public function initPlugin(player:IPlayer, config:PluginConfig):void {
api = player;
var streamUrl:String = 'xxx';
[code].....
View 1 Replies
Jul 25, 2010
First off I don't understand classes, how to "call" or "initiate" them. I'm class ignorant.
I have two .fla files. One of my .fla files consist of 15+ .as files; we'll call this one XML editor. The other .fla file consists of 10+ .as files; we'll call it the interface.
The xmleditor.swf loads the interface.swf. Within the xmleditor.swf, a login screen appears and the enduser logs in as either a "user" or an "admin". The "user" or "admin" is stored in a public variable called "userType". The userType variable is created in one of the many xmleditor.fla .as files called Login.as.
Once logged in, xmleditor loads the interface.swf. interface.fla uses 10+ .as files. one is called nodeNames.as I need an if statement in nodeNames.as that is something like this:
if (Login.userType == "user"){
trace("do something");
}
I have the following FlashVars.as file but I have no idea what the steps are to make it work.
package extras.utils {
import flash.display.Sprite;
import flash.display.LoaderInfo;
[code]....
Should I use this FlashVars? and if so, how?
Or is there an easier way to access the variable?
View 1 Replies
Oct 25, 2010
I would like to know if it is at all possible for AS3 to grab header information and process it? I am trying to avoid having to use PHP to get the information, then store it in a DB, give it to flash, then go and delete it again, or something alike.
Basically the flash is waiting for three variables that get sent through the URL, right when it gets initialized, then once it gets those variables, it can determine where to go next.This is for a Facebook application, and I am using FBML to embed the flash.
View 2 Replies
Jul 1, 2009
I am creating a flash program to open other flash programs (load swf files), and change their textfields to my own extended textfield class. This is to capture all text written to screen using a textfield object. Here is what I am doing:
1. If a textfield has been created, the event is captured
2. I want to replace the textfield with my own class extending textfield
*3. Any further access to the original textfield for value changes can be captured, and would update the replaced extended textfield object
The problem is if in their original code, at sometime, the text value of textfield is changed (mainly through textFieldObj.text = some_value) , I don't know how to capture this event.
This cannot be captured by event.CHANGE which requires the user input (ie: keyboard strokes) into the actual text field and changing the text through the code: textFieldObj.text = some_value does not trigger the event.
Here is a simplified example:
// FlashMovie.fla START -------------------------------------------
// any DisplayObjects (such as a created textfield) created will be captured
// by ChildAdded()
this.addEventListener(Event.ADDED, ChildAdded);
[Code]....
View 0 Replies
Jun 21, 2010
I have an input box and button on frame 1. I want user to enter some text in the textbox, and press the button.This will take him to frame2 and based on the info supplied it will take something from the server. The code on the frame 2 would be:
ActionScript Code:
var path:String = ("Http://" + w.text + ".pl");
var nodeLoad:URLLoader = new URLLoader();
nodeLoad.load(new URLRequest(path));
[code]....
I get the error. - Access of undefined property w. (where w is the input box)
View 4 Replies
Jun 23, 2010
I need to access the contents of a variable that is filled inside a function, but is declared outside the function.. [URL] says that if you declare the variable outside of the function the variable should be accessible even when its content is filled by a function. I have declared the imgs variable at the start, outside the function, as an array. After that the function retrieves a string from the URLLoader and splits that string into to the imgs array/variable.
[Code]....
View 2 Replies
Jul 20, 2010
I have a parent swf which loads a child swf. The. Child swf is a game and when. It finishes, I need to access the score from the parent swf. How is this possible....
View 1 Replies
Jun 9, 2011
number = '12345' I'm trying to hook my counter up to a PHP script that echo's a DB query. Now I've had no issue passing the variable and I can even display it in a dynamic text field but no matter what I try I cannot get the "number" varibable to use my PHP variable The dynamic text field shows the correct value clear as day but the counter just shows "undefined".
[Code]....
View 9 Replies
Jul 25, 2011
I have this code on the main timeline:
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, loading);
[Code].....
I want to use the variable var_page3_title for dynamic text boxes in movie clips further on down the timeline. Of course I don't want to repeat this code for every textbox so my question is, how to I access the variables from the function loading();
View 5 Replies
Jan 12, 2011
I'm having a SWF call functions from another SWF loaded in the first one with the Loader class. There are no problems as long as the target SWF does not contain any TLF TextFields created on stage by authoring time interface. As soon as I place a dynamic textfield on the stage of the loaded SWF, the main SWF (the loader) fails to call any of the functions within the SWF that is being loaded.Static text does not seem to present problems and neither do TextFields created via ActionScript.Also, is it possible to access variables of the parent SWF?
View 2 Replies
Dec 5, 2003
I am having a problem accessing variables in a loaded flash movie.
As my understanding goes (someone please correct me if I am wrong), if I load a flash movie into a parent movie (i.e. 'loadMovie("myMovie", emptyClip);'), I should be able to access the loaded movie's variables using dot-syntax.
As an example, say I have two movies: MainMovie.swf, and SubMovie.swf. SubMovie.swf contains a (global) variable called someText. After loading SubMovie into an empty movie clip called "emptyClip", MainMovie.swf should be able to access the aforementioned variable by saying "emptyClip.someText", right....? Well, when I try this I keep getting an undefined value for the variable.
View 7 Replies
Dec 11, 2007
accesing the movieclips/function/contents of a extenal swf.I used movieclip loader to load the swf.i have two files.. preview.swf and main.swf preview.swf loads an xml and renders its content. the xmlpath is embedded in preview.swf. when i play the file directly, it seems to load the content. however when i load preview.swf into main.swf with a moviecliploader, it does not load or render the xml.i cant even access the functions / variables in the file preview.swf.
View 3 Replies
Dec 13, 2011
I'm loading swf externally. I need to access it's methods and variables. This is the code I'm using:
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
[code]....
View 2 Replies
May 3, 2011
I am having this issue were I can not access any variables from any other class![code]Now, from my other variables, that is what I do, I don't understand what I am doing wrong?
View 5 Replies
Dec 5, 2003
if I load a flash movie into a parent movie (i.e. 'loadMovie("myMovie", emptyClip);'), I should be able to access the loaded movie's variables using dot-syntax.As an example, say I have two movies: MainMovie.swf, and SubMovie.swf. SubMovie.swf contains a (global) variable called someText. After loading SubMovie into an empty movie clip called "emptyClip", MainMovie.swf should be able to access the aforementioned variable by saying "emptyClip.someText", right....? Well, when I try this I keep getting an undefined value for the variable.
View 7 Replies
Aug 1, 2004
how to access variables that are declared in a movie clip from a function declared in that same movie clip.
i.e.
****************************
var int1 = 1
var int2 = 2
[Code]....
I'm trying to do this in the main movie clip of a movie that I plan on importing dynamically in another movie. I've tried to use this.int1++, but I think that flash was looking for a variable that belongs to "myfunction" when I did that. I could just use _root.int1++ but like I said, I plan on dynamically loading this into another movie, in which case it would be pointing to the wrong movie.
View 2 Replies
Mar 14, 2012
If you have a series of sprites created in a loop:
ActionScript Code:
for (var i:int = 0; i < numItems.length(); i++) {
var mySprite:Sprite = new Sprite();
}
Which you added event listeners to, in the same loop:
ActionScript Code:
for (var i:int = 0; i < numItems.length(); i++) {
var mySprite:Sprite = new Sprite();
mySprite.addEventListener(....
}
How can you remove those listeners, then add them again? I need to kill and re-enable the listeners of many sprites which were created that way.
View 4 Replies
Jun 15, 2009
I have an instance of a movie clip called dirt I assigned a variable to dirt called dirt.val I also added an event listener to dirt that calls a function In the function I want to access the dirt.val property, but evt.target.val doesn't work.
View 3 Replies