ActionScript 3.0 :: Creating Instance Names In For Loops To Reference Later?

Dec 22, 2009

I create buttons, but I am trying to give them each instance names so can target them individually but I keep getting undefined property error.

Code:
import fl.transitions.Tween;
import fl.transitions.easing.*;
var menu_items:Array = ["CHAPTER I","CHAPTER II","CHAPTER III"];

[code]....

View 1 Replies


Similar Posts:


Actionscript 3.0 :: Using For Loops To Generate Numbered Instance Names?

Jun 27, 2011

I'm attempting with no success to use a for loop to generate numbered instance names so that I may attach an event listener to multiple movie clips at once.Ex: I have 10 movie clips with instance name button_1 to button_10 and I'd like to be able to do something like this:

Code: Select allvar btnName:String = "button_";
for (i = 1; i < 11; i ++) {
[ btnName + i ].addEventListener(etc, etc);
}

View 2 Replies

ActionScript 2.0 :: Refer Certain Variable And Instance Names Within Loops?

Aug 18, 2010

Trying to set up a world of warcraft like hotkey setup for an RPG i'm making for a school project, where you drag spells from the spellbook onto the hotkeys. Understand all the concepts, however, instead of doing a ridiculous amount of if statements, I want to loop the functions. Unfortunately, I don't know how to refer to certain variable and instance names within loops. I shall show you what I have:

ActionScript Code:
for(var i; i<2; i++){
spellbook_inst["spell_"+i+"_inst"].onPress = function(){
this.startDrag();
_root.hold_spell_position_inst._x = this._x;
_root.hold_spell_position_inst._y = this._y;
}}

The "spells" (i.e., icons you drag from the spellbook) are all named spell_(number)_inst, and are movieclips within the spellbook_inst movieclip. I want the drag function to be available for all spells. At the moment, I don't get any syntax errors, but nothing happens, so I presume I have referred to it incorrectly.

View 2 Replies

ActionScript 2.0 :: Creating Unique Instance Names For AttachMovie?

Aug 16, 2007

I'm currently making a TicTacToe game to help build my Flash experience and I've come across an issue. I'll try and explain what everything is doing in my code thus far. I know it's a lot of code for a forum post, but I don't want to leave anything out as someone may have a really nice way to work with this.

Code:
this will be switched to a user defined value (1 or 2), depending on which person the user decides should go first. currently it is set up for the 2nd player to go first

new _global.whosTurn();
_global.whosTurn = 2;

//this sets all cells DISABLED so, at the beginning of the game, any cell is selectable
cell1_isUsed = false;
cell2_isUsed = false;[code].....

View 4 Replies

ActionScript 3.0 :: Creating Instance Names For Dynamically Created Movieclips?

May 28, 2011

I am trying to use a for loop, to place 5 instances of the same movieclip on the stage. In the loop I used .name to give each movieclip a unique instance name. But when I try to reference one of those instance names in an event listener I get an error. Here is an example of what I am trying to do:

Quote:

