ActionScript 3.0 :: Referencing Movieclip In Array

Jun 13, 2011

Just learning as3. For testing purposes, I duplicated a movieclip 4 times on the stage and gave each mc a different instance name and put them in an array ("line1","line2","line3","line4"). Then I just want one movieclip to move 200 pixels based on the conditions of the array. Here is the code:

var stuff:Array = new Array("line1","line2","line3","line4");
for(var i:int=0;i<stuff.length;i++)
{
if ((stuff[i]) == "line4") {
trace(stuff[i]);
var duke = (stuff[i]);
[duke]y += 200;
}
}

It traces out the correct mc (line4) but ALL the movieclips move 200 pixels instead of the one (line4). Do you know why this is? I have a feeling that [duke]y is not the correct way to reference the movieclip.

View 2 Replies


Similar Posts:


ActionScript 2.0 :: Referencing MovieClip Properties From An Array?

Mar 20, 2007

Code:
container_mc = _root.createEmptyMovieClip ("Page_Container_mc",100);
pageContent = new Array ();

[code].....

View 3 Replies

ActionScript 2.0 :: Dynamic MovieClip Referencing Using Array Notation

Feb 23, 2009

I know that a dynamic mc can be referenced using array notation
viz: myArray['someName'+i]
My question is ... can mcs that have been placed on the stage and given instance names be referenced in some similar way? If I have placed 10 mc's with different instance names eg mg1, mg2, mg3 etc, can I reference them using array referencing?

View 6 Replies

ActionScript 3.0 :: Flash - Referencing A Movieclip In An Array And Calling A Method?

Nov 12, 2010

Is it possible to refference a movieclip in an array and then calling a methodfor ex.The movieclip i want to refference: main.box.mymovieclip

var current:array = new array();
push(main.box.mymovieclip);
and then like calling a method on it:

[code].....

View 1 Replies

Flash :: Referencing Mc's From An Array To Then Assign Further Array Properties?

Oct 15, 2010

