ActionScript 3.0 :: How To Target MovieClip Inside Each Item In Array
Apr 2, 2009
How can I target a movieclip that is inside each item in the array using getChildByName. Heres my code so far:
var aMC:Array=new Array(letter, envelope, parcel);
if(i< aMC.length){
var myTargetName:String = aMC[i].target.name;
var myTarget:DisplayObject = getChildByName(myTargetName);
trace("Stamps Target: "+myTargetName);
if (evt.target.dropTarget != null && evt.target.dropTarget == myTarget) {
// do what ever here
i++;
}}
I've a main movie with a container movieclip to load an external swf file. That's working fine but I want to control the movieclips of externally loaded movie. I tried the below method but not work out. Script on the main movie _root.holder.loadMovie ("1.swf", mytarget); // This is working fine _root.holder.mytarget.<movieclipname of the externally loaded movie>.onRelease= function (){ // Do something. } But the above script not worked out.
I'm trying to reference a specific frame inside a MC in my .swf file from an .as file. What I want is to capture the current frame of the movie clip for the .as file. It's for the purpose of points when you shoot each plane. It's an easy trick of frame 1's plane would be worth 100 points, frame 2's plane 200 points, etc. I thought I'd write a line like this in my collision detection section of my .as file.
Code: planePoints = currentFrame * 100;
The only problem is, of course, it grabs the current frame of the main .swf timeline that my flash file uses, and not the movieclip that's being called to produce the planes. So I thought I'd be able to specify a path to the movie clip (in this case it's called Airplane in the MC's linkage properties).
Code: planePoints = Airplane.currentFrame * 100; Then, of course, it freaks out and says that 'access of possibly undefined property currentFrame through a reference with static type Class.'
I still get confused with AS3 and the way items are handled vs AS2. I've lost track of how many times I type _root. Am I getting something basic mucked up here or should I be importing something in the package to get it to recognize the class?
I have an xml file that I pull values out of and push into an array. I want to use a value from the array as the name of a movieclip but I keep getting the following error.[code]...
I have what I think should be a very simple problem. I have an array and can access an element of it like this:
var test = finalArray[0]; Will be a number between 1 and 7
say this will trace a number.No there is a movieclip on the root of stage whose name is a letter (always the same, say "R") and whatever the number is. I'm trying to get this movieclip to gotoAndStop at the frame corresponding to the number that is test. However this isn't working:
i have dynamic buttons in movieclip and i want the movieclip goto 2nd frame once some one click single movieclip while rest remains in 1st frame.the movieclips can be in arrayi have some code here:
Actionscript Code: var mc:MovieClip = new MovieClip();for(var i:int = 0 ; i < numberOfButtons;i++){ var btn:MovieClip = new button();
ActionScript Code: var myArray:Array = new Array(); for(var i=0; i<10; i++){ var p:Particle = new Particle();
[Code]....
I have this array of particles and I was wondering how can I add this particles inside a movieClip, in other words I would like to add particle "p" to a movieClip that I have on the stage with an instance name of "mainMC".
Also, is it possible to display the number of particles (p) inside mainMC in a text field? On this case I know it will be 10, but this will change.
I am making a profile sort of thing, basically what happens is: You start the program... it loops, and generates 500 text fields, it stores them in an array called profile_name[]; it names them "Profile + (i+1) (i being the var used in the loop). Changes the colour to yellow, changes the size to 13. Removes the border from it and makes it unselectable (the text). It then converts the text into a movie clip (as if you made a dynamic text area, on the stage, and clicked it, and pressed f8, and converted to mc). It stores that in an array called profile_mcs[]. I need a way to access the text inside the movie clip in both they're arrays...
Example If you go to your flash stage, make some dynamic text, call it "ptxt1", you make it unselectable, remove any border if it has one... you name the text "test", you select it, press f8, then convert to a movie clip called "test_text" you name it "pbtn1" (the instance name I mean, when I say name) If you go to the first frame of your main timeline and press f9 (action script section) type pbtn1.test.text = "NEW TEXT", it will name the text "test" inside the mc "pbtn1" to NEW TEXT...
However, if you store them into an array (both text and mc) you can no longer reference them like this: MyMC_Array[0].MYText_Array[0].text = "NEW TEXT", It doesn't show up, and making 500 if statements is to much (I think my problem may be when I traced my dynamic text inside the movie clip (that I've made on the stage) it appears as undefined.
Code: var profile_name:Array (my text var) = [ptxt1, ptxt2, ptxt3, etc..]; I've tried doing Code: var profile_name:Array = [pbtn1.ptxt1, pbtn2.ptxt2]; etc.. None works,
I need to create an array inside a movieclip, so: var Container:MovieClip = new Movieclip; Then how do I make an array inside of the that movieclip. I've tried Container.mCONTENT:Array = []; But I get "Label must be a simple identifier"
I'm creating a drag and drop Flash activity where there is 1 target and multiple draggable items. In my case I have 4 apples and I want to be able to put all apples into the same basket. I can get the draggable item into one target but i cannot get multiple draggable items into one single target.[code]
I put my mc's in an array.I have another array with strings.when the mc is clicked I want to get its position in the mc array and return the string from the same position in the string array.How do I do that?
PHP Code: var numBtnArray:Array = new Array; function addNumButtonsToStage():void{
I know how to remove duplicates from an array, but what I'm trying to do is prevent an item from ever being added to an array in the first place if it already exists. I'm pulling in data from an xml feed in a loop, and I thought that searching for that values index would work, but no matter what, the index is always -1. Here's my code:
[Code]...
Maybe I'm misunderstanding the indexOf function, but I thought it was supposed to return -1 if a value did not exist in an array. What am I doing wrong?
var profileholder:profileHolder=new profileHolder ;
inside of profileholder is another movieclip(infoBtn) that acts as a button.when the mouse is over profileholder i want to do something with infoBtn like:
//profOver is the over state of profileholder function profOver(e:Event) { e.target.infoBtn.alpha=1; }
this doesn't work and brings up this error:ReferenceError: Error #1069: Property infoBtn not found on flash.display.Loader and there is no default value. at main_fla::MainTimeline/profOver()
i also tried: function profOver(e:Event) { var item:profileHolder=e.target as profileHolder; item.infoBtn.alpha=1; }
and get this error:TypeError: Error #1009: Cannot access a property or method of a null object reference.
I have this code to try to acess the values of the array in the arraycollection but it does not work it actually creates a value to the end of the arraycollection. can anyone tell me what im doing wrong i basically whant to modifys the individual arrays in the arraycollection and add Login_user.
I haven't found my answer with a search of the forum, sorry if this is a redundant question. I am having problems with targeting a MovieClip that is inside another Movie Clip that is placed on stage from the Library using the addChild(); method. This is my code for creating the MC instance on stage:
var pMenuSlide:plusMenuSlide = new plusMenuSlide(); addChild(pMenuSlide);
Now, inside of pMenuSlide there is a MC called cloze, how do I target this MC? This does not work: var pMenuCloze:MovieClip = Object(root).pMenuSlide.cloze
I'm migrating from as2 to as3 and have a problem. I have a movieclip called papel_ilus which has loaded images inside with text and stuff. I found a Drag And Drop code that constrains the movement of the _x axis and have targeted the papel_ilus movieclip. However, when I click the images inside they are dragged separately from the whole movieclip I targeted and everything is a mess. Is there a way to drag the whole "pack" as one? Here is the code I'm using:
Code: import flash.geom.Rectangle; var leftY:int = 0;
When I load a .swf into a target movie that I have on my main page, it is all wrong, the slider menu that I have loading into the target movie, does not stay inside target and it seems to reposition the slider menu to the x psotion of my main movie How can I fix this, so the slider menu in the swf stays inside the target movie when loaded? FLA file is too large to attach, if needed I can attach it in pieces.
And , as u can probably see, it's a menu with 3 buttons, and the middle one is supposed to have a submenu.I am looping through the menu items and it displays everything alright:
ActionScript Code: var xml:XML = new XML(); var total:Number;[code]..........
What i can't figure out is the piece of code needed to count the nodes inside the <item> tag.
Trying to target a button inside a mc in order to trigger a swf. The swf has the same name as the listener in order to repeat the function with multiple swfs. my problem is, i'm getting an error of an Access of undefined property with my mc I geting an error:"
When code changes for allItems the item disapears from screen as expected but still sits in memory! I know this by a function inside a compoenent that has "trace" so the trace output still displays even after the component disappears from screen. How do I ensure that the element is deleted when it's reference is deleted? Will using List-based component to display items instead of "Repeator" solve the problem (it requires significant refactoring of my code so I'm asking before trying it out)
I'm doing a project that makes a movieclip draggable in different droptarget movieclip. When it is dragged in the 1st target an animation is triggered and so as the rest of the droptargets.Here's my initial code that does'nt work:
I have an Item Renderer having HBox. Now I want to add child in that HBox from my application file using addChild method. Any way around for the same. I am not able to access the properties of HBox inside the item renderer.
When I load a .swf into a target movie that I have on my main page, it is all wrong, the slider menu that I have loading into the target movie, does not stay inside target and it seems to reposition the slider menu to the x psotion of my main movie How can I fix this, so the slider menu in the swf stays inside the target movie when loaded?
FLA file is too large to attach, if needed I can attach it in pieces.