var xPos:int = 120;
var yPos:int = 60;
for (var i:Number = 1; i<=5; i++) {

[Code].....

This code generates an error saying that the cStar2 property is undefined. In the example above, does the for loop create 5 copies of the movieclip starC_moov, and give them unique instance names cStar1, cStar2, cStar3, cStar4 and cStar5?

View 1 Replies

ActionScript 3.0 :: Creating A New Instance With The Same Variable Reference?

Mar 8, 2011

set to null a reference in this case?

private function initGame():void{
var game:Game = new Game()
}

[code]......

View 2 Replies

ActionScript 3.0 :: Flash - Creating A New Instance With The Same Variable Reference?

Mar 8, 2011

Theres any need to set to null a reference in this case?

private function initGame():void{
game= new Game()
}

[code].....

View 1 Replies

ActionScript 3.0 :: Instance Names And Variable Names: It Goes Deeper

Mar 20, 2011

I started a thread about a reference to a symbol House, in the output window, which was: House_1. A lot of people said some useful things about that. All day I've been thinking about it, and I came to the conclusion that I don't understand things, at a very basic level.

Consider:I make a movieclip which I give the Symbol name Drawer. (I don't export it for AcitonScript.)On the stage I manually place two instances of this Symbol. The first one I give the Instance Name drawer (in the properties panel). The second one I leave nameless.Now if I trace the names of both these clips, by

trace(this.getChildAt(0).name);
trace(this.getChildAt(1).name);

the output window gives me

drawer
instance2

Now I know that the so-called "instance name" which I gave in the Properties Panel (drawer) is, in reality, a variable name which Flash gives my first instance behind the scenes. And instance2 is a name that Flash gives my second instance. What exactly the nature of that name is, I do not know.My point is: both names (drawer and instance2) are the .name property of these movieclips. Otherwise I could not have traced them through asking for the .name property, in the above. Yet only the first of these two can be manipulated:

drawer.x can be set;
instance2.x can (as we know) not be set.

But...why? What is the real difference between these two kinds of names? How can they both be the .name property of their underlying movieclip, yet be of such a different nature? What IS the nature of the instance2 name? If it's a String, how come the .name property of one movieclip can be a variable name, while the .name property of another (but identical) movieclip is a String?

I've searched every bit of web page on the net I could find. But it looks as if nobody addresses this issue. We all just work with it - but it makes no bloody sense. A name property = a name property, you'd think. Whether Flash set it or I set it should not make a difference. The x property of a clip, for example, does not change in nature according to who set it - me or Flash.So, again, just to emphasize the problem: how can a property (the name property) of a movieclip change in NATURE depending on who set it? After it's been set, shouldn't the name property of a clip be of exactly the same nature as the name property of another clip?

View 8 Replies

ActionScript 2.0 :: Objects - XML - Creating A New Instance Of An Object That Uses An Identical Name To An Older Instance Delete The Previous Instance?

Mar 20, 2009

Does creating a new instance of an Object that uses an identical name to an older instance, delete the previous instance? Or should the original instance be deleted first? The code uses a ridiculous amount of XML vars. Isn't it less memory intensive to parse the XML and save the properties to an Object, and then delete the XML Object, rather than keep the XML Object around and reference it's child nodes directly? Is it better form to break up a huge XML file (>600lines/3200vars) into smaller chunks?

View 1 Replies

Actionscript 2.0 :: Flv Playback Instance Loops Back To First Frame?

Feb 27, 2010

I am importing a .mov file in Flash, which converts it into an .flv, which works fine and dandy, but playback does NOT stop at the end of the video, but loops back to the first frame and stops there. what to do to get it to stop at the last frame? I am just using the flv instance in a keyframe, not using any code to control it, which is a bit over my knowledge level.

View 1 Replies

CS3 :: Creating A Crossfading Between Sound Loops

Jun 25, 2008

I am trying to make a sound crossfading between the loops (an example would be: same as in a "Winamp" media player you toggle the Crossfading function in a Modern Skin and select a duration of it). Say I got a loop of 10 seconds, altho it is not perfect as its cut of the song without a proper editing tool. Any way I could accomplish it by using the ActionScript?

View 2 Replies

Set Properties Of A New TextField When Creating With Loops?

Aug 10, 2009

I am trying to create 6 TextFields with a loop which I have done but I can't seem to figure out the right syntax for setting the properties such as font, size, etc. in the loop. Here is my basic code:

var Tiles:Array = new Array();for (var i:Number = 1; i< 7; i++){Titles[i] = new TextField();
Titles[i].TextFormat.size = 17;}addChild(Titles[f]);}

View 3 Replies

ActionScript 3.0 :: Creating Movieclips In For Loops?

Aug 23, 2010

I am trying to run a for loop that creates multiple instances of a movieclip.

public function movieclip() 
for(var i:int; i < 4; i++) var
square_mc1:mcSquare = new mcSquare();

[code].....

View 5 Replies

ActionScript 3.0 :: Multiple Tab Loops Creating Themselves?

Oct 26, 2010

I have created 2 separate arrays. One that contains all of the "options" and the other which contains all of the "products". Since the products change depending on the options, this way I can just update the products array whenever the filtering options get changed.So far, everything is working as expected. I can change the filters whenever I want and tabbing works exactly as expected.The problem arises when I click on one of the products.This brings up an informational popup. When that happens, I loop through the products array and the options array and set tabEnabled to false on all of them so that you can't tab through to items in the background. This works great. When you close the popup, I once again loop through the products and options arrays and set tabEnabled to true, but this is where the weird happens.

What happens is that you can now tab through the options and it goes through them all just fine, but when it gets to the end of the options, where it would normally start tabbing through the products, it skips them and goes back to the beginning of the options. HOWEVER, if you shift-tab from the beginning of the options, it goes to the products and as long as you are shift-tabbing, it will cycle through only the products. If you release shift and tab normally, it will tab through the products and when it reaches the end, jumps over to the options and tabs through those, once again skipping the products unless you are shift-tabbing.

I have traced the tab indexes and they aren't changing. I have no focusManagers implemented in the entire project. All of the various items are added programatically and dynamically at runtime. I'm at a loss here, and haven't been able to find anyone else with a similar problem... Any thoughts? Most of the options items are components (radioButtons and Checkboxes) if that might make a difference.On a side note, it also seems like whenever I set tabEnabled to false, when I set it back to true, I have to set focusRect to true as well. It seems to automatically set focusRect to false when you set tabEnabled to false as well. Is that normal? Seems like those should be independent of each other

View 2 Replies

ActionScript 2.0 :: Creating A Grid Of Hexes Using For Loops?

Jul 11, 2004

I'm trying to create a grid of hexagons by using nested for loops. I picked up this code trawling the forums but this creates a diamond shaped pattern of hexes rather than neat rows that interlock together. I want to create one row in the first place, increment the x and y placing coords so as the next row is offset as appropriate to lock it into place under row above.

This is the code I'm using, which is clearly not doing the trick.

spacing = 35;
spacing2 = 35;
for (x = 0; x < 10; x++){

[Code]....

View 1 Replies

ActionScript 2.0 :: Use Instance Names Such As '1-1'

Mar 17, 2010

I have a grid 8 columns, 3 rows.I used instance names such as 1-1, 1-2, 2-1, 2-2, ect to easily identify each cell. I can call the movieclips within them without a problem by doing this["1-1"].gotoAndPlay(1); but how do I go about calling them when I can't use "this"? "1-1".gotoAndPlay(1); does not work.

View 2 Replies

IDE :: How To Replace Instance Names

Jan 26, 2009

In the first frame I have 60 buttons with each having a actionscript in it using the instance name "A1". What I need to know is how can I REPLACE the instance name from A1 to B1 in 60 buttons in my NEXT FREAME?

Is there an easy way to do it rather than typing one by one?? I used the "FIND AND REPLACE" option but it replaces A1 to B1 in both the frames. I need to alter the instance name only in the second frame. How can I do it?

View 3 Replies

IDE :: Instance Names Given In The Editor?

Apr 26, 2009

I have two buttons, they're both movie clips, and have identical code except for their names. When I place one of each on the stage and give them instance names, they come up output:

[Code]...

View 1 Replies

ActionScript 1/2 :: VAR Instead Of Instance Names?

Sep 14, 2010

How to write the following AS codes using VAR instead of instance names?

my_Input_Txt.onChanged = function() {  _root.my_Dyn_Txt5.text = my_Input_Txt.text;_root.my_Dyn_Txt6.text = my_Input_Txt.text;}; 
_root.my_Dyn_Txt5._visible = false_root.my_Dyn_Txt6._visible = false_root.MDT1._visible =

[code]....

View 7 Replies

New AS File Won't Recognize Instance Names

Jul 15, 2009

I get the error "Access of undefined property menu_bar" when menu_bar is an instance name directly on the main timeline. I'm not sure how I would call it in the other class. It also isn't exported for actionscript is that the problem?

I have it imported to my document class as:

var mouseClicks:MouseClicks = new MouseClicks();
addChild(mouseClicks);

Then the class looks like this:

Code:
package{
import flash.display.MovieClip;
import flash.events.*;

[Code]....

View 2 Replies

ActionScript 3.0 :: Instance Names Getting Changed

Mar 4, 2010

I know I've read something about this here before but I can't find it, so for Mr. Thicky here, I have dragged some buttons on my stage - each one is actually an instance of the same movieclip. In the IDE, I have given them instance names like 'myButton1', 'myButton2' etc. I've then grouped all these buttons together into a single container movieclip called 'buttonHolder'. Now, in my code, I am trying to retrieve the instance name of the button I have clicked on:

[Code].....

View 3 Replies

CS3 Give Instance Names Quickly?

Jun 3, 2010

I have 100+ of the same movieclips on the stage at the same time, all positioned differently.i'm getting really tired of clicking on one of them, then clicking in the instance name box then typing "i65", then clicking on one of them, then clicking in the instance name box then typing "i66"...

is there anyway flash can fill this information in for you? or a plugin anyone's heard of? this isn't really an actionscript question, I'm not so fussed about selecting the different movieclips based on getChildAt or any of that stuff, I'd just really like a faster way of assigning instance names.

View 1 Replies

Shortcut To Assigning Instance Names?

Oct 22, 2010

I have a 4x4 set of square buttons that I need to give instance names to. They will be named 'btn_1' thru 'btn_16'. Is there any shortcut to assigning the names or do I have to go through 16 times clicking on the button and clicking down to the 'instance name' text box?

View 2 Replies

Find And Replace Instance Names?

Oct 4, 2011

I am working on making a photo flip animation between 5-7 photos but i have to duplicate this 70 different times. So what i have done is made a scene for each set of 5-7 photos, they are externally being pulled in through an AS3 script to prevent a large .swf file from happening with all those photos. The problem i am running into so that i cant seem to run a find and replace search to replace the instance name values.

View 1 Replies

ActionScript 3.0 :: Tween And Getting Instance Names?

Feb 3, 2009

iv got these buttons animated using the inbuilt tween function and am coding them like this:

function navOver(e:MouseEvent):void {
var page = MovieClip(e.currentTarget).buttonThumb;
var myTween16:Tween = new Tween(page, "y", Regular.easeOut,
0, -25, 0.35, true);

[code]....

MovieClip(e.currentTarget).instanceName returns undefined neather of which are the instance name.i cant hardcode the function because its used on lots of different mcs throughtout the flash file

View 4 Replies

ActionScript 3.0 :: Getting Movieclip Instance Names?

Feb 23, 2010

I am trying to get the instance name that i gave to a dynamically created movieclip the movieclip was created using var zebra_mc:Zebra = new Zebra(); //creating a new instance of the zebra class The movieclip was then added to the stage using a for loop, as it was contained in an array. Each time a movieclip is added to the stage it is then added to another array (existingObjects) I then need to iterate through this array and pull out each objects names. I have tried using existingObjects[i].name, which returns "instance140" and existingObjects[i].toString, which returns functionFunction(){}, very useful. and existingObjects[i] which just returns the object.

View 2 Replies

ActionScript 3.0 :: Hit Testing Without Instance Names?

Jun 18, 2010

I know its possible to hit test From something without an instance name if you have it in a seperate .as file. All you have to do is type in this.hitTest(InstanceName);

But, Is it possible to do a hit test from something without an instance name against something else that doesn't have an instance name?[code]...

View 16 Replies

ActionScript 3.0 :: Using And Storing Instance Names?

May 30, 2011

I know you can store instance names in an array and call on the array values to reference the instance names in it.I was wondering if there is any way I can take an instance name, feed it directly into a function and use the name of the function variable/array/whatever to affect the object instance of whatever I name.

if it's an array of instance names, what is it actually an array of? Also, is there any way to hold and reference an instance name in a single value? sidenote: this doesnt have much to do with my question, but can arrays be fed directly into the header of a function?

View 6 Replies

Flash :: Complaining About Instance Names?

Nov 13, 2009

I have a Flash CS4 FLA throwing the following error when I hit Ctrl+Enter to test the movie: WARNING: Multiple 3D objects on the same frame have the same instance name. 3D instance names must be unique. All but one of the instances will be renamed during export. On my layers, I can't see any duplicate instance names, and Flash doesn't give me ANY indication as to which names are causing the problem. I know it's to do with two layers making use of 3D Tween. When I hide them, the problem goes. I've even tried removing and replacing the Symbols. First of all, I have to have the objects on those layers Tween in 3D, and I have to give them instance names as I refer to them from ActionScript code.

View 2 Replies

ActionScript 2.0 :: Indexing Instance Names?

Jan 13, 2011

I have a series of movieclips which I want to use as buttons.The instance names of the clips are as follows: "ms1", "ms2", "ms3" and so on...I want to put frame actions on these buttons, so that when the mouse rolls over on them, the button movie clip changes frame. I created an array to store instance names and then referred to it for actions, but the problem is that although my buttons do work, but when I roll over them, the button doesn't move to its next frame.

Here is my code:
ActionScript Code:
var men:Array=new Array();

[code]......

View 1 Replies







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