ActionScript 3.0 :: Dynamically Referencing Movieclips?

Nov 28, 2011

I'd like to know how I can achieve this in AS3. The code would work fine in AS2, but as I am very new to AS3 I am not sure what the equivalent would be in AS3.

code:
humanNum = 1;
MC = ["Human"+humanNum];

[code].....

View 1 Replies


Similar Posts:


ActionScript 3.0 :: Dynamically Referencing Movieclips On The Stage?

Jan 20, 2011

Just wondering, is there any way to dynamically reference movieclips on the stage, as in through a for loop like so:

for (var i = 0; i < 10; i++) {
["mc" + i].x = 10;
}

[code]........

View 3 Replies

Referencing Other Movieclips Within Actionscript Class

Jan 17, 2010

I have externalized the actionscript code of a movieclip into a separate class files.This movieclip requires references to some other clips on the stage. What I am currently doing to reference those clips is by using Movieclip(this.parent).otherclip but somehow that feels wrong.Is there a better way to pass in the required references into a class extending from Movieclip inside of the constructor? Or what is the recommended pattern here?

View 2 Replies

ActionScript 3.0 :: Referencing Movieclips On Different Frames?

Jul 9, 2009

I have a main fla with loaded swfs. I would like that I can access a movie clip
in a swf from from another swf.

I would like a button on one frame, when clicked, to go to another frame of a movie clip in a loaded swf on a different frame.

View 6 Replies

ActionScript 3.0 :: Referencing MovieClips Made From The UI?

Aug 26, 2009

I have 23 movieclips on Stage. Each one is a class of 'point', and has been given an instance name of p1, p2, p3, p4 etc.I want to reference them in code, and then get their x and y co-ords eventually.How do I make them accessible variables in AS3? in AS2 I would have put them into a for loop, and said

