ActionScript 3.0 :: Dynamic Create Items With For Loop

Jan 30, 2007

Well, i have this line of code

Code:
var t1:thumbBack = addChild(new thumbBack(x, y));

And i want to create many thumbBacks with names t1, t2, t3... with a for loop.

I tried something like this, but it doesnt seem to work

Code:
for(i=0; i<8; i++){
var this["t"+i]:thumbBack = addChild(new thumbBack(10 + i*200 , y));
}

View 1 Replies


Similar Posts:


ActionScript 3.0 :: Count The Amount Of Items In The XML File And Then Create A For-each Loop

Sep 24, 2009

I have 10 dynamic text fields inside a movieclip, which are populated via an XML file. However, the xml file sometimes has less than 10 items. It never has more than 10. This results in the following error, which is normal. I need the code to count the amount of items in the XML file and then create a for-each loop. I can visualize it, but I don't know how to write it. Basically what I need the code below transformed in to is this... (notice the #'s)

[Code]....

View 3 Replies

Actionscript 2 :: Create Dynamic Textfields In A Loop?

Aug 12, 2010

I want to populate the stage with a list of dynamic text fields with individual names, something like pg4_txt1, pg4_txt2, pg4_txt3. I'm a novice at flash, I tried creating variables with a while loop, but I just haven't got the grasp of it.

Here's some kind of weird pseudo code to explain what I want to do:

