Instance Names
Hi!
I'm working with loops and I use the attachMovie() function alot to put different thumbnails, buttons etc. on to the stage.
I have e.g. this code:
Quote:
for(i=1;i<=5;i++){
s="thumbnail"+i trace(s) trace(s._x)
It's not working to put together an instance name like this. I have also used the concat() function without any luck. Previously, I have use _root["thumbnail"+i], but this is complicated and doesn't work when i have several movies loaded into each other.
Does anybody knows how i can solve this problem?
Thanks alot!
FlashKit > Flash Help > Flash ActionScript
Posted on: 06-22-2006, 08:51 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Instance Names...changing...or Addressing Txt Field Instance Based On Instance Of Mc
i'm creating a mail form, that has a text effect which displays the type of info to be entered in each input box. To create this effect, i had to assign the variable name txt to the input boxes as well as the instance name txtBox. each of these text fields is contained within a movieclip, each with a unique instance name. what i need to do, is somehow assign a value/variable to each text field to pass to PHP to generate an email. I have always used components for contact forms so i'm not sure how to make the switch, AND.. the script i use for my contact form is an EXTERNAL AS file. (i use a customized version of a contact form from www.actionscript-toolbox.com [which apparently is no longer Flash related site])
ok.. this is hard to explain..... so bear with me....
If my original mail form component instance names were: tiName, tiEmail, tiSubject and taMsg (ti for textInput and ta for textArea)
and my current instance names for the mc's which CONTAIN the input boxes (with txtBox textfield instance inside them) are: name_txt, email_txt, subject_txt & comments_txt...
how would i pass/convert the users input text in each movieclip's txtBox, into the original instance name for my mail form so i can continue to use the form/PHP i have been using??
OR....
how do i take the values input by the user in each txtBox (i.e name_txt.txtBox.insertedTextFromUser or name_txt.txt, email_txt.txtBox.insertedTextFromUser or email_txt.txt) and send them to a new PHP script to send mail??
please keep in mind i am PHP retarded... hence why i re-use the same form over and over..
thanks in advance for any help. it's greatly appreciated...
if you're confused about my problem, please let me know... i'm having a difficult time explaining....
How To Get Button's Instance Name On Stage? OR Can A Button Ahve 2 Instance Names?
i have a button the the stage, with an instance name of: "butt1"
the button itself lives inside a movieclip, where it is called thisButton
when flash runs and I click the button I want to output the button's instance name on the stage (i.e. butt1) but i'm only getting the button's instance name in it's own movie
this._name gives me = thisButton
is the name i want stored in a separate property?
edit: sorry - i realise that the problem is that the button code is inside the mc itself, where the button's name is thisButton
Instance Names
in flash mx how do i go about assigning an instance name ?
Instance Names
How do you instance an external .swf file that is loaded through action script using:
Code:
loadMovieNum("Page_1.swf", 1)
Any help would be great.
Thanks,
ex
Instance Names
okay this is basic....i think.
the situation:
I've got a frogger type game. There are 3 goals at the top of the screen. I have a collision detection block of code that detects when the player hits the goal. (duh)
So the goals are 3 instances of the same movie clip from the library all with the same collision detection code in it with one difference, the instance name. The question is, I'd really like to have all three blocks have the same code to call the "game over" function. To do this I'd like all the goals to have the same instance name, however it dosen't seem this is possible. Am I missing something or will I have to edit the code to say goal1, goal2, goal3 etc?... thus resulting in a lot of redundancy.
Instance Names
Is there a way to set instance names on the fly.
Im calling mc's from my library and the there not keeping my instance names I gave them after I call them to the stage.
Thanks
Josh
Instance Names
HI, probably a simple question as I am a newbie, I have some text which loads from XML to form a menu. I have that working but with long code:
this.mc_buttons.mc_btn1.menutxt.text=titlearray[0];
I would like to loop through the array to populate the text rather than specifying it.
e.g.
this.mc_buttons.mc_btnj.menutxt.text=titlearray[j];
The problem I am having is adding the j variable to the end of the mc_btn1 instance name, I want it to be something like mc_btnj.
Does anyone know how I would do this? I do not really want to change the way I am doing the menu as it works fine, just this little problem to solve.
Thanks
Bex
Instance Names
ok, im new to flash and actionscript.
I have an movieclip that i want to duplicate but respect the same hit tests as the original. Looking through the help documentation in MX i see that instance names need to be "unique" to there objects this explains why im having problems. My question is, is there a special class or something that i can use in order to have multiple objects with the same instance name? or is there some other way i can do this without having to refer the hit test to seprate instance names?
Thanks
Instance Names
Well I have been working with flash on some games and a lot of them have the same issue. They have to have hit tests on a lot of the same library objects but becuase a instance name only works for one of them on the screne i was wondering if there was a way to make a peice of script work for all of that library object, a entire layer, or something along those lines without having to add in a different instance name for the dozens of the same library object it might hit.
Thanks a lot.
Instance Names
Hello.
I am currently building a menu (which i unfortunately can't paste the fla here) and was wondering if someone could give me a little advice. I have it set up that the movie will duplicate itself upon loading and therefore I can't select the multiple graphics while designing in flash because they technically dont exist yet...
What I need to know is how can I refer to "instance names" in a/s and tell it to load a specific movie on press/release on that instances graphic? It might be very simple but I can't seem to find the answer.
Please let me know if I'm not making myself clear and I might have to try to post my fla later then. Thank you very much.
Thanks.
Help With Instance Names.....
I have a movie clip within a button within another movie clip all have different instance names. Flash does not recognise the instance name of the movie clip within the button. Does anyone know why, and of a way around this if possible?
AS 3 Instance Names
I know that you can add a movie clip to the stage using the addChild() function but my question is how can you give a instance name to a dynamicly placed MovieClip?
Instance Names & AS
I was wondering if there was a way to classify multiple instant names under one variable.
For example
my_cities = atlanta, boston, tokyo, la
my_cities being the variable.
atlanta, boston, tokyo, la being the instant names.
Then...
my_cities._alpha = 50;
^ & all of the instant names under the variable "my_cities" would be effected. I could use some help on finding the right AS lingo to make this work.
I'm asking because I'm making a map with lot's little pin points where the cities are... & a super big time saver would be being able to affect all of those pin points (cities) at once.
- THANK YOU EVERYONE
Same Instance Names?
I'm loading a movie clip onto my stage through xml (a dot). When it does this, it also creates a small list on the side. The user can rollover the different items in the list and the corresponding dot lights up. Here's my problem. Some list items need several dots. I have it working as far as putting the multiple dots on the stage, however, on the list rollover part I'm having issues.
When the list item should have multiple dots, I am making those dots have the same instance name. I then have a function tell that instance name to run (hoping to have all mc's with that instance name run) but only one dot works.
Here's my as.
ActionScript Code:
function thumbnails_fn(k){ if (duplicate[k] == "yes") { d=d+1; // making p equal to original k p = k-d; flashmap.dots.attachMovie("dot", "dot"+p+"dup", d+99); flashmap.dots["dot"+p+"dup"]._x = xpos[k]; flashmap.dots["dot"+p+"dup"]._y = ypos[k]; addbutton = false; } new_k = k-d; if(addbutton) { locations_mc.attachMovie("location_bttn", "thumb"+k, k); locations_mc["thumb"+k]._y = new_k*18; locations_mc["thumb"+k].location_txt.text = locations[k]; } addbutton = true; flashmap.dots.attachMovie("dot", "dot"+k, k); flashmap.dots["dot"+k]._x = xpos[k]; flashmap.dots["dot"+k]._y = ypos[k]; locations_mc["thumb"+k].onRollOver = function(){ flashmap.dots["dot"+k].dot.play(); // here's where I'm trying to get all mc's with the same name to play flashmap.dots["dot"+k+"dup"].dot.play(); } locations_mc["thumb"+k].onRollOut = function(){ flashmap.dots["dot"+k].dot.gotoAndPlay("out"); // here's where I'm trying to get all mc's with the same name to play flashmap.dots["dot"+k+"dup"].dot.gotoAndPlay("out"); } }
Instance Names
I want to use this test function to have certain objects brought to the front.
I want all objects to be able to use this same function to be brought to the front but have a problem in determining which object evokes the function.
Code:
import flash.display.*;
import flash.events.*;
function Main() extends MovieClip
{
t1.index = depth;
addChildAt(t1,depth++);
t1.addListener(MouseEvent.MOUSE_DOWN, test);
}
function test(event:MouseEvent):void
{
setChildIndex(event.target, 3);
}
With the setChildIndex line I get this error...
"1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.displayisplayObject."
Do I have to wrap "event.target" as an Object? Does AS3 allow wrapping? And if so, how?
Thanks
Instance Names...
(I would put Flash CS3 in the title if I could )
if you call an object several times in the timeline (i.e. in several keyframes), is it really required that you give each an instance name? Is there a way to apply a instance name to the object across the clip?
also... is this proper syntax? It doesn't appear to be working
(["contentline" + _root.contentopen]).gotoAndPlay("s1");
it works in this...
gotoAndPlay(["content" + _root.contentopen + "-open"]);
Instance Names
Hi,
I have a function called by an interval which is working just fine but I can't seem to reference the instance outside of this function
Here is my code
var myInterval:Number = setInterval(this, "my_function", 1500);
function my_function():Void {
myLevel++;
attachMovie("my_mc","my_mc"+myLevel,myLevel);
this["my_mc"+myLevel]._x = 400;
}
and this is what I am trying to do with it in another function but it doesn't work.
if (this["my_mc"+myLevel].hitTest(_root.my_hit_area)) {
// do something here
}
If anyone knows how I can pick up on the instances of the movie clip in this hit test function I would really appreciate it.
Thanks
Instance Names
can you name an object _root.Name like you would a dynamic or input text box?
Instance Names Of MCs
When I load a MC via loadMovie or loadMovieNum how can I find out MCs instance name ? I know there is a property _name
e.g.
loadMovie("na2.swf", "_root")
how can I reference the movie ?
Dynamic Instance Names
Hi Everyone,
Well, I've been racking my brain on this one now for a couple of hours. I know I'm being an idiot but it's just not coming to me.
What I hoping to do is this. I have six movie clips, with six instance names, screen1, screen2, screen3 etc.
I want to be able to get properties from these movie clips, but I want to be able to create code dynamically. What I mean is I want to write something like:
(screen & x)._y = a;
where x is a variable... thus creating:
screen1._y = a;
hope that makes sense.. anyways.. for the life of me I can't get the syntax right, and now I'm starting to go batty!!
anyways.. any help what so ever would be most appreciated. Thanks in advance.
Pat
Instance Names As Variables
I am trying to have one movie clip give a play command to another movie clip based on a variable set by the previously played movie clip. I can make it work when I put the instance name directly into the script. However, when I switch out the instance name for a variable name it does not work. Is it possible to use a variable in the place where an instance name would normally go? I have tried using Tell Target and dot syntax.
Linkage And Instance Names
I have this piece of actionScript, and although it works, I need to know if there's some way to put the underline script where the bold instance names are....(the instance name shouldn't be an absolute as it currently is). Does this make sense to anyone?
onClipEvent (load) {
this.attachMovie("clientwk" add _root.itemsid add "d", "clientwk" add _root.itemsid add "d", 1);
}
onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse)) {
clientwk1d.gotoAndStop(2);
} else {
clientwk1d.gotoAndStop(1);
}
}
Variables And Instance Names
My movie sends data to the database if, and only if, the text is stored in an input text field labeled using the instance name (not the variable name). The fields are on separate frames and then shown altogether as a summary that can be printed. The only way I know how to do that is to label the input text boxes with the variable name. But if I have it labeled w/both the variable name and instance name, it won't send. If I get the user to enter data in the variable named boxes, how can I populate the summary where the text fields are labeled with the instance name?
Thanks
Variables From Instance Names
Hi, I'm trying to finish off a project for today, and I'm caught on this one last thing.
I'm trying to make a dynamic menu. There are 4 instances of the same 'button'. Actually a button inside a movie clip. Also in this movie clip is line of dynamic text that should hold the title of the button.
The variables that hold these titles ("but1", "but2", etc) are saved externally in a text file.
I can load the variables no problem. But how do I call up the variables into that piece of dynamic text?
The problem being, as it's an instance of the same button 4 times, I can't just call it directly. What I was thinking of doing was somehow calling on the instance name of that button ("but1" the same as the variable name) and using
-that- in the dynamic text. So whereever the text is (whether it's in "but1" or "but3") it will call up the appropriate variable according to the instance name of the movie clip it's inside...
... if that makes sense?
Problem being I don't know how to do that?
Any help would be great, thanks.
Variables Into Instance Names
Friends,
Let's say I have three variables:
x=1
y=2
z=3
I also have movieclips in the library called:
mc1
mc2
mc3
I want to attach them, but using a loop similar to the following but I'm not sure if it's possible or what the syntax looks like. Here's the theory:
_root.attachMovie("mc1"; "mc" + x; 50);
Would this attach an instance of mc1 and call that instance "mc1" on layer 50?
Thanks!!!
Using Strings As Instance Names
I have a clue:
I want to duplicate a movie clip and use previous duplicated instances to get properties frome them.
here's my code:
-frame1-
i = 2;
-frame2-
// name = cap2
name = "cap" add i;
// previous = cap1 (cap1 is the first movieclip)
previous = "cap" add (i-1);
// duplicate as cap2
duplicateMovieClip ("cap1", name, i);
setProperty (name, _x, <<how do I use "cap add i-1" properties?>>);
setProperty (name, _y, <<how do I use "cap add i-1" properties?>>);
i = i+1;
-frame3-
goto2
can u help me?
Instance Names As Variables?
Help please...
I have a textfield named myTextTx and a background that sits behind it named myTextGrow so I made the function below to trigger the myTextGrow effect to be used in a number of texts and backgrounds with my naming covention swapping the Tx and Grow parts of the instance names to trigger the right nnnGrow mc with the appropriate nnnTx textfield.
function txPulse() {
var fieldName = Selection.getFocus();
trace(fieldName);
var growName = fieldName.substring(0, fieldName.length-2)+"Grow";
growName.loopIt = true;
trace(growName); //show the correct instance name with target path
trace(growName.loopIt); //debug shows this as undefined, why?
growName.gotoAndPlay(30);
}
Any ideas why it doesn't work? The loopIt var is declared at the start of the nnnGrow MC and works because it stops at frame 29.
Thanks
Instance Names Not Sticking?
I am seeing some very strange behavior where I type an instance name for a pill button component, and it doesn't 'stick' - that is, if I leave the component properties, then click on the component again, the instance name is missing again.
I have not had trouble assigning instances to other components. I don't see how I could be doing this incorrectly... any ideas?
Duplicate Instance Names
I have a number of layers with a button in each that have instance names set. I'm using a string to keep track of the button clicked so I can disable it once it's clicked and re-enable it later if another button is clicked. This means it's important for multiple instances of the same symobol to have the same name.
What are the implications of taking the same symbol, in the same layer, but on different (identical) keyframes, and giving them the same instance name?
Thanks,
Frank
Help Re-Naming Instance Names
Hello,
Is it possible to give instance names to MC's from an external text file? So basically in the text file it says:
target1 = phil
and the in the .swf it somehow says the instance of :
Movieclip1's instance = target1
which would change the instance name of Movielip1 to phil
or something,
cheers,
Tom
Strings As Instance Names
can I use a string to call an instance?
4 example I need to call some MCs named a1, a2, a3, a4, etc to a20
that would be boring doing it by typing every single instance name so I want to do it by code.
I use a numeric variable set as 1 and then increase and every time I use the "add" command to the instancename string ("a") so it becomes a1 a2 a3 a4 right?
any clue on how to write the code?
Changing Instance Names On The Fly?
Is it possible in Flash 5 to change the name of an instance on the fly?
IE if I have "movie1" and "movie2", how do I change "movielcip1" to be called "movieclip3"
Thanks!
Rubbersharkman
Posting Instance Names
Hey, I need help with posting a value of an instance name into an url. Their are two names that must be posted into an url by pushing a button. I need to have to fields of text posted into a url. I need it to do...?username=(instancename)&password=(instancena me) so how can i get an instance name into the get URL (or any other one) command into ActionScript? Thanks 4 helping if you can.
Copying MC's And Instance Names Or..?
ive made this man who should not walk into rocks!ive made one rock hich the an absolutely cant walk into, yahoooo! BUT, I am to lazy to make alot of programming for each stone I put into my game. Therefor i ask:
is it possible to copy my rock + its instancename so that _root.rock is both the first and the second rock?
or
can I make a action saying if(_root.(rock1 or rock2 or rock3 or etc...)._y == 27 ...
Im using flash MX
on forehand
THANKS ALOT FOR LETTING MESAVE TIME
-Hashmus-
Something Wrong With These Instance Names ?
Would there be any conflicts with these instance names:
sound_mc
tracks_mc
track1
...the reason I ask is I have problem - and I i have checked my code 20 times and there is NOTHING wrong with it. I have used the code several times before in other projects.
If it isn't the names then I'm lost
TabIndex And Instance Names
Hi all,
I (obviously) have a form that I want to allow tab ordering through.
All of the text fields are input text with a var name, no instance name.
If I enter instance name, it shows up in the text filed (as I knew it would) but the tab order works.
If I only have a var name for the text field, and no instance name, the tabIndex won't work.
Here is a sample of code I have:
code:
_root.hello.helloForm.cName.tabIndex=1;
_root.hello.helloForm.cEmail.tabIndex=2;
_root.hello.helloForm.cAddress.tabIndex=3;
Basically, I need to give the input field an instance name..but how?
Does anyone have any suggestions?
Change Instance Names
Hi..
I have a button I would like to copy from one project and put it in antoher. I would like to make several copies of this button and then change the text for each of the copies so that they will function as other buttons.
HOWEVER: When I change the text of one of the buttons, the others will also change because thier instance names are all the same.
Is ther any way to change the instances names??
Thanks
-- KevinRyan
Flash MX
Dynamic Instance Names.
Hey guys,
Hope you can help me...
What Ive made in a movieclip (imageMC1) which just checks a variable and loads a jpg then stops.
I want to be able to duplicate this clip over and over with an incrementing instance name.
This is the code I have (which obviously isnt working).
Any suggestions would rock. Thanks!
x=x+1;
if(x > totalImages){
x=1;
}
_root.loadImage = x + ".jpg";
thisMC = "imageMC" + (x-1);
nextMC = "imageMC" + x
duplicateMovieClip('thisMC', 'nextMC', x)
Question About Instance Names
I have a swf that loads several button instances onto the stage and spreads them over several levels. I'm trying to write a script that will go through each level and check to see how many instances the swf has dropped on the stage.
My question is, is there a way tomake somthing like this...
LevelNumber = 1;
InstanceNumber = 0;
tempLevel = eval('_level'+LevelNumber);
tempInstance = ('instance'+InstanceNumber;
newPath = eval(tempLevel+'.'+tempInstance));
I want to get a loop going that will go through each level checking if the instances exist. As soon as it hits an undefined instance it will jump to the next level and continue checking.
Multiple Instance Names?
umm ive been experimenting on scripts that call out to instances with different names, but uses only one call script.
so ive done it like this, box1, box2, and box3 and so on and so forth
but what i cant do is to use, lets say box++?
is it possible to use a script that represents instance names with
accumilating numbers?
example:
box1, box2, box3, box4, box5...
_root.box++.do whatver
umm oh yeah....is this still a noob question?
haha tnx dudes!
Variable Instance Names
In a menu header I'm making for a site, I want it to import a text file that has each menu item and link URL, then create MC buttons for each of them and distribute them evenly across a certain y value with certain endpoints.
Anyway, I'm getting started on the code to read the text file and create the MC's. To save myself the hassle, I will put the number of links as the first var in the imported text file. I make a for statement, counting up from 1 until it has reached the total number of links, and want to make an MC for each one. So, I createBlankMovieClip, using "linkname_"+i to create it using the current iteration of the for statement. However, how do I call that to add a text field to it?
linkname_+i.createTextField() doesn't seem to work.
Renaming Instance Names
Hello. I have a chat room. And one of the problems that I have with it is that I have a var set up for a picture to apear everytime the person chooses an avatar. but I have different avatars with different instance names. I need it so that when the person clicks on that avatar it changes the instance name from "avatar[1]" to "chosenavatar". Please help.
Strings To Instance Names
I need help!
Here is the senario:
I have 5 movies clip instances (mov1,mov2,mov3,mov4,mov5).
I have a number (num), and a button (but1).
Everytime you press the button, a random number from 1 to 5 is assigned to num. Its all good to this point!
Here is where my problem is;
I want to adjust the _alpha property for corresponding movie clip.
here is the wrong syntax: mov(num)._alpha = 0;
How can I get the value of num added to the string mov to make the instance name?
Is there a special way to concatenate strings to instance names?
I hope I'm being clear.
Changing Instance Names
How do you change the instance name of a movieclip with actionscript?
I have been using:
code:
mc1._name = "mc2";
But it doesn't seem to be working, and so I looked up the help document on "_name" and it only mentions it as being used in buttons.
_name (Button._name property)
What is the syntax for changing the instance names of movieclips?
Thanks
Ross
Instance Names And Actions
Hi.
I have several buttons (btn1,btn2,btn3 etc...)
To make my as code less complex, i made this code:
Quote:
function btnRollOver(z){
if(newSite!=[z]){
buttonName.gotoAndPlay(1)
buttonName2.gotoAndStop(5)
}
}
buttonName and buttonName2 are variables that will have values like "btn1", "btn2". Know i know that it try to play an mc with the instance name "buttonName", but how can i make i play the mc with the instance name that the variable "buttonName" contains...?
Any help would be great.
Magnus
Getting Instance Names Dynamically
This should be pretty simple, but I'm not sure which functions I should be using.
All I need is to be able to get the instance name of a movieclip when I click on it. I'm sure it has something to do with targetPath, but not sure on how to utilize it...
This would be enough to get over the hump.
Thanks in advance!
Variables And Instance Names
I am trying to control my buttons using variables, but I'm not sure if this is right.
On button 1 I have this action:
Code:
on (release) {
portfolioselection = "Monkey"
this.enabled = false;
}
On button 2 I have this:
Code:
on (release) {
portfolioselection.enabled = true;
portfolioselection = "Thornwick"
this.enabled = false;
}
In theory, when Button 1 is clicked it should be disabled. When Button 2 is clicked it should be disabled, and Button 1 enabled. But this doesnt seem to work.
I'm not sure where I'm going wrong here. Am I targetting the variables incorrectly?
PS - I deffinatley need to use Variables because I have lots of buttons, this is just a simplified example.
Thanks,
Jamie
|