ActionScript 2.0 :: Referencing Instance Name At Certain Depth
Apr 7, 2010How can I reference a moive clips instance name at a certain depth?
View 5 RepliesHow can I reference a moive clips instance name at a certain depth?
View 5 Repliesis there a way to set the depth of a movie clip instance that is on the stage, ie. not created via createEmptyMovieClip, attachMovie, duplicateMovieClip and so on? Something like
View 5 RepliesI am new to as3, and trying to create empty movie clip
var mystage = stage.getChildAt(0);
var mc:MovieClip = new MovieClip();
mystage.addChild(mc);
But, where I have to set depth and the instance name, when I trace the mc.name. It shows as "instance1". I need to set depth and to name the mc.
I have a series of clips with instance names like box1, box2 etc. Altogether there are about two dozen. Is there any way I can run something like "box#.x = 0" where # would be a wildcard to place all instances starting in "box"?I'd also love to be able to set their y position where box#.y = (#-1)*2. For that I believe I need to do a count function, but I was hoping there was another way. For other reasons I need to be able to control the instance names and not have that be automated in any way.
Is this possible? Searches in these forums as well as Google and a few other places have turned up nothing. It would save me a huge amount of time and work if either of these were possible without having to rework all of my instance names that are already in use.If it's relevant, I'm doing this all in Flash CS4.
I am completely new to actionscript although I do come from a OOP background. I have been asked to trial Flash and Actionscript 3 in particular - so I do come with a few preconceptions on how I expect actionscript to behave. I have a problem I donot understand. I have created a new class and to test it I use a simple test harness in the form of a .fla file.
The issue I have is when I create a new instance of the class and assign it to a variable, subsequent background changes to that instance of the class are not 'picked-up' when referenced through the variable. I would expect that given instance of class could be assigned to many different variables and any updates using one variable would accessible using any of the other variables.
[code]...
I've got a linked class, with an external .as file, tied to a movie clip called "Menu" in an encompassing fla. In this actionscript file, I am trying to pull some information from a few things I made with the flash authoring tool. There are a few symbols on stage in the fla that I drew with instance names "greensboro" and "birmingham", and I want to get their x-position inside some functions of the linked class. I've tried returning a value from "greensboro.x" but of course it says the variable greensboro doesn't exist, because I haven't defined it in the class. Surely there is some way of getting that info in a variable of my linked class!
Edit: here is some code to show what I've tried(cutting everything else). This is in the .as file of the linked class:
package {
import flash.display.*;
import flash.net.URLRequest;[code].....
I'm trying to reference an instance through the use of a variable in my call to a prototype. The variable is myVar and contains the instance name to which I want to apply the resizeTo prototype. My syntax is incorrect.
Code:
on(release){
//disregard this line
this.swapDepths(this._parent.getNextHighestDepth());
//this is calling a prototype named resizeTo
this.resizeTo(150, -100, -100);
//Setting instance name of another movie
myVar = "green";
//Trying to drop that instance name into my next prototype call
this._parent.myVar.resizeTo(100, _parent.old_X, _parent.old_Y);
}
I make a movie clip in the library ( a button with a text field on it ) and export it for actionscript. Then I create an instance of the object using code ( myButton = new Button1(); ).And then I want to access and change the text field ( whose instance name is "myField" in Flash ) afterwards.Is that possible, or I have to create a custom class for the object, or just create an entire button dynamically?
Because what I have tried until now doesn't work.
Code:
var button1:button_test1 = new button_test1();
button1.x = stage.width / 2;
button1.y = stage.width / 2;
[code]....
This questions is for all movie clips: is there a way to access a movie clip's objects with actionscript after you have created (with code) an instance of that object (which was designed in flash, and exported for AS) ?
Anyone know how to change a single instance of an item renderer for a Flex tree item at runtime? To reiterate, I'm not trying to change the entire tree's item renderer like this:tree.itemRenderer = new ClassFactory(ItemRenderer2);I'm trying to change the item renderer of a single tree item like this (the following code does not work):tree.selectedItem.itemRenderer = new ClassFactory(ItemRenderer2);To put it more simply, does anyone know how to reference an instance of an item renderer and set it to a new item renderer class? I've tried using the Tree's itemToItemRenderer() method with no success.
View 1 Repliesputting a movieclip into highest depth without knowing which clip is in the highest depth
View 2 RepliesDoes 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 RepliesI have a library object (SomethingMC) which extends a custom class (Something). Something, in turn, extends MovieClip.If adding SomethingMC to the stage within Flash CS3 IDE, is it possible for it's super class (Something) to assign an instance name from a class constant (Something.THE_CONSTANT)?
package
{
import flash.display.MovieClip;[code].....
The above does not work. It throws Error #2078: The name property of a Timeline-placed object cannot be modified. if the instance is assigned a name in the IDE, and it just doesn't work if no name is assigned in the IDE.
I have a BUNCH of bumpers of four types bounceUp, bounceDown, bounceLeft, bounceRight. during a collision which you hit determines the bounce so they always do the same thing so here's my question.....can i just name every bounceUp instance the same thing and then just add that one instance name to the list the collision detector checks?
i just dont wanna go through and name a hundred each of bounceUp s and bounceDown s individually as the potential for screaming increases proportionally.......
I placed a movie clip instance inside a button, and I want this movie clip to play when the button is released. I'm using this code on the frame containing the button:
function playMovie(event:MouseEvent)
{
this.theButton.theMC.gotoAndPlay(3);
[code].....
Does anyone know if it is possinle to scroll a graphic or a movie instance as well as a text instance in flash. I want to scroll text and images as well. Actually text with imges embedded in it.
View 3 RepliesI am wrapping my brain around OOP in AS2. I am making two posts on two different subjects. My question here is: when should I use local instance variables, and when should I attach new properties to the instance object? (Feel free to correct my terminology.) Let's say I have a class for a scrolling background, which scrolls when I mouse over its edge. I want to put these values somewhere:
1) How wide is the border in which a mouseOver makes it scroll? This is basically a semi-constant I set it up once and keep it the same, unless the user changes it in an options menu to make the border wider or narrower. Call this scrollBorderWidth.
2) How fast is the background scrolling now? I want to track this so I can smoothly change the scroll speed over several frames. This is often changed. Call this scrollSpeed.
It seems I have two ways I can store and access these values and darned if I know which is better practice. METHOD A: Make them local variables in the class, so the scrolling background instance has them as local vars. I set them up thusly:
[Code]....
I have a general / somewhat newbie question. Is it better practice to call a function from another class like so:
[Code]...
Does one way free up more memory or enhance performance?
I have a base class I've used on 6 different MC's. Then when I use these MC's my function runs an if statement to check which one to add.
if(id=design) var obj = new design();
if(id=team) var obj = new team();
I want to make it a bit more dynamic and use the id:String to evaluate which new instance to create.
ActionScript Code:
public function loadChapter(id:String):void {
var obj = new instance_of( id )();
}
i'm workin with some "self created windows" in my flash app. how can i put the window i click on front of the others? I found smth about swapDepth, but there is no swapDepth in as3.
View 3 Repliesi have this drag and drop thing basically when i drop the item on top of its slot i want it to do a hittest to set the depth to a number assigned to it. so lets say I drag an item called Item to a spot called slot i want it to do like item on hit test to slot set depth(2) lets say.
View 1 Replies[code]When I publish it keeps swapping over and over.How can I get it to call only once?
View 2 RepliesIs there any way to see if a depth is already being used by a movieclip before assigning it to another movieclip? I have a game where there are hundreds of movieclips moving around on screen at the same time and changing depths every time they move. But at rare times, one movieclip will spawn at the exact spot another movieclip is in and use that depth, making the old movieclip invisible (but still active and moving around).
View 2 RepliesI'm trying to create a menu for my game, it is a tile-based game, and it draws my tile game ontop of everything. So how can I make my menu layer be above the tile game?
View 3 RepliesI have a movie clip that has about 20 layers that make up four different groups. (Five of the layers work together)Any one of the four groups has to come to the front of the others at any time.Is there an easiesh way to swap depths of these groups?EG. Can you swap a folders depth for example?
View 1 RepliesI m looking for method similat to MovieClip.swapDepths(depth).what is the method in as3, i have movieclips i wanne update those deths
View 4 RepliesI have 3 sprites: img1spr, img2spr, and img3spr. Inside every sprite I have some bitmaps.Every sprite has a name:
img1spr.name=name1;
img2spr.name=name2;
img3spr.name=name3;
[code].......
I'm running a loop that's creating a multiple movieclips. Each clip can be dragged to drop point on the screen. What i'm trying to accomplish is when you select an item to drag it should take the highest depth, and should appear over all other draggable items. Right now the first clip is always under all of them while the last is getting the highest.
View 1 RepliesThis should be really easy to do, but i cant find anything from searching. It's all tuturials for buttons and stuff. All i want to do, is put a MC called "face" on top of everything. What exactly would be the AS3 for this, and where would i put it?
View 4 Repliesshow me a good algorithm which loops through an entire XML without knowing from the start the number of children and sub-children?I studied something in university but at the time I didn't get the explanation well and now I totally forgot.
View 0 RepliesIs there any code like replacemc? Instead of removeChild() and then placing the new one at the addChildAt(same depth).
View 1 Replies