ActionScript 3.0 :: Creating Dynamically Named Variables In A For Loop?
Nov 4, 2009
i am loading several images from an XML path into a flash movie and i want to dynamically create image loader variables for them. Here is my code so far:
Code:
var xmlData:XMLList;
var myXML:XML;
var xmlLoader:URLLoader = new URLLoader();
[Code]....
method and this doesn't work for me either, i'm guessing thats because it is in the AS2 forum.
View 1 Replies
Similar Posts:
Jan 24, 2010
I need to make new sprites on-the-fly within a for loop, and this code does not work:
Code:
for(var i:int = 0; i<5; i++) {
var this['menuBtn'+i] = new Sprite();
[code].....
View 2 Replies
Jul 27, 2010
I'm trying to create a dynamicly named object.
something like
private var myVar:String = "dynamicName";
private var [myVar+"staticName"]:Object = new Object;
but what i wrote above dosn't work for some reason.
View 2 Replies
Dec 11, 2010
I've created a basic function that sets a movieclip to a certain state depending on which mouse cursor is set (determined by a variable called txt_cursor). I can hard code this to work great for the one single movie clip but potentially have to do this for 624 other movie clips so obviously want to create a for loop to reproduce this.
Code:
chk1.onRelease = function()
{
[code]........
View 1 Replies
Mar 2, 2010
i'm loading several sound files, and want to error check each load. however, instead programming each one with their own complete/error functions, i would like them to all use the same complete/error handler functions.
a successfully loaded sound should create a new sound channel variable, while an unsuccessfully loaded sound will produce a simple trace with the name of the sound that failed to load. however, in order to do this, i need to dynamically create variables, which i haven't yet figured out how to do.
here's my code for my complete and error functions:
function soundLoadedOK(e:Event):void
{
//EX: Sound named "explosion" will create Sound Channel named "explosionChannel"
var String(e.currentTarget.name + "Channel"):SoundChannel = new SoundChannel();
[Code].....
View 2 Replies
Dec 8, 2011
After loading the movieclips and text boxes dynamically I now need to get the movieclips to perform a unique function when they are pressed, for testing purposes I am using the getURL funciton and linking to the boxNo. This is just so I can see what is going on!At the moment they are all linking to the boxNo that is pulled from the last run of the loop.
for (var i = 0; i < loc.length; i++)
{
var boxNo = loc[i].location_ID;;
[code].....
View 1 Replies
Dec 19, 2008
Still learning how to use for loops, I want to set a huge range of Boolean Variable to false. like:
var met0:Boolean = false;
var met1:Boolean = false;
var met2:Boolean = false;
etc... etc...
how can I dynamically name variables inside a for loop and set its data type? I know how to with movieclips but can't get it to work with variables
View 4 Replies
Jun 7, 2011
The label variables are null at the end of the loop. This has worked for be in the past. What am I missing?
[code]...
View 3 Replies
Dec 6, 2010
I have the code below but I need to generate it with a for loop. What is the proper way to do this? I don't initially know how many points i will have. I just want to create a for loop to loop through a variable that holds the point count such as "var totalPoints=10"
//1
var p1oint = new Point();
points.addChild(p1);
[code]......
View 1 Replies
Jun 1, 2011
Here is the structure of the XML file: PHP Code: <xmlfile><page></page><page> <source></source> </page></xmlfile> Some "page" nodes contain the extra "source" node. What I'm currently doing is looping through all the page nodes and looking for any source nodes. If there is a source node, I create a variable, and want to assign it a value of the contents of the "source" (HTML).
[Code]....
View 1 Replies
Dec 2, 2009
I am reading in collection objects from an XML file. Each collection has an img field that stores a URL to the collection image. So I am trying to load the images of each collection, storing each image in a MovieClip, and add these MovieClips to the stage. However, my problem is that after adding a MovieClip (with the collection image) to the stage, when a new MovieClip is created in my 'for each' loop it overrites the previous MovieClip. So the images I am adding to the stage are being replaced by the following collection's image on each loop iteration. What can I do to avoid this?
Here is my code...
var collXML:XML = IXml(assets.collections).xml;
var collNodes:XMLList = collXML.children();
for each (var collInfo:XML in collNodes)
{
[Code].....
View 6 Replies
May 29, 2008
I using a loop to dynamically create some movieclips and then position them using the ._height and .width values.
When they are created I use a Listener and LoadInit, to check that everything has loaded. I do this because I want to be able to access the ._height properties of the movieclip in order to place them next to each other and centre them vertically.
If I place the following 3 lines outside the function:
inBead._x = currentPosition;
//gets the start position
currentPosition = currentPosition+Number(mainLoader._width);
//gets the position and adds the width of the movieclip
[Code]....
View 1 Replies
Feb 3, 2010
I'm still a noob with flash. But I'm attempting to make my website using itSo far I haveseveral swf files that are all loaded into a "index" swf file.So all the code needs to work with that chain of MC's:_root.LoadedContent_mc.LoadedContent2_mc.Page1_mcThats the path to where I am working..Page1:I'm attempting to create a downloads list here. I have a phpfile already worked out that scans the directories "downloads" and "imgs", and generates a list of file names. It then formats each file name into a path to that file. And turns each path into a variable that can be loaded into flash.So basically after php does its thing we are left with this:
Code:
File1=Pages/PageData/Page1/Downloads/SomeTextFile.rar&File2=Pages/PageData/Page1/Downloads/SomeTextFile1.rar&File3=Pages/PageData/Page1/Downloads/SomeTextFile10.rar&File4=Pages/PageDat
[code].....
View 1 Replies
Oct 15, 2009
I'm currently creating an app which allows users to select blocks of text from a List and dynamically create a TextField on the stage.I'm calculating the height of the TextField and positioning the next TextField beneath.I'm also recording the total heights of the TextFields so that I know when the total height exceeds the available height, at which point I move the x position and reset to y position to zero.
When the next TextField will exceed the available height I want to split it into two, so I'm calculating the remaining height, making the TextField.height into the remaining height.when I try to get the position of the last visible line.If I have the TextFieldAutoSize as LEFT, then I can dynamically generate the heights of the TextFields.For the final TextField in the column I need to set TextFieldAutoSize to NONE so I can change the height of the TextField. i.e. I don't want it to autosize.However, bottomScrollV returns the total number of lines, not the last visible line.
I can create the required behaviour in a separate doc but when I copy the code into the loop it fails.Here is the code.
Code:
public function buildTextFields() {
3 columns (I'm calling them TextBlocks)
// so the first is 0;[code]....
View 1 Replies
Nov 10, 2009
Trying to get from AS2 to AS3 and the simpliest things are taking too long.I have some movieclips on the main timeline named...
btnSm1_mc
btnSm2_mc
btnSm3_mc
[code].....
View 2 Replies
Sep 8, 2009
It is possible to loop through buttons in a movie clip that do not have sequential names.For instance, they are all named by the date they are for reference to a database.
View 1 Replies
Feb 18, 2004
I'm using a loop to duplicate a MC named MCbutton, which is all good.
[AS]
for (i=1; i<=this.total; i++) {_root.MCbutton.duplicateMovieClip(["MCtest"+i], 1+i);
trace(_root.MCtest1);
[Code]....
Can't i duplicate a Clip inside another Clip??
View 5 Replies
Apr 3, 2012
I'm building a variable matching game. The player clicks one of four choices and then clicks the answer area. Their choice appears in the area, and if the answer is correct the answer container shifts down, highlighting the next answer area to be filled. Inside the container are a large number of these answer areas (60).
What I am trying to do is have only one be answerable at a time, the highlighted one, so that players can't skip ahead despite seeing the empty spaces left to answer in. What I have right now isn't working, and I could use some outside insight.
Code:
var i:int =1;
function sampleFunction(evt:MouseEvent):void{
if(selection == e.currentTarget.targetCorrect){//targetCorrect is a string set statically
[Code].....
I realize I could use a for loop to add the event listener, but the project really calls for only one answerable area at a time.
View 2 Replies
Feb 5, 2009
My problem is that I cant figure out how to draw my movieclip if I dynamicly name it.
However If I address it by using its actual name it works fine.
I have included both working and non-working code.[code]....
View 2 Replies
Jun 18, 2010
i'm trying to create a dynamically named Vector. i have a critical project deadline tomorrow, and this small problem is holding back continued development i've adapted my code from this example [URL]...yet am getting an error message (see below). here is what i have:
[Code]...
View 9 Replies
Oct 20, 2010
I have an array of external images that I am loading and the number of external images is variable, so I want to be able to create loaders to load them as needed. Is there a way to dynamically create and uniquely name a loader at run time?
Otherwise is there a way to pass the image content off in such a way that it will remain loaded if the loader is used to load other images?
View 3 Replies
Dec 9, 2010
I've dynamically created a grid of buttons which are going to modify a 2D array, but I can't work out how to create a unique function for each iteration of the loop with a dynamic function name. Probably just a stupid syntax error by me...
ActionScript Code:
for(var i:int = 0; i < 8; i++){
for(var j:int = 0; j <
[code].....
View 3 Replies
Apr 13, 2011
So I've been trying to make dynamically named functions, and while it works, I've run into a couple of problems.
ActionScript Code:
var uServer:String = "irc.epic-chat.net"
var lol:String = "lolz"
var num:Number = 3
[Code].....
If I had something like that ^ what could I add to func to distinguish between whether it is being called by lolz0, lolz1, or lolz2? I was thinking whether there was something like .name I could use, but I couldn't come up with anything.
View 9 Replies
Oct 2, 2009
A snippet of my code is [code]The first element in the mainOptions Array is linked (metaphorically) to tab1.The second element in the mainOptions Array is linked (metaphorically) to tab 2 and so on.I want to create 12 variables named AudioMP3, AudioHEAAC, NewsBBC, NewsTwitter, VideoVideo and so on down to PicsPics2. i.e concatenate each entry in say tab1 through 5 to the each element from mainOptionsArray and make a new variable using that name then assigning a number to this variable.[code]
View 1 Replies
Nov 16, 2010
I'm trying to get data out of an array. Problem is the array I'm trying to access is different depending on where I'm currently at.
I can get data from a dynamically named variable, like so:
_parent["Menu" + Menui + "Button" + Listi + "Link"]
but now that I want to access one field in an array, instead of a single variable, I don't know the syntax to get at it? Waa. I tried:
_parent["Menu" + Menui + "Button" + Listi + "Link[" + Linki + "]"]
but it didn't like me.
View 2 Replies
Jun 23, 2009
I've been attempting to attach bitmaps from the library in AS3, and have settled on a piece of code which works:
PHP Code:
var myBitmap:Bitmap = new Bitmap(new pic1(0,0));
myMovieClip.addChild(myBitmap);
[code]......
View 6 Replies
May 25, 2004
I have a movieclip (myMC) that I create several instances of.I dont duplicate the movieclips, but just copy and rename them like "myMC_i", where "i" is a unique number.Can I somehow check if one copy of myMC (for instance "myMC_2") collides with another copy (for instance "myMC_5"), always ignoring collisions with other types of movieclips on the stage?Thats the problem I cant solve. I can either check for a collision with ANY other movieclip, or check for a collision with a single SPECIFIED movieclip (by checking for its name). But I dont know how to check for a collision with a group of movieclips that has the first part of their names in common. If it had been like in a search-engine, you would have been able to search for:[code]
View 1 Replies
Sep 12, 2011
I have a function that creates a group of dynamically created MC'sWithin each MC, there is a group of dynamically created buttons.I got that bit to work fine.Now what I need is to send a handful of var strings and numbers along with each of those buttons, and am not having very good luck doing thatHere's what I got so far...
Code:
function storePageBuilder(a):void{
var storeMC:MovieClip = new store_MC();
[code].......
View 1 Replies
Sep 12, 2011
I have a function that creates a group of dynamically created MC's Within each MC, there is a group of dynamically created buttons. I got that bit to work fine. Now what I need is to send a handful of var strings and numbers along with each of those buttons, and am not having very good luck doing that.
Here's what I got so far...
Code:
function storePageBuilder(a):void{
var storeMC:MovieClip = new store_MC();
storeMC.name = "storeMC_"+a;
[Code]....
View 1 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