ActionScript 3.0 :: Access To Childs Created Through For Loop?
Nov 15, 2009
Image's paths are in the xml file. I make a loop to load images to the Display List.
So if i have a loop:
ActionScript Code:
for(var i:int=0;i<xmlList.length();i++)[code]....
after it is done i would have access only to the last imageLoader instance. How to get access to the rest of images, which were added to the Display List with the same name "imageLoader".I tried to call it with the imageLoader.name property,but surely i do something wrong, as only errors appear in the output panel.
View 1 Replies
Similar Posts:
Jan 21, 2011
I need to be able to make a large amount of concentric circles, using only the action script. I need to be able to alter each of these concentric circles independently from each other. Currently My code is as follows:
ActionScript Code:
var circ1:MovieClip = new MovieClip();
addChild(circ1);
[code].....
View 6 Replies
Jul 20, 2009
I have a script that randomly pops out circles all over the stage. However, I want them to disappear once I roll my mouse over them (and only the ones I roll over, not all the instances).So if I have code like this in a function:[code]And then I have a mouse_over function in the same class, how do I tell it to removeChild? Since the stars are instances of the object, they are giving instance names like instance67, which makes them hard to remove.
View 2 Replies
Jun 1, 2011
Do I need to create all objects which i will possible use with itemRenderer in createChildren function, even if the current item must not show some of them ?
View 2 Replies
Jun 16, 2011
how can I access to All instances of a movieclip in the stage with for example a for loop?
View 3 Replies
Oct 22, 2010
So, you have a sprite, you draw some graphics, you set cacheasbitmap=true... I can't seem to access the newly created bitmap data, to access the dispose() method.
[Code]...
View 6 Replies
Feb 19, 2007
Basically, I have data organized by date in an XML file. I'm trying to make a website application that will allow the user to click on a date (in a text field) to see another textfield populate with all the data under that particular date. So far, all the information loads into the textboxes at the same time. How can I get it to only load information under a particular date when somebody clicks on that date?
Before I started this project, I was convinced I could do this by manipulating the [j] (see code below) in the myFunc2 function. Currently, it's set up to increment blank_mc._y by whatever value is returned by [j]. But for some reason this doesn't work. I feel that if I could atleas get this part to work - I could probably do the rest.
AS code:
Code:
function loadXML(loaded) {
if (loaded) {
var nodes = this.firstChild;
[code]....
View 1 Replies
Jul 26, 2011
I am doing is learning flash, so what I have done is followed some tutorials and created some different images with a mask, now I trying to make them loop and I can't seem to figure out how to do it. it seems at the end of the tutorial it says I must put in a stop or the last layers do not come in to view. So I am curious as to how to get passed this problem I am having. am I doing this completely wrong?
View 1 Replies
Jan 20, 2010
[code]My code will:
- loop through the Grid array and place each tile on the stage
- assign RedBall a random Grid coordinate and places it on the stage at that coordinate
I want to be able to click RedBall, which will create a border around the tile beneath RedBall, and create borders around the tiles above, below, to the left and to the right. BUT, I don't want to reference the tiles by their distance in pixels from RedBall or from each other; I want to reference the tiles by their coordinates in the Grid array. So I want to:
- get the coordinates of RedBall
- use those same coodinates to reference the tile at the same coordinates in the Grid array
- use the tile's coordinates to reference the tiles above/below/left/right
- apply a border to all these tiles
What's the best way to reference an instance of a tile? Should I apply a name to each instance as it's created in the loop? like myTile.name = "tile"+i+"_"+j; ? If so, how do you reference that instance later? Just tile1_3 ? Do you have to prepend it with root, or stage, or the class it was originally created in? Do you have to use getChildByName? OR, can you still reference it later without having given it a name?
View 1 Replies
Nov 21, 2010
I have a simple gallery site with thumbs 'gridBtns' that show and hide content pages 'projectPages'
I have a loop that duplicates an MC (projectPageHolder) (that already exists on the stage) 20 times, simple enough. I run a trace that confirms they all exist.
In the same loop I give a different set of 20 MCs (gridBtn) an onRelease function that attempts to show and hide the projectPage MCs using _alpha, again simple enough.
For some reason the first 4 MCs disappear...they do not trace or become visible, but the rest are fine.
[Code].....
View 1 Replies
Mar 1, 2008
I have the following code that should set the onPress events for movieclips
Code:
function actionSetter() {
for(var k = 0; k< 5; k++) {
trace(k); //traces correctly
_level0["EventBtn" + k].onPress = function() {
[Code]...
What should I do to correctly define onPress for my movieclips within the loop?
View 2 Replies
Aug 25, 2009
simplied version:(there's a mc of the Box class in the library)
Code:
for (var i:int=0; i<10; i++) {
var box:Box=new Box();[code]......
error: access of undefined property box2
View 13 Replies
Nov 11, 2010
I am creating a loop which loadsimages to newly created loaders.After each loader completes, I'd like to pass it through another function.[code]It seems like if the above function was my complete_handler but in the place of loader_names[k] would be the completed loader.
View 5 Replies
Nov 8, 2011
I have a loop which creates several TextFields in different positions[code]..
I have tried removeChild and setting the t.text to nothing, but this only affects the last created textfield
View 10 Replies
Nov 11, 2010
I am creating a loop which loadsimages to newly created loaders. After each loader completes, I'd like to pass it through another function Here's my loop of loaders where loader_names is an array of my loader names and overlay_files is an array of my file URLs
for (var j:int = 0; j < loader_names.length; j++) {
loader_names[j] = new Loader();
loader_names[j].contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
loader_names[j].load(new URLRequest(overlay_files[j]));
}
Once each image loads I want to overlay the image on a map here's a loop which does just that, only I do not know how to pass loaders into this function as they finish
function create_overlays(e:Event):void {
for (var k:int = 0; k < loader_names.length; k++) {
overlay_names[k] = new GroundOverlay(loader_names[k],
new LatLngBounds(new LatLng(46.669, -115.035), new LatLng(48.995,-112.079)));
}
}
View 1 Replies
Dec 2, 2010
I have a horizontal scroll bar that I need to appear to loop around continuously. I've managed to get it moving on its own since the last time I posted, however the loop is proving more difficult.
The move function is here:
Code:
public function movemouse() {
lst.onEnterFrame = function () {
var speed:Number = -1;
this._x += speed;
[Code].....
View 1 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
Jan 20, 2010
My code will:
- loop through the Grid array and place each tile on the stage
- assign RedBall a random Grid coordinate and places it on the stage at that coordinate
I want to be able to click RedBall, which will create a border around the tile beneath RedBall, and create borders around the tiles above, below, to the left and to the right. BUT, I don't want to reference the tiles by their distance in pixels from RedBall or from each other; I want to reference the tiles by their coordinates in the Grid array.So I want to:
- get the coordinates of RedBall
- use those same coodinates to reference the tile at the same coordinates in the Grid array
- use the tile's coordinates to reference the tiles above/below/left/right
- apply a border to all these tiles
What's the best way to reference an instance of a tile? Should I apply a name to each instance as it's created in the loop? like myTile.name = "tile"+i+"_"+j; ? If so, how do you reference that instance later? Just tile1_3 ? Do you have to prepend it with root, or stage, or the class it was originally created in? Do you have to use getChildByName? OR, can you still reference it later without having given it a name?
View 3 Replies
Nov 28, 2008
why this won't work?
Code:
var base:MovieClip = this;
// initiate
[code].....
View 1 Replies
Dec 25, 2009
I'v been toying with this for a few weeks now and I'm trying to find the best way to animate several instances of an object created by a for loop thru an ENTER_FRAME function.When the function runs only 1 of the 3 instances that were created animates.
var balloonArray:Array = new Array();var balloon: hotAirBalloon;var xVel: Number = -3;var yVel: Number = -4;
addEventListener(Event.ENTER_FRAME, startBalloons)
[code]....
View 9 Replies
Dec 8, 2011
I'm creating buttons like so:
for (k=0; k<5; k++) {
myLink = new LinkClass();
myLink.name = "link" + k;
box.boxMC.linksMC.addChild(myLink);
}
This creates 4 movieClips with the names "link0", "link1", etc. How do I remove them? I try this:
box.boxMC.linksMC.removeChild(myLink);
But it just removes the last one made (link3). How do I have all of them removed?
View 2 Replies
May 19, 2011
I want to remove an object that is created in a loop, with a timer.
var timer:Timer = new Timer(2000);
timer.addEventListener(TimerEvent.TIMER, voegtoe);
In function voegtoe I'm adding an Movieclip Object called man:
man.x=Math.random()*650;
man.y=Math.floor(Math.random()*(70))+350;
addChild(man);
I want to remove this object after 2 seconds. The problem is that there are multiple 'man' objects.
View 3 Replies
Nov 15, 2011
So I'm working on a Flash version of the old "Robots!" game. In case you're not familiar: the game lays out a number of robots on a grid (number varies by level), and drops the player in the middle. As the player moves around the grid, the robots all move towards the player one grid space per player move. The object is to destroy all the robots by making them run into each other (or the rubble left from previous collisions) without letting a robot run into you.
Anyway, my robot hordes are being created on the stage through a "for" loop, and each icon is a child of variable "evilBot" which references a library item with the class name "enemy."
ActionScript Code:
function placeBots():void{
for (var c = 0; c < numBots; c++){
evilBot = new enemy;
[Code]....
I've run a trace on "evilBot.name" and verified that the children are being given instance names of "evilBot0, evilBot1 ..." and so on. But no matter what I try, I can't issue instructions (regarding movement, orientation, etc) to individual children.
Using a for loop and "this["evilBot" + x]" returns a "term is undefined" error.
If I store the instance names in an array (named "botName") and use "evilBot.name[botName[x]]", I get the error "Property evilBot0 not found on String and there is no default value."
View 9 Replies
Sep 27, 2007
I have generated a series of buttons using this:
Code:
duplicateMovieClip(sign, "sign"+z, z)
while still inside the loop that is creating the buttons I can get to each sign:
[code].....
View 3 Replies
Aug 2, 2008
As the title suggests, I cant get function at end of the code to attach to each MovieClip I create dynamically within a loop.Only the last image will follow the mouse. What am I doing wrong? Im really not sure.
Code:
//now do something with the xml data
PopulateLists = function(final_array)
[code]....
View 4 Replies
Jun 3, 2009
I create some movieclips dynamically through a loop and store them into an array. I add an event listener to all those movieclips. In the function to which I direct the listener I want to be able to get the loop variable value associated with each movieclip. For example if you click the movieclip that was created the first time the loop ran then you would get the value 0.
Hope I have explained myself well enough. Is it necessary to create a custom event class for this?
[Code]....
View 3 Replies
Jun 23, 2010
I have an for each loop that creates a new textField for each item and I need to know how you can give each textField a unique name so it can be targeted later on.Here is the relevent code:
Code:
var i:int = 1;
for each (var titleElement:XML in titleList) {
[code].....
View 3 Replies
Jan 17, 2011
what is the syntax for assigning names to textfields created dynamically using a loop.
Code:
for (var i:uint=0; i<10; i++) {
var myText:TextField = new TextField();
myText.defaultTextFormat = textFormat;[code]....
As expected, this code gives me a warning "Duplicate variable definition".How can I assign names dynamically (myText1, myText2, myText3...)?
View 3 Replies
Dec 9, 2005
I've been staring at the screen too long and I'm sure the answer is simple but this has been bugging me for a bit now. I've created a grid with over 200 movie clips dynamically using a for loop. I was wondering if there was a way to assign rollovers and such to each new clip using the same loop.
I've been poking around with it a bit but can't seem to get it working and sure don't want to write over 200 rollover functions so any help would be great.
View 7 Replies
Dec 17, 2006
I thought this would be simple but for some reason I'm having all kinds of problems. Why won't the for loop create a new c instance each time the loop increments, like it does for sHolder and s? ...And, assuming it is possible to make it do this, how can each instance be given an identifier that can be accessed dynamically, like sHolder and s in the traceSomething function?
Code:
package {
import flash.display.Sprite;
import flash.geom.ColorTransform;
[Code]....
View 12 Replies