var leading:Number = 15;
var i:Number = 0;
while (i<14) {

[Code].....

View 1 Replies

Actionscript 3 :: Create Multiple Dynamic Objects In Flash With Loop?

Jul 5, 2011

I'm attempting to create a graphical representation of the microphone activity in flash for a conference.

I got a movieclip called eqNotch that's just a rectangle and its linkage name is EqNotch.I also have a movieclip where I am writing my as3 on the first frame, its called dynamicBar and linkage name is DynamicBar.

I've successfully written the code for the dynamicBar to create one column of eqNotches and the number of rows is dependent on mic activity.[code]...

View 2 Replies

ActionScript 3.0 :: Flash - Creating A For Loop To Create Dynamic Variables?

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

Flash - How To Loop Through Items In MovieClip In AS3

Aug 5, 2011

I am trying to do this in as3
for (var i = 0; i < 8; i++) {
var clip = "markerMC" + i;
this.scoreGridMC[clip]._visible = false;
}
But I get compile errors all the time.

View 1 Replies

ActionScript 3.0 :: Loop Through Library Items?

May 21, 2010

I was wondering if you could loop through your library or a specific folder in your library and get alle linkage names of items that have 'Export for Actionscript' checked. I have an amount of items in my library of which I want to random pick one. Of course I could just use an array of linkage names that correspond to my library items, but I was wondering if there is a more efficient way.

View 2 Replies

ActionScript 2.0 :: Add Loop Items To Array

Jun 5, 2005

What I've got is a menu that loads images as buttons. It will only display menu items that are within a certain group (i.e. if themenuitem.node Value == groupid[q] then it will display that menu item. Each of the menu items has a unique number (Itemnumber[n]). I have a loop that goes through and displays the menu items that are within a certain group. I am currently able to also find out the unique number of each of the menu items where themenuitem.nodeValue == groupid[q], but what I want to do with these numbers, is place them all into an array as it loops through.So, say for example, it finds an item in the loop. It tells me this item is number 4 (if I tell it to trace(Itemnumber[n]) within the loop). Then, it finds another item in the loop, and it tells me this item number is 6. I want to be able to add items to an array as it loops through, so I'll have an array at the end like this: (4, 6).Currently my ActionScript looks like the following. Never mind if there are variables that are not defined in there -- they have been defined in other parts of my movie.[code]As you can see, I've made an attept at achieving this by trying numarray[numarraylength] = n; -- but all this does is send me an array, then overwrite it next time it loops (so I get an array like (4, 4), then one like (6, 6). I've added comments in the code to further explain what I'm trying to do.

View 2 Replies

ActionScript 3.0 :: Removing Items From Memory Using Loop?

Feb 18, 2009

The following for loop removes children from their parent if they're in the display list. It works correctly, but I also want to remove each child from memory with the same loop.

View 1 Replies

ActionScript 3.0 :: Add Addlistener For 11 Items Through Single Loop?

Jun 25, 2009

there are 11 buttons in my stage which is called button0,button1,....button10, i want add addlistener for all buttons through a single loop. here i have attached my code,But its not working.What is the mistake.

ActionScript Code:
var count:Number = 11;
var temp:MovieClip = new MovieClip();

[Code].....

View 6 Replies

ActionScript 3.0 :: Accessing Items Created In Loop?

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

Actionscript 2.0 :: Loop To Load Xml Items Into Flash?

Sep 3, 2009

im trying to do a for loop to load xml items into flash but im stuck,

[Code]....

View 1 Replies

ActionScript 3.0 :: Using A Loop To Dynamically Alter Items

Mar 5, 2009

Basically I have five mcs on the stage, MC1, MC2, MC3, MC4, MC5, and I would like to change the alpha, for example, each time I click on nextBtn. I would control the number of mcs but altering the if (j <= 4){ line.

[Code]...

View 3 Replies

ActionScript 3.0 :: Removing Items From An Array In For Loop?

Dec 9, 2009

I could pop, shift, splice or slice it out of there (hey, that had a nice ring to it...)

how to properly remove items from an array while in the middle of a for loop:

Code:
//This will cause errors, because if the condition is met, it will skip the next array in line
for (var i:int = 0; i < arr.length; i++)

[Code].....

If someone is reading through my code, will they understand what I am doing without me having to clarify with comments each time?

View 4 Replies

ActionScript 3.0 :: Add String In Array Items With Loop

Jan 17, 2011

So, I have an application where flash receives this string:'mp3, pdf, doc'using .split(), i managed to separate the values in an array.I need to add a "*." on each item of the array. i used for, but the result is always the last one. How do i manage to add the "*." string on all items of an array and display them on a dynamic textfield?[code]

View 12 Replies

ActionScript 3.0 :: Create A Loop So Icons In Menu Continually Loop Indefinitely

Apr 16, 2010

I would like to create a loop so the icons in the menu continually loop indefinitly.[code]

View 2 Replies

ActionScript 3.0 :: Use A Loop To Create Text Field With The Loop's Current Value

Dec 11, 2010

I am attempting to use a loop to create text field with the loop's current value. The code looks like this:

ActionScript Code:
for (var i = 1; i<=10; i++) {
var 'nameHolder'+[i]+'_txt':TLFTextField = new TLFTextField();
'nameHolder'+[i]+'_txt'.x = 40
'nameHolder'+[i]+'_txt'.y = 40
'nameHolder'+[i]+'_txt'.text = "Hello World"
}

So essentially what it should do is create 10 text fields at 40, 40 with the text: "Hello World".

View 7 Replies

ActionScript 3.0 :: XML To Flash - Loop Through The Items And Display Each In A Single Text Field

Aug 16, 2010

just trace out the data within the "item tag" below. I can trace out the three at the top but can't get into the items. Having it nested like this is giving me problems. I would really like it to loop through the items and display each in a single text field.

[Code]...

View 4 Replies

ActionScript 3.0 :: Resetting Items In My Loop - Get TypeError : Error #1010: A Term Is Undefined And Has No Properties?

Apr 4, 2011

So i have my items that I bring onto stage with my loop function with dynamic text fields within the loop. If I want to clear these items using a reset button on the stage how can I do this. From my code below when I press the reset button I receive: TypeError: Error #1010: A term is undefined and has no properties.So a little snippet of my code just to give an idea what I use to bring items to stage and what Im trying to use to reset[code]....

View 4 Replies

ActionScript 3.0 :: AddChild For Loop - Display Items On The Stage Nested Inside A Movieclip Called MainItem

Mar 31, 2011

I have a MovieClip called item with the same linkage set and my first task is to display 10 of these items on the stage nested inside a movieclip called MainItem. I have dragged MainItem to the stage and have the following for loop:

[Code]....

View 5 Replies

ActionScript 2.0 :: Create Multiple Items Behind Ui?

Aug 5, 2009

What I'm trying to do is have multiple items appear and go behind the ui with the next one coming under previous one also.

View 0 Replies

ActionScript 3.0 :: Create An Colliding Items?

May 13, 2011

How can I create the objects which push eachother?

View 2 Replies

Flex :: Access Items By Their ID If Create Them Dynamically

Feb 8, 2010

In one area of my application I am creating a display that builds itself with actionscript during a loop. (in my actual app there are A LOT of nested children and my function might be looking for any of those children) In that AS I assign each item an ID, but when I try to access that item by it's id it fails. What gives? and how can I accomplish finding a UI component without having to go through knowing all of it's possible parents? [code]

View 1 Replies

ActionScript 2.0 :: Create Clickable Items In Another Object?

Jul 6, 2010

Alright I'm pretty sure I know what my problem is, but not sure how to fix it. I created a 50x50 grid of objects I want to be individually clickable using the following code to generate them:

[Code]...

I'm assuming this should work except for one issue, the above code is within another object that I have set to be able to clickdrag (so you can drag the whole map at once). Because of this, using "this.onMouseDown" seems to apply to the entire mapObject and gets the depth for each of the 2,000 some odd objects I've created. How do I set it up so that if I click on a nodeObject it gets the depth for just that and assigns it to a variable?

View 1 Replies

ActionScript 3.0 :: Dynamic Load Of Library Items

Aug 24, 2009

I have a couple of movieclips in my library (there's 52 of them actually, I'm making a card game. ) and I have them exported for actionscript through the property menu.Is it possible to load them by passing a variable with the name of the movieclip class?[code]

View 2 Replies

ActionScript 3.0 :: Dynamic Referencing Of Items Within MovieClip?

Feb 19, 2010

I am building a drag and drop application. I have a few items within a movie clip that are movie clips. They each have their own instance name.

I am trying to access them from the document class using 'event.target.name'.

That works and I can pick up the name of the movieclip.

I put it in a string var called tName.

Then I try to modify a property of the selected movieclip:

itemList.items.tName.x+=23;

thats when i get, 'A term is undefined and has no properties' error.

I know itemList.items.tName is the correct navigation to the clip, because if i replace the var and hard code the correct name, it works.

whats funny is my tName var is tracing out the correct name of the movieclip.

Or a better way to dynamically access mc's within mc's.

View 1 Replies

ActionScript 2.0 :: AttachMovie Of Dynamic Created Items In MX?

Feb 23, 2004

What I want is the following. Based on an XML file and one empty movie clip, I create about 80 different items (menu items). By drag and dropping these menu items you can create a scene with objects. These objects are copies of the menu items.But I want to use the attachMovie command to have control over the path of the objects. But by creating the menu items dynamically, I cannot say in the library, export for actionscript.So my question is, how can I use the attachMovie command on items that are dynamically created.

View 6 Replies

ActionScript 3.0 :: Create Drag/drop Shifting Items?

Jan 19, 2010

What would be a good way to create a grid of images in which one can be dragged to a new position and the other images will shift to make room for the image dragged? Looking at making a little program that will reorder an XML file by visually dragging the items to where I want them.

View 0 Replies

ActionScript 3.0 :: Where To Create Array Of Items (Which Class File)

Jan 25, 2012

This is a hard question to phrase and having trouble finding the right search terms. In the last couple of weeks I have been learning AS 3.0 and the fantastic Classes that are cool as heck (not a programmer... well sort of). Everything has been working great and I've grasped the concepts well, but because of my lack of experience I am not sure of the "best" way to do some things. For example where (which "as file" to create an array of characters?)

This is a very simple game:
25 "characters" (character class in Character.as)
All characters have the exact same properties with different values:
charName:int
life:int
strength:int
movement:int
type:String
char_mc:MovieClip (or sprite.. probably mc)

There are 2 types of characters; shipCrew and aliens. The differences between the two is that shipCrew can use various weapons and have unique "names". Aliens don't have names, just a type and they can grow and/or multiply. All of the interaction and basic game play I can handle no problem once I figure out "where" to create my characters and classes and or subclasses. My initial "training experiments" worked well... until I started reading up on "best practices" in coding and realized I had it kind of all mixed up and backwards. My concern is "doing it wrong at the start".

My first stab at this was to create the array of ALL characters in the "main.as" class for the document, then looping the array, creating new character instances on the stage. Since each character has different properties I just created the same array properties for each with a different value. So basically I am "hard coding" all the characters up front "by hand" so to speak with all the properties in the array. Since they were all identical basically, looping the array to "do stuff" was straight forward... for now. The array looks horrible in the code and is hard to "read" but since it's all "static" anyway it doesn't seem to matter... but would still like to "do it right".

Game play is simple because at a basic level each character regardless of what type it is will do the same thing. I would expand on the differences later. However as part of this inquiry I will need class instances on the stage to communicate with each other (like the idea of a registry for this). So my questions are:
Should I create individual as class files for all 25 characters? (icky?)
Or use an array to store the character class objects? A dictionary? A vector?

They all worked, I tried them all. I like arrays better because easier to deal with, but dictionaries look like fun and might be more efficient (only 25 items, how bad could it be?) storing in an object works too. Whatever type of "array thingy" I choose, Which class file do I create the array in? In the "main" document class or the character class itself? In another type of file like an "init" file? Could I create a "custom" file "type" or class... thingy like "CharacterCreator.as"? How about using a registry?

View 5 Replies

ActionScript 3.0 :: Adding Event Listeners To Dynamic Lib Items?

May 24, 2010

What I want to do is be able to click a button that adds an Item to the stage and then you are able to drag the item around on the stage. I know how to do these things separately as in if the item is already on the stage I know how to add the code to drag it and I know how to create a button that brings a library item on the stage. How would I combine the two?

View 7 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved