Flash - How To Loop Through Items In MovieClip In AS3
Aug 5, 2011I 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.
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.
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]....
im trying to do a for loop to load xml items into flash but im stuck,
[Code]....
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]...
Why does Flash still offer to declare library items as either MovieClip, Graphic or Button? Is this just for backwards compatibility or is there any reason not to use MovieClip for everything? (Well, Button does have some additional functionality, but what about Graphic? does a Graphic have any advantage over a MovieClip?)
View 1 RepliesI 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 RepliesWhat 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 RepliesI am trying to animate a navigation menu so that when you roll over an item (say "Contact Us"), it moves up a bit, and the rest of the items blur.
I allllmost have it working but there is one piece of code that is no longer working (blurTween.onMotionChanged) since I put it into a for each loop in order to go through the array and apply the blur filter to each item.
So my code is as follows:
Code:
import caurina.transitions.Tweener;
import flash.filters.BlurFilter;
import mx.transitions.Tween;
[Code].....
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 Repliesthere 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].....
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.
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));
}
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]...
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?
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 RepliesI 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]....
I'm trying to create a movieclip object that contains another movieclip that continuously loops. My current problem is, no matter what I try, the embedded movieclip will not play inside the one containing it. It would be significantly more work to design the looping animations in actionscript than through using the IDE, so I would prefer not to have to dynamically create these loops.
View 1 RepliesSo 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 RepliesI am trying to coding a part of a program which is creating different listener for the same object by using a for, but the problem is that the result for all of them is the same, In the following you can find my code:
for( var i:int=0;i<10;i++){
var obj = new MyClass();
obj.y = i*30;
[code]...
My goal of writing the code above is, by clicking on the first obj, the program writes 0 in output, by clicking on second one, writes 1 and so on, but this code give me 10 for all the objects.I should add that no matter there is an obj or not in myOtherMovieClip area, by clicking in that area, I got the same value.
So I know that if I want to create an instance of a movie clip called part01Roads from the library I do this:
Code:
var part01Roads_mc:part01Roads = new part01Roads();
addChild(part01Roads_mc);
part01Roads_mc.x = -22379;
part01Roads_mc.y = 317;
Well I want to take this one step further if it is at all possible. Lets say I have 100 different movie clips labeled in a sequence: part01Roads, part02Roads, part03Roads ..... part100Roads. Instead of rewriting the above code 100 times, can I make a loop to do this?
I have 35 movieclips, named s1, s2, s3 etc, depending on the value of currentDisplay, I would like to set a movieclip visible property to true while the others are set to false, I have tried the following:
Code:
for (i=1; i<36; i++){
trace(i);[code]....
but I receive an error message: 1083: Syntax error: dot is unexpected. I assume it is referring to the dot before visible.
I'm quitte new to the forum, so be gentle I'm making a Website, where the the menu will have a luminous movieclip which follows the menu items around and stays there. This is what I have so far:
[Code]...
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.
I have a movieclip, "holder", that has a lot of movieclips contained inside of it. I am trying to duplicate "holder", as well as all of the movieclips inside of it and create a 2nd movieclip called "holder2". Below is an example of the problem I am having. The movieclip "holder2" is created, but it does not duplicate the movieclip "box" that is inside of "holder". Is it possible to do this using duplicateMovieClip? If not, is there another way of accomplishing the same thing?
[Code]....
I have a vertical movieclip that has 20 graphic symbols that need to be dragged onto an area to the right on the stage.
The issue I am having is I need to make the movieclip scroll vertically. If I use the scrollpane component, the draggable items get masked and disapear when dragging them outside of the scrollpane component.
I tried using a custom scrollbar, though the draggable items that are dropped, are then scrolled vertically with the main movieclip...
I am making a navigation for a site, and the client wants a box behind a menu item to show that it is the active option. He wants that box to move to behind the new option when selected. So my navigation goes along the x axis; home contact about etc. Initially the box, which I have given the instance name 'tab' is behind 'home' as its the homepage.
So by clicking on say, the third option, the box will move from home to the third option, and say the user then clicks the second option, the box is to move to behind that. I got 4 navigation items, all are buttons, all on their own layer with the box being on its own layer too (obviously below the layers for the buttons so it appears behing the menu item).
I thought it would be quite simple, have some code which effectively says:
buttom1.on(release) {
tab.moveto(x value, 40);
}
I have a project underway where I am making an interactive game. It is a personal character creator game and I need Actionscript 3 help with this.Something similar here:http:[url]....
I have tried already with toggling visibility and 'gotoAndStop()' to make items appear over other items when the corresponding button is pressed, for example, when the user tries out different pants/shirts on their character.
I would like to use the selectionMode=multiple described in the Flex docs, but with a few modifications:
1) I would like the box that the user drags over the graph to remain there until the user drags a new one.
2) In the top right corner of the box I want to display the sum of the items selected by that box.
How to make list items as tool tips for combo box items?
View 2 RepliesI'm creating a facebook application in flex. I'm actually working on the friends component that shows your friends who are using the application. now, each friend has a profile image.
I created the component using a s:List element.
In the Skin Class of the element i configured the requestedColumnCount to 3, which means it shows 3 friends. i added buttons to scroll left and right in the list.
Whenever I scroll to see a different friend, for a half of a second i see no image because the List component is loading the image in order to view it.
is there a way to make the list preload all the elements so i won't have this kind of problem ?