I have a number of 'items' (mc's) contained in a scrolling mc that can be drag-dropped to other matching mc's. The items names are listed in an array and I wish to assign variables of suitability and feedback to each mc from the array also. I think this is called an associative array?

Having some trouble correctly referencing the items from the array. To explain, here's a working script with a simple array and an inefficient workaround:

[Code]...

View 4 Replies

ActionScript 3.0 :: Referencing Loaders In An Array?

Jun 28, 2010

I have a project that needs 4 levels of zoom, each with its own image loading in. So, to make things easier on myself, I made an array of the Loaders, so I can instantiate them and hide/display them when I need toHowever, this doesn't work as I had expected. I.e. (using just two level for simplicity):

Code:
private var photo:Loader;
private var photoLarge:Loader;

[code].....

View 4 Replies

ActionScript 3.0 :: Referencing Array Element By Name?

Mar 9, 2009

I've got an array containing various sprites... I'm wanting to reference the sprite I want by its name rather than its index in the array, and was wondering if theres a simple way of doing this? I know I could do a for loop through all the array elements and see which one has a name that is equal to the name im looking for, but is something along the lines of myArray[elementName] possible?

View 5 Replies

ActionScript 3.0 :: Referencing Objects In Array?

Feb 25, 2010

I've created a for loop to do the following:add instances of button MovieClip from library to stagename the instances via name propertyadd instance names to array for later referenceadd event listenershese 4 steps are working peachy, however, I'm having troubles referencing these instances later on through my code. I'm pretty sure that the problem is in my data types not matching, but I'm not sure how to fix it.

var menuBtn:mc_menuBtn;var menuBtnList:Array = new Array();
for(var b:int = 0; b < numFiles; b++){  //add instances to stage  menuBtn = new mc_menuBtn();  testClip.addChild(menuBtn); //adding button instances to

[code].....

View 5 Replies

ActionScript 2.0 :: Referencing An Object In Array?

Nov 3, 2009

I was wondering if anyone could tell me how to access a certain object in an array. for example, I created an array of buttons displayed on the stage. Now I need to attach an onRelease command to each one to launch a new image on the stage.e going round in circles with this. I have attached the code below for reference:

thumArray = [];
function thumbs(){
for (i=0; i<totalImages; i++) {

[code].....

View 1 Replies

ActionScript 2.0 :: Referencing Array Index?

Aug 25, 2011

I have three placeholder images, the contents of which are populated by an array ("galleryArray").These three placeholders are titled "placeholderLeft", "placeholderCentre" and "placeholderRight".

the contents of "placeholderLeft" will be: "galleryArray[n-1]"
the contents of "placeholderCentre" will be: "galleryArray[n]"
the contents of "placeholderRight" will be: "galleryArray[n+1]"

[code]...

View 6 Replies

ActionScript 2.0 :: Referencing To Array In Parent?

Jan 4, 2007

I have an array defined in the main timeline to store some values. At some point of time, I am dynamically adding a movieclip to stage using attachMovie and then using a movieClip.onEnterFrame event to set one of its values by referencing to one value from the main array.(Sorry if the following description sounds a bit confusing. I am attaching a part of the code below to help describe the situation) The problem is that it is not able to retrieve the value from the main array no matter what I try. I tried adding a "_root" befor the array name and the index array id but it did not work. Not only that but the trace shows that it is able to retrieve the index id as well as the full array but not any particular value from the array - as in, trace(arrayname) outputs all the values from that array but trace(arrayname[a][b][c]) gives an output 'undefined'.

I have managed to make it work by creating a temporary variable to store that particular value just before the onEnterFrame event kicks in, but I would love to know why it is not working the way I thought it should. Here is a part of the code. If someone needs more info about the code then please ask and I will give it in the next post (The full code is way too large to be posted here)

ActionScript Code:
//------In main timeline
var movesNum:Number = 0;

[code].....

View 3 Replies

ActionScript 2.0 :: Referencing An Array Value Globally XML?

Mar 2, 2007

I have been trying to get this right for a few days now, but I am stumped. This code runs on the first frame of my movie:

Code:
_global.headingText = new Array();
_global.captionText = new Array();
_global.contentText = new Array();

[Code].....

View 1 Replies

ActionScript 3.0 :: Referencing From An Object Within An Array?

Oct 16, 2011

I have a several objects nested within an array. I'm trying to reference a property of one specific object (intel).

function eventGenerator():void
{
var randomArea:Number;
randomArea = Math.ceil(Math.random()*5);

[Code].....

ainPlace names is the array's name. The random area variable contains the co ordinate on the array for the object. Each object on the array has a property called intel. The idea is I want to able to store the value of intel in a number and use in an equation. I would also like to be able to adjust the number. the trace function here returns an error saying it is undefined so eventArea.intel for some reason isn't referencing the intel property of the object.

View 3 Replies

ActionScript 2.0 :: Array Name Referencing With A Variable?

May 2, 2005

fairly simple question (with a long explaination). I have an array, created from the results of another array and it's position in that array. There are actually multiple arrays It can be created from.

Eg.
Array1: clientName1, clientName2, etc.
Array2: clientType1, clientType2, etc.
Second Array: [clientName1,0], [clientName2,1] OR [clientType1,0] etc.

[Code]...

My issue is, I would like to be able to dynamically adjust the array that it is generating from. This would mean changing the bold bit of the code above. I have tried declaring a variable (type = names+"[i]") and using it in the linkArray declaration, however it will not see this as an array reference, only as a variable. What I want to know is, how do I reference the name of the original array as a variable so I can update it dynamically?

View 5 Replies

ActionScript 2.0 :: Referencing A Movieclip Within An Attached Movieclip?

Nov 29, 2006

I am trying to reference a movieclip within a movieclip that I am loading using "attachmovie". In the first frame of the root, I am attaching the movie. Then, from the attached movie I am calling a function that is also in the first frame of the root. In the function I am tring to set the property of a clip within the attached movie to visible using the following code:

_root.logIn.loginMessage._visible = true;

I have also tried _root["logIn"].loginMessage._visible = true; with no luck.

(logIn is the name of the clip I am attaching using attachMovie and loginMessage is the clip I am trying to reference in the attached movie)

This is how I'm loading it and I know that part is working: _root.attachMovie("login_mc","logIn",getNextHighes tDepth());

View 1 Replies

ActionScript 3.0 :: Referencing Array / Main Timeline

Dec 23, 2009

This used to work in flash 8.I just purchased CS4 and am trying to learn a few basics.I have nested arrays on frame 2 of the main timeline. [code]I can no longer use _root. on the mc to reference the main timeline.If I trace myQuestions from the mc I get an error.

View 14 Replies

ActionScript 3.0 :: Referencing Embedded Sounds In An Array?

Dec 30, 2009

I want to play an embedded sound referenced from an array.In flash 8 I would simply use this code.Quote:

var mySound = new Sound();
mySound.attachSound(myArray[0][8]);
mySound.start();

[code].....

View 11 Replies

ActionScript 3.0 :: Correct Syntax For Referencing Array?

Sep 6, 2011

I have a number of XMLList objects:
 
_xml.group1..image[i]
_xml.group2..image[i]
_xml.group3..image[i]
_xml.group4..image[i]
_xml.group5..image[i]
 Im trying to reference each object thus:
_xml.group[myVariable]..image[i]
 
But it doesnt work. What's the correct syntax?

View 3 Replies

ActionScript 3.0 :: Referencing Array Through Static Property

Nov 28, 2010

The behaviour looks little weird for me and dont know how to get valus through static property from an array:

[Code]....

but if I initialize missions with values not in the construtor but through variable initialization I gets output = 4; why is that? Doesnt static class initialize its variables in the constructor statement??

View 3 Replies

Actionscript 3.0 :: Referencing Movieclips Inside An Array?

Dec 16, 2010

I am trying to reference a movieclip located inside an array to add an eventlistener and function... I am using array[0].add...ect. The code for the first movie clip works, but for the rest I get an error 1010.

Code: Select allvar image:MovieClip = new Image();
addChild(image);
const MAX_ITEMS:uint = 6;

[code].....

View 1 Replies

ActionScript 3.0 :: Flash Referencing Loaders In An Array

Jun 28, 2010

I have a project that needs 4 levels of zoom, each with its own image loading in. So, to make things easier on myself, I made an array of the Loaders, so I can instantiate them and hide/display them when I need to.However, this doesn't work as I had expected.I.e. (using just two level for simplicity):[code]Is there any way I can reference the loaders dynamically so I can load/show/hide them on the fly, instead of hard coding it for each level?

View 5 Replies

ActionScript 3.0 :: Error #1010 In Referencing Items In An Array

Dec 6, 2010

when I try to move my "stars" I get a 1010 error. when I try to loop a singular item, it works, but dynamically...

Using FlashDevelop.
main()
Actionscript Code:
package {  import com.gfx.mainContainer;  import flash.display.MovieClip; import flash.display.Sprite; import

[code]....

I can trace starArray, but I can't loop to each individual element and move it.

View 1 Replies

ActionScript 3.0 :: Error #1010 In Referencing Items In An Array?

Mar 14, 2011

when I try to move my "stars" I get a 1010 error. when I try to loop a singular item, it works, but dynamically...Using FlashDevelop.

[code]...

I can trace starArray, but I can't loop to each individual element and move it.

View 2 Replies

ActionScript 3.0 :: Remove An Object From An Array Without Referencing Its Index

Oct 19, 2011

I was just wondering whether it would be possible to remove an object from an array without referencing its index, for example when the index is unknown, or when you want to splice it from within the class itself, like ina die function for an enemy in an array. I have a project due on Friday morning, GMT.

View 6 Replies

ActionScript 2.0 :: Looping, Then Referencing Dynamic Clips From Array?

Jan 4, 2006

i'm looping thru xml nodes and using this to attach clips to an empty mc:Code:item = _root.mainHolder.links.linkHolder.attachMovie("linkClip", "linkClip" + i, i);my question is how can I reference the previously attached clip so I can determine the _y property of the current item(clip).I'd like to do something like this.item._y= previously attached clip._y-previously attached clip.height

View 10 Replies

ActionScript 2.0 :: Referencing A Movieclip Within A Movieclip

Jul 26, 2004

If I have movieclip named box01_mc inside movieclip btn01_mc and I wanted to change box01_mc's alpha to 0 on the rollover of btn01_mc how would I write this? I tried writing the following code on btn01_mc but it didn't work:[code]

View 6 Replies

ActionScript 2.0 :: F8 - Referencing MovieClip After Attaching It

Feb 17, 2009

I'm having issues trying to reference a movieClip after attaching it. What I have is:
Code:
btn_instructions.onRelease = function() {
instructions = true;
attachMovie("parchment", "mc_parchment", getNextHighestDepth(), { _x:280, _y:280 });
} mc_parchment.btn_close.onRelease = function() {
instructions = false;
trace("close");
removeMovieClip(mc_parchment);
}

The first is creating it on top of the other items that are created during the game. I can't have the instructions on the timeline and just change the visibility of it due to all the assets this game is making. The instructions variable is used in an if statement elsewhere in the game to lock the user controls so they can't create anything else in the game while your viewing the instructions. The second function is the one that should close it. The movie clip that's attached has a button in it, with the instance name btn_close. The trace doesn't even pop up so it's not targeting it correctly. Yet when I go to 'debug' and 'list objects' both mc_parchment and mc_parchment.btn_close are listed as being in the scene after clicking the instructions button.

View 2 Replies

ActionScript 3.0 :: XML Node Referencing A MovieClip

Aug 28, 2009

Is it possible to make a reference to a MovieClip in an XML object. It doesn't seem to be working with this code.[code]

View 2 Replies

ActionScript 3.0 :: Referencing Movieclip In Game

Sep 20, 2009

var xBoard:Number = Math.floor(mouseX/cellSize);
var yBoard:Number = Math.floor(mouseY/cellSize);
if (board[(yBoard-1)][xBoard] == 0)
{
root.getChildByName("b"+(yBoard-1)+xBoard).alpha = .7;
}

I want to be able to call various movieclips I have arranged in a grid from these two variables (xBoard and yBoard). They get new values every time I click on my gameboard.

Basically I check if they space ahead of the unit is empty. If it is I want the alpha of that space to change designating you can move there. The movieclips are arranged in a grid and named b00 (top left) to b77(bottom right).

This is the error message:

1061: Call to a possibly undefined method getChildByName through a reference with static type flash.displayisplayObject.

If I take out the getChildByName... root.("b"+(yBoard-1)+xBoard).alpha = .7;
This is the error message:

TypeError: Error #1123: Filter operator not supported on type Game_fla.MainTimeline.
at Game_fla::MainTimeline/test()

View 1 Replies

Data Integration :: Referencing What Is In A Movieclip

Mar 11, 2007

I am calling an image from a server to be displayed in flash using php, mySQL. If the image is in part of a browsing gallery where there are eight images on screen all in movieclips how do I get it so when a movieclip is clicked it recognises what image it contains and then goes to another frame where it can have just that one image?

View 1 Replies







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