Code:
for(i=0,i<23;i++)
{

[code].....

View 12 Replies

ActionScript 2.0 :: Flash8 Referencing MovieClips With Variables

Jun 12, 2009

I want to reference clip with some variable name because i want to change dynamicaly target clip. Example:

myMC="testClip";
myMC.my_txt="some text";//this doesn't work
//but this works
eval(myMC).my_txt="some text";

I guess eval() is not right thing to do.

View 4 Replies

ActionScript 3.0 :: Referencing Movieclips To The Stage Or Root

Jun 18, 2009

I have a movieclip "submenu" that is on the main timeline, and inside this movieclip, I have some ActionScript:

[Code]....

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

AS2 :: IDE : Dynamically Referencing ROOT?

Aug 3, 2009

I am having trouble dynamically changing the reference to root in my movies. Here's what I'm trying to do: I have a main movie(_level0.mainMovie) that I am loading external .swfs into. However, I want to be able to test the child movie clips without having to load them into the mainMovie(for testing purposes). In such a case, the child clip would be at _level0 or _root. I would like to add some code to the child clips to test whether they are the _level0 clip, if not, then I want to change their reference to _root. Here's what I've come up with, which doesn't seem to work:

Code:
function testLevel(){
//This code goes into each child clip to see if it has been loaded into another clip
trace(this);
if(this == _level0){ //If this is the _level0 clip

[code]....

View 4 Replies

IDE :: Referencing A Dynamically Created Clip?

Jan 10, 2010

here is a snippet of code in first frame of the movie I have trouble with:

----------------
for (var i = 0; i < 5; i++) {
var container:MovieClip = new MovieClip();
this.addChild(container);

[Code]....

I am getting an error message: A term is undefined and has no properties. I checked list of objects and container0.one and it's there but I can not get to container0.one.usecase

View 6 Replies

ActionScript 2.0 :: [MX04] Referencing Multiple Movieclips With Single Variable?

Jan 25, 2009

Is there a way to reference multiple movieclips using a single variable name? For example,I'm making a side-scrolling game, and there's going to be many platforms, and I have some code that tells the player not to fall through these platforms, but I don't want to copy and paste the same "platform" code every time I add a new platform.

View 3 Replies

ActionScript 2.0 :: Referencing Dynamically Created Variables?

Dec 9, 2006

I have a number of 'TweenField' instances created in a for loop. The problem is that each time the loop increments, the 'myTweenField' variable has the same name, so I don't know how they can be referenced individually from elsewhere in the script. How can I rewrite it so that each instance has a unique name, and how would I then reference it from outside the loop?

Code:
package
{

[code].....

View 11 Replies

ActionScript 2.0 :: Referencing A Field In A Dynamically Created Movie?

Jul 17, 2010

I'm using Flash 8.

I've made 18 movies in a for loop. I'm trying to modify a text field in those movies. I am unable to do so in the for loop. Something with my referencing is wrong.

The dynamic text field in each movie is named "eventText".

ActionScript Code:
_root.attachMovie(myData["loadHandler"+x]+"Movie", myData["event"+x], x, {_x:100, _y:100});
_root.myData["event"+x].eventText.text = "test";

If I hardcode the event name for testing purposes, it puts the data in correctly:

ActionScript Code:
_root.houseSale2.eventText.text = "test";

View 4 Replies

ActionScript 3.0 :: Referencing Library Items Semi-dynamically?

Aug 16, 2010

I'd like to add a couple of different MC's to the particle stream. I'd like to do that by referencing different items in the library.So I have 12 different particles in the library exported with classes named from Bubble0 to Bubble10 now as I run through my for loop I'd like it to use a different particle each time. first time I tried:

ActionScript Code:
var bubbleArray:Array = new Array();
bubbleArray.push(Bubble0,Bubble1,Bubble2,Bubble3,Bubble4,Bubble5,Bubble6,Bubble7,Bubble8,Bubble9,Bubble10,Bubble11)
for (var j:uint = 0; j < NUMBER_OF_BUBBLES; j++) {

[code]...

Scene 1, Layer 'actions', Frame 1, Line 871086: Syntax error: expecting semicolon before leftbracket.Is what I'm trying to do possible without some clunky switch statement?

P.S. I tried searching the forum for an answer but the terms are so common I couldn't find what I'm looking for.

View 6 Replies

ActionScript 3.0 :: Dynamically Referencing Objects Names In Loop

Jul 12, 2009

The problem is referencing object names dynamically in AS3, in a loop. Example. I have an array called c4 which i would like to reference like this:

I have a number
var x:Number = 4

How can I do something like
trace(["c"+x].length);
(I know this is wrong!)

Same with other objects
E.g. Movieclip called mc4
["mc"+x].x = 100;

View 3 Replies

ActionScript 2.0 :: Referencing/loading A Dynamically Created Movieclip Variable?

May 23, 2008

I am trying to load an image in to a dynamically created movieclip, which is:

_root.mySlider."+stripX2(band[i][0])+i

but I can't seem to reference it. I can load the movie into _root.mySlider, but if I add the dynamic element (stripX2(band[i][0])+i) without quotes it it doesn't load. If I load with quotes i.e.

"_root.mySlider."+stripX2(band[i][0])+i

flash doesn't allow strings in movieClip variables.The code I'm using is belowm, it's the second to last line thats causing the problem:

var loadListener:Object = new Object();
loadListener.onLoadComplete = function(target_mc:MovieClip):Void {
trace(">> target_mc._width: "+target_mc._width);[code]......

View 2 Replies

AS3 :: IDE - Dynamically Naming Movieclips?

Sep 23, 2009

Ok, I've been climbing the walls trying to figure this out, looked everywhere for an answer, learned a few bits and pieces along the way, but still can't do it.I've made my Class which is a little movieclip called 'block', it's fine and does what I tell it to do ie. I can reposition itstretch itotate it and stuff.The problem is.. I want to make more of them and reference them individualy so I can change the properties of them individualy ie, the x and y values etc.

for (var i=0; i<2; i++){
var newBlock:blocks = new blocks();
this.addChild(newBlock);

[code].....

View 6 Replies

ActionScript 3.0 :: How To Dynamically Align MovieClips

Jan 29, 2010

I'm working on a project so as to hopefully learn AS3 a bit more, and for it what I have for it currently is that it looks at the time, and if its between 8 pm and 8 am it imports one mc, or if its between 8 am and 8 pm it imports another. My problem at the moment is that I can get it to import it and align it at the needed x coordinates, but not the needed y coordinates. I'm not sure what the exact y coordinates are, but as in the future they might change, I was trying to find a way to align it so that the very top side of the mc to the top side of the stage, but so far I have had no luck, as I can't think of what would be needed. I've seen references to a "StageAlign._______" before, but either I'm not using it right or it isn't the right thing to use.

Here is my code right now:
ActionScript Code:
import flash.events.*
import flash.display.StageAlign;
import flash.display.StageScaleMode;
var time:Date = new Date();
[Code] .....

View 1 Replies

ActionScript 2.0 :: Dynamically Add Several Of Same Movieclips To Stage

Sep 20, 2010

Im trying to dynamically add several of the same movieclips to the stage. This movie clip contains a textbox. I have tried the following:-[code]I have my movieclip exported fror actionscript with the identifier as (textbox). This code does add a textbox to the stage however it only adds the second one which says "goodbye" but not the first one which should say "hello"? I thought the loop should go round twice and add a 'newText1' and a 'newText2'??

View 3 Replies

ActionScript 3.0 :: Assign Dynamically Name To Movieclips

May 2, 2007

i wanted to create a bunch of movieclips in a for loop but wanted to name them something different each time, how would i dynamically name them? example of basically what i want to know how to do

[CODE]...

View 14 Replies

ActionScript 2.0 :: Use A Loop To Add Movieclips Dynamically

Oct 29, 2007

I have a little problem with a loop. I recieve som data from a database and gets it back as an array. I then use a loop to add movieclips dynamicly and this works fine to, but if i try to trace the id from an onRelease function i get an undefines, but when i dot it outside the onRelease it works fine. This is the code. Its in a class by the way.

[Code]...

View 1 Replies

ActionScript 2.0 :: Move MovieClips' X & Y Relatively/dynamically?

Aug 28, 2008

I have about 70 MovieClips and when you rollover one I want it to enlarge and the other MovieClips' x & y to shift so that nothing is overlapping. Does anyone know how to do this or has anyone seen an example? I have attached some screen shots of how I would like this to work.

View 1 Replies

ActionScript 3.0 :: Dynamically Creating MovieClips?

Sep 5, 2009

Is there any way to create dynamic animations? Say if I'm creating a game and there might be multiple sprite sheets for different NPC's, would I have to manually create the walking/whatever other animations manually?

View 5 Replies

ActionScript 3.0 :: Dynamically Created Vs Static Movieclips?

Feb 4, 2009

Movieclips created on the stage and instanced behave differently from dynamic movieclips in that they are destroyed when you go to the next frame (I have a stop on every frame). If I create that same movieclip dynamically then it will stay on the stage forever regardless if I go to the next frame or not. I understand that it needs to be removed from the display list but I can't find any event that is fired on a next frame basis. I could use onEnterFrame but at 30 fps, that's alot of overhead. The idea is to have all the code contained in my .as file.

View 6 Replies

ActionScript 3.0 :: Drag And Drop One Of Many Movieclips Dynamically

Mar 4, 2011

I'm looking to be able to pick up one of 36 movieclips on the stage, and drag it to a hotspot. If it lands on the hotspot, then it does something, otherwise it just gets dropped.

How do I dynamically change the "target_mc" to be whichever movieclip I select?

This code works fine, but that's because eventlistener is set-up explicitly for a given mc.

Code:
// sprites
import caurina.transitions.*;
var drag_mc:MovieClip = energy_sprites.play_wave;

[Code].....

View 3 Replies

ActionScript 3.0 :: Accessing Dynamically Created Movieclips

Nov 21, 2008

I have an application that I am adding movieclips to a container movieclip through a for loop and repeatedly calling myClip.addChild(theNewClip). Now I have a dozen clips in my container and it seems like the only way to access the clip is to use the getChildByName() method and cast it into a temporary clip so I can get at the its properties.

Is this the best and/or only way to do this? Does the old AS2 myContainer["theName"].property not work with dynamically created movieclips? It doesn't seem to work for me anymore.

access a dynamically created movie clip.

View 1 Replies

ActionScript 3.0 :: Accessing Dynamically Created Movieclips?

Nov 21, 2008

I have an application that I am adding movieclips to a container movieclip through a for loop and repeatedly calling myClip.addChild(theNewClip). Now I have a dozen clips in my container and it seems like the only way to access the clip is to use the getChildByName() method and cast it into a temporary clip so I can get at the its properties.

Is this the best and/or only way to do this? Does the old AS2 myContainer["theName"].property not work with dynamically created movieclips? It doesn't seem to work for me anymore.

access a dynamically created movie clip.

View 1 Replies

ActionScript 3.0 :: Dynamically Generated MovieClips In Array

Mar 3, 2011

I've tried to generate movieclips dynamically the method I have used does the following:
Uses a loop runs depending on how many movieclips I want to generate e
Each time the loop cycles it creating a new movieclip instance
Adds the new movieclip to an array
Uses method addChild to put moveclip on the stage then draws a rectangle
begins fill
ends fill
Adds it to that movieclip

I then use a conditional statement checking if the movieclip is the first item in the array if so it sets the current MovieClips x and y position to a chosen value. the first movieclip is used for a starting point to align the rest of the generated movieclips to. If not the movieclips x and y position are set to the previous array items x and y position + current movieclips width or height + the gap I would like them to have. Then the cycle repeats. I've coded this using timeline code and it works fine the shapes appear on the stage no errors. I tried to move this code off the timeline to an as file and the code has no errors but when run I just don't see the objects even if I trace there x and y positions I don't see them on the stage.

Timeline Code
var mcArray:Array = new Array();// DEFINE ARRAY FIRST
var randomNo:Number;
var colorStr:String;
var currentColor;
var movieClip:MovieClip;// TEMPORARY VARIABLE
[Code] .....

View 5 Replies

Professional :: Scrollpane With Dynamically Added Movieclips?

Mar 25, 2011

I'm more of a Flex than Flash developer so I'm hopeful this is something easy.  Short story, I have a scrollpane in a flash-created swf. In my pure AS3 project I dynamically create menuitems within a new movieclip.

[Code]...

View 5 Replies

Dynamically Adding Movieclips To Stage In 'for Each' Loop

Dec 2, 2009

I am reading in collection objects from an XML file. Each collection has an img field that stores a URL to the collection image. So I am trying to load the images of each collection, storing each image in a MovieClip, and add these MovieClips to the stage. However, my problem is that after adding a MovieClip (with the collection image) to the stage, when a new MovieClip is created in my 'for each' loop it overrites the previous MovieClip. So the images I am adding to the stage are being replaced by the following collection's image on each loop iteration. What can I do to avoid this?

[Code]....

View 1 Replies







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