ActionScript 2.0 :: AttachMovie In For Loop - Flash 8
Mar 24, 2008
I seem to be having a bit of trouble with my code- specifically the attachMovie line in the for loop below. I have a series of movieclips with identifiers named "loc_1", "loc_2", "loc_3" ... which are supposed to load inside the scrollPane which is located on the root timeline. I think I have the problem narrowed down to the first parameter in attachMovie : mcMain.attachMovie("loc_"+i, "loc_"+i, mcMain.getNextHighestDepth()); If I change it to "loc_1" instead of "loc_"+i, it loads the movie clip.... Here's what the AS looks like:
I am trying to create a pair of custom drop down menus (one for states, and then one for each states counties). I have an XML doc that contains all this info, which I am parsing out into an array(sc). What I would like to happen is when the user rolls over the states drop down arrow(stDropArrow_mc) that I run a for loop which attaches some movie clips to a states movie clip already on stage(states_mc), fills in the state name in a display text field(display_txt) within the attached movie, within the "states_mc" on stage(root timeline). so essentially(states_mc."NEW ATTACHED MOVIE CLIP NAME".display_txt.text) Here is a code sample that I am using...
i've got an attachMovie in a for loop, that creates a number of buttons, depending on how many names are in an array. as of right now i have the buttons created vertically, and im controlling the x value, like this:
i'd like to do two things that this won't let me do:
a. have more control over the Y coordinate, so when the loop starts i can say 'start making the buttons at x: 520, y: 350, instead of them just starting at y: 0 like they are now.
b. have a way to check if the amount of buttons reaches five in height, if so, the array starts a new column at x: 600 y: 350. im trying to have it do that about 3 times, as the amount of buttons will vary from 5-15.
Looking to convert the following attachMovie actions to a for loop. I get an error message running the following loop and I'm not sure what the correct syntax is. Takers?[code]
I am having a bit of a nightmare with a site i am trying to build at the moment and would be most grateful for any help. I have a menu bar which is made by looping through an array of the menu options (and submenus) and then attaching a menuitem movieclip in each case (then setting the text). The menuitem movieclip contains a dynamic text field and also actionscript to draw the background depending on the current settings (colour, border etc).I have a variable in my root fla file called menuwidth and this is used within the menuitem movieclip to define the width of the menuitem. When i set this to one value it works absolutely fine and creates the menus accordingly. i can change this to whatever size i want (including calculating the size of the largest option and then setting it to that, to ensure all options fit).
I have been trying to code it so that the menu options can be different sizes (in the event of a horizontal menu) so that you can have one that is wider than another. The code has become quite long (due to submenu and other functionality) but in a nutshell it is:[code]Instead when i use the code above all of the menuitem movieclips end up the same width as tthe final one (so if there are 5 menu options and the starting length is 50 then the ending length is 75 then all of the movieclips are 75 wide). When i try and debug it and check the value of _root.menuwidth inside the menuitem movieclip it states that it is set at 75 every time with no variation at all.It is almost as if it doesn't run the attach movie commands until the loop has finished, at which point all of them execute (and _root.menuwidth has already increased to it's highest possible value), but i can't see how this would make any sense.Obviously there are a number of other options that could be at fault, but i am trying to whittle it down and would be most grateful if anyone could explain to me if the above logic holds true and that increasing the _root.menuwidth value within the loop just before callin attachMovie should cause each one to be progressively bigger?
I have a menu bar which is made by looping through an array of the menu options (and submenus) and then attaching a menuitem movieclip in each case (then setting the text). The menuitem movieclip contains a dynamic text field and also actionscript to draw the background depending on the current settings (colour, border etc).
I have a variable in my root fla file called menuwidth and this is used within the menuitem movieclip to define the width of the menuitem. When i set this to one value it works absolutely fine and creates the menus accordingly. i can change this to whatever size i want (including calculating the size of the largest option and then setting it to that, to ensure all options fit). This works great.I have been trying to code it so that the menu options can be different sizes (in the event of a horizontal menu) so that you can have one that is wider than another. The code has become quite long (due to submenu and other functionality) but in a nutshell it is:
I have 3 buttons and when I click them the attach movies corresponding to them from the library should show up. Issue is with for loops. It stops at last number. What should I do or use for loop so that when I click my invisible buttons, movie corresponding to them show up? and only that movie show up, not anyone else.
buttonArray = [btn,btn1,btn2]; //mouse click button movieArray = ["mypopmc","mypopmc1","mypopmc2"]; //movie name; mArray1 = [mypop_mc,mypop_mc1,mypop_mc2,]; //movie instance name //dynamic text instance for 3 movies are y1,y2 and y3 for(n=0;n<buttonArray.length;n++) {
[Code]...
How could I create the for loop so that with every mouse click it shows the corresponding movie and text in it. It should show only 1 movie at a time with 1 mouse click on the invisible button (I meant corresponding movie).
I am trying to make the function below in AS3 and this attachMovie is throwing some good punches.As you can see i need to attach the "tile" in the scrClip but through a matrix. I've searched the whole web and i cant seem to find something similar for AS3.[code]
I'm trying to create a scroller menu. The container movieclip will hold several copies of a clip in the library. So I'm trying to create the clip dynamically since it's width will be varying depending on the number of elements it contains. But when I try to use the attachMovie method on my newly created empty movieclip, nothing shows up! The test_mc will attach if I just say _root.attachMovie, so I don't know if it's a path issue or if emptyMovieClips can't have other clips attached or what.
I am adding a bunch of MC's(linkage ID:buttonHolder) dynamically using a for loop and attachMovie. If I want to dynamically add an onRelease function to each of those MCs,so that each of them links to different links how would I accomplish that? here's where i've reached so far..
var depth:Number=0; var nextY:Number=77; for (i=0; i<5; i++)
Through attachMovie I have loaded an mc from the library onto the stage into "holder_mc".
myButton.onRelease = function () { if (currentWork != "holder_mc.myWork1_mc") { holder_mc.attachMovie("myWork_mc","myWork1_mc", getNextHighestDepth()); currentWork = "holder_mc.myWork1_mc"; } }
This works.
However, there are a couple of buttons (mc) inside "myWork1_mc" which skips through a few slides in the myWork1_mc clip that I cannot target. I thought using:
holder_mc.myWork1_mc.buttonName_mc.onRelease = function () { trace("MC_pressed"); }
... would work. My curser doesn't even change to the hand symbol. How do I target an dymanically loaded MC from the library which is inside an empty holder MC on the stage via attachMovie? What am i missing? Believe me, I have spent hours trying to google it.
Note: at this stage there is no other script on "holder_mc", but there will be at a later date, but I'll cross that bridge when I get to it. Also, the buttons work when I place the MC onto the stage and not use attachMovie.
i was wondering if it is possible to use attachMovie with variables using flashvars from html. im kind of new to AS and would like to know if anyone could help me out here
i need to make a single SWF in wich some movieclips can be replaced by others through the html code without editing the swf file.
i already know how to enter the variables on the html, but i dont know how to apply this to attachmovie command in the flash file.
So a clip is attached to a clip, and that works fine, but how do I get code on to the attached clip? I've tried duplicateMovieClip...but it's not working...
for (i=0; i<policy.length; i++) { newOpt = Stocklist_MC.attachMovie('Option', 'Option'+i, i);
I've got a ScrollPane on the root stage. This loads a MC called 'Stocklist_MC' (this also has a linkage/export name of 'Stocklist_MC'). When I try to use '.attachMovie' to the movieclip (Stocklist_MC) inside the ScrollPane nothing appears. All the AS is on frame 1 of root. Everything works when I use '.attachMovie' with _root. for (i=0; i<policy.length; i++) { newOpt = _root.attachMovie('Option', 'Option'+i, i); Also, if I drag Stocklist_MC to the stage I get everything working but list gets cut off at bottom, which is the reason why I need it in a scrollPane.
I've been battling this project, and finally got it all wrapped up and working, and was feeling pretty proud of myself, and then I went and posted the exact same .swf on the web and it doesn't work anymore.Specifically, there are a bunch of icons which are placed into the FloorMC which then attachMovie a copy of themselves into a LegendMC and UtilityRefMC, but they dont seem to be attaching anything when I run it through a browser.[URL](I'd love to attach the swf and fla to this message, so you could take a look at those, but apparently that would be crazy.) thought perhaps it had to do with me using _root, but I went through and changed them all out to _globals and _parents and it still no likey. Furthermore the Comment Box in the bottom left gets triggered by _root commands form all sorts of different levels, and it seems to work fine, both on the web and off.
What i am trying to attempt here is to make the variable equal to the name of an item in my library. (Im using this to use different ships in an old arcade-style vertical shooter). This is meant to make a ship appear on stage.
When <variable> is replaced with a library item (eg. mvcShip), it works fine, but if the variable is in place, i get a trace value of ship1 as "undefined", and the ship doesnt show up on the stage.
I have a linked movieClip in my library with the identifier "arrow" i want to run a for loop and attach this clip to movie clips on my stage named blank0 blank1 blakn2 and so on.
When you attach a movieclip taken from the symbol library to the Stage, by using the attachMovie function and its Linkage name, do you have to - previously - place a dummy instance of the mc anywhere on that Stage to get it works ?
I am trying to revise the very first flash project I ever did and it's become a complicated mess. I have created an interactive atlas. I am using my favorite map zooming and panning tools supplied by Senocular which can be found here: http:[url].....For the panning/zooming/drawBox tool to work the map features must be buried deep within several movieclips. There is one level at which you can put buttons that aren't effected by the code for the panning/zooming etc. Buttons have to go on this level or higher if you want them to work.
The way my atlas is set up - there is a main interface that has these tools plus the menu system. The menu (xml; created by Lost and Sen - brilliant, thank you) loads in two external swfs - one is the map itself and the other is a set of "controls" for that particular map (radio buttons, check boxes, text links, etc.).I have a couple of external swfs that have buttons on them that do things when you roll over and off them. If I have these buttons sitting on the map then when it gets loaded into the main interface they no longer work. So I am trying to use attachMovie to attach them to an MC within the zooming tools in the main interface at a level they can be active.But it's not working.I am guessing it's because the code to attach them is being fired before the external can be loaded into the interface. So I'm not really sure where to fire the attachMovie code. Does it go with the external? Does it go with the controls for the external?
I can supply code if needed though like I said, this file is a mess. There are 15 external maps with 15 "control" files. Plus the main interface, plus some other miscellaneous files.
I have a loop and in it i am attaching a movie clip (basiccly its just a row with data). The movieclip has a alpha fade in it. Now I want to delay each attachmovie function so that the movies are attached one by one rather then trow them all on the screen at once. (plus it looks better with the alpha fade).
I tried the setInterval but it wont work (ex.:Interval is 1 sec, and if im going to attach 6 MC, flash wait 6 * 1 sec, then show them all)
And is it possible to attach a movieclip inside a othermovieclip thats not on the same frame (the other MC is on frame 10)?
I want to attach a MC dynamically so that I have 12 rows and 12 columns of _mc box on the main stage:[code]I think it can be done only with a nested loop but so far, well, my head's in a loop!
I want to attach a preloader to the main stage of my site to load in external JPEGS and SWF's and to do this I need to pass certain parameters to my preloader, such as the preloaders width and height. How do I make use of the initObject parameter for attachMovie()? I know I need to either define a constructor or somehow access the current movieClip's constructor, but I have no want to create a custom class for my preloader movieclip, I just want to be able to get certain information when I attach the preloader. Do I really need to create a custom class that inherits from movieClip?
Is there a way to link duplicated movieclips to the library? Because I need to attach these duplicated mc's to an other mc. So my problem is that I don't have a linkage identifier?
Is there an alternative to attachMovie that I can use to put my movieclips on to the stage. Here is my problem, I have 2 frames total in my fla file, and in each frame I have buttons that when you click on them it attaches the corresponding image from the library. Problem is when you click to go to the next frame, the attached image stays.
I basically want it to stay attached only until you hit the next frame.