Get 'swf Name' From 'instance Name'
hi guys,i'm using a componet that make a cool effect, but it won't let me add more function to the buttons, like loading external swf's.i have 3 buttons: -button1 (with instance name 'button1' that calls button1.swf)-button2 (with instance name 'button2' that calls button2.swf)-button3 (with instance name 'button3' that calls button3.swf) and the component get the button target with a function +/- like this: this.btnTarget = this._parent[this._targetInstanceName] and i wanna determine wich swf to load with a similar function. the component code is: ActionScript Code: #initclipmoveBtnClass = function () { this.init();};moveBtnClass.prototype.init = function() { this.btnTarget = this._parent[this._targetInstanceName]; this.cpnt_name = "cpnt_move_btn"; this._visible = false; if (_global.cpnt_move_position_arrayX == undefined) { _global.cpnt_move_position_arrayX = new Array(); _global.cpnt_move_position_arrayX.push(this.btnTarget._x); _global.cpnt_move_position_arrayY = new Array(); _global.cpnt_move_position_arrayY.push(this.btnTarget._y); } else { _global.cpnt_move_position_arrayX.push(this.btnTarget._x); _global.cpnt_move_position_arrayY.push(this.btnTarget._y); } this.btnTarget.onRelease = function() { this.positionArray = _global.is_btn_horizontal ? _global.cpnt_move_position_arrayX : _global.cpnt_move_position_arrayY; for (i=0; !_global.isOk && i<_global.cpnt_move_position_arrayX.length; i++) { if (Math.abs(this.positionArray[i]-this._x)<1) { _global.isOk = true; _global.targetP = i; } } _global.isOk = false; };};Object.registerClass("moveBtn", moveBtnClass);#endinitclip and i wanna add something like this: ActionScript Code: this.btnTarget.onPress=function(){ loadMovie(<font color="red">[function that get de instancename]</font>+ '.swf',"_root.contents_mc");} help with the function that get the instancename, plz
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 05-01-2004, 03:59 PM
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....
Access Property/function Of Instance From Inside Another Instance
Might be something really obvious, but I'm still trying to get my head round as3...
I need to call up a property and function of another instance of the same class, similar as in as2 (called from within "_root.instance_mc1"):
ActionScript Code:
_root.instance_mc2.someNumber = 0;
_root.instance_mc2.someFunction();
Now in AS3 I can access the object (extending sprite) itself (and inherited properties like x) by using:
ActionScript Code:
this.parent.getChildByName("row2").x
but if i try to access public variables/functions from that object (this.parent.getChildByName("row2").someNumber) I get Error 1119: Access of possibly undefined property someNumber through a reference with static type flash.displayisplayObject.
Anyone know how I can get this to work?
Code In One Instance Is Referencing The Previous Instance
I have the following code in a button symbol:
on (release) {
gotoAndStop (2);
_root["answer" + this._name.substr(1)] = "true";
}
I also have an instance of the button in 2 consecutive keyframes. The first instance is named "Q5" and the second instance is "Q6".
I expected the code: this._name.substr(1)]
to reference "5" and "6" from the instance names (Q5 and Q6), but instead instance "Q6" is referencing "Q5"!
The *really* strange thing, is that when I insert a blank keyframe between the two original keyframes, the code works perfectly!
Does anyone know what's happening?
[MX04] Get Instance Name Of Rolled Over Array Instance
Hi
I am willing to do a rollover image gallery which enlarges image on rollover event and shifts the neighbouring ones aside..
Here is the code so far
Code:
_root.bttn.onRelease = function() {
createGallery();
};
function createGallery() {
var row11:Array = new Array("DSCF5659", "DSCF5807q", "DSCF5773q");
for (i in row11) {
_root.createEmptyMovieClip(row11[i], _root.getNextHighestDepth());
_root[row11[i]].loadMovie("segi/"+row11[i]+"small.jpg", [row11[i]]);
_root[row11[i]]._x = i*150;
}
}
_root.onEnterFrame = function() {
function roll() {
var row11:Array = new Array("DSCF5659", "DSCF5807q", "DSCF5773q");
for (i;i<row11.length;i++) {
_root[row11[i]].onRollOver = function() {
this._xscale += 10;
};
}
}
roll();
};
What I would like to do is to:
ask flash which particular movieclip was rolled over , what is its instance name and than perform string operation to get a number (order) of that clip (I am naming all dynamically with image name + number in order)
Can anyone help me please ???
Thanx in advance
How Do I Copy A Sprite Instance Into A BitmapData Instance?
I apologize if this is covered elsewhere: I just don't even know what terms to search on to find what I'm looking for...
I have a sprite that receives various user-drawn lines on it during runtime. I would like to be able to copy this Sprite into a BitmapData instance, then send the pixels from the BitmapData instance to a PHP script. I think I'll be all right with the PHP end of things, but I just don't know how to copy my Sprite into a BitmapData.
(If there were a way to just use BitmapData and use the moveTo, lineTo, mouseX, mouseY, etc, methods, then I'd do that, but I don't even know if that's possible...Obviously, I'm not as well-versed in AS3 as I'd like to be.)
Thanks in advance for any help!
Instance On Top / Movie Instance Depth
Hi everyone,
I would like to know how, if possible, i can get the depth of a movie instance. Basically I just want to make the movie instance clicked on on top of all the others. I was going to try to do this using the swapdepths action but if anyone knows of a better way please tell me!
thanks a lot
jordan woolley
Returning The Instance Name Of A Class From Within The Instance
Hi,
I'm trying to do some error reporting in my actionscript.
I have a class MyData which can be instantiated several times over in each project e.g.
var myData1:MyData = new MyData();
var myData2:MyData = new MyData();
In the error reporting I have put statements like
trace("MyData.loadData reports error.... message...");
However, I'd really like it to return the instantiated name, not the generic class name so that I can trace errors to the particular instance that is failing. Does anyone know how to do this? I've tried
trace(this.toString() + " reports error.... message...");
but I just get a name of [object object] which isn't that helpful!
Many thanks!
Removing Instance X Inside Instance X
In Flash CS3 in library I have a MovieClip symbol Help (exported for AS).
The function below opens an instance of the symbol when the button is clicked.
ActionScript Code:
function showHelp(e:MouseEvent):void {
var helpwindow:Help = new Help();
helpwindow.x = 50;
helpwindow.y = 50;
addChild(helpwindow);
}
This works and instance "helpwindow" shows on the screen.
Now inside the symbol Help i have another button which will run a function that would close that instance. How do I get rid of that instance? I was trying with removeChild but errors occurr.
ActionScript Code:
function removeHelp(e:MouseEvent):void {
removeChild(MovieClip(parent).helpwindow);
}
Quote:
TypeError: Error #2007: Parameter child must be non-null.
How To Call The Instance Name Inside That Instance?
Ok this is what I want...
I am inside an instance of a movie clip. And I want to access the properties of this movie clip. Now the problem is (if) I don't know the name of the instance of the movie clip (suppose I create the instance of the movie clip on the fly!!!), how do i refer to the name of the instance.
Is there something called this. in actionscript?
Any help would be appriciated!!!
Sushubh
Dynamic Instance Name Vs Manual Instance Name?
Hello,
I would like to access this object (taken from Debug > List Objects of in flash player)
ActionScript Code:
Target="_level0.promotion0.loader_mc.instance87.promo TXT"
This is what I am trying to access it with:
ActionScript Code:
trace( this.getChildByName("promotion0").loader_mc.getChildByName("instance87").promoTXT.text );
Error:
ActionScript Code:
1119: Access of possibly undefined property loader_mc through a reference with static type flash.displayisplayObject.
what is the correct way to do this?
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 Name Instead Of Instance Number
hey there,
the following code returns strange names for the instance: I get 'instance61' and 'instance55' when clicking the button in the MC named 'tabber'. I would expect to see 'tab' and 'tab2'.
Is there a way to get the instance name instead of the instance number?
cheers!
PHP Code:
package { import flash.display.MovieClip; import flash.events.MouseEvent; import flash.display.SimpleButton; public class content extends MovieClip { public function content() { //content.stop(); var tab:tabber = new tabber(); tab.x=118; tab.y=75; tab.butt.addEventListener(MouseEvent.CLICK, ms2); addChildAt(tab,1); var tab2:tabber = new tabber(); tab2.x=228; tab2.y=75; tab2.butt.addEventListener(MouseEvent.CLICK, ms2); addChildAt(tab2,1); } function ms(event:MouseEvent):void { trace(event.target.parent.name); } }}
Any Way To For A Class Instance To Ask What Its Instance Name Is?
Hey. I have a class which needs to create a movie clip on the stage. Since each instance of the class will only ever have 1 movie clip on the stage at a time, it seems reasonable that I have the instance create a movie clip with its own name, prefixed with "mc_" or something of the sort.
Here's where I don't know quite what to do... How do I get at this information? For instance, when you a dealing with an XMLNode, you can simply use...
the_answer = xmlNodeInstance.nodeName;
...I know the analogy fails, but hopefully you know what I'm looking for.
Thanks!
Calling An Instance Within An Instance
Hi,
I've got 3 movieclip buttons with instance name, "btn1", "btn2" and "btn3". Inside these clips is another movieclip named "mousedetect".
How do I use a loop on the "mousedetect" movieclip to initiate an action? Without a loop it will look like this:
btn1.mousedetect.onRelease=functiion(){
btnRelease();
}
I've tried something like:
for (i=1;i<=3;i++){
this["btn"+i].mousedetect.onRelease=function(){
btnRelease();
}
}
but an error shows up, what should be the correct syntax?
Thanks!
Want Opening Movie Clip Instance To Close Underlying Movie Clip Instance
Just so you all know, I'm one of three people in our company that uses Flash and I'm considered "the expert". However, we don't do more than a few Flash projects a year, so my scripting knowledge is very, very green. Thanks in advance for your patience.
I have 22 buttons that play an assigned movie clip from the library. I suspect I'm building these things the wrong way (probably true), but here is how each button is constructed....
Each instance that I'm calling a button is actually identified as a movie clip intance with a button in it. It sits on its own layer. When I double-click an instance, several layers are displayed, the majority of which belong to the presentation of the movie clip. The clip lasts five frames.
The first frame consists of blank keyframes for each layer except for one layer that has stop() assigned to the frame and another layer with the actual button. The layer with stop() at frame 1 is then blank for the next three frames, and then another stop() on frame 5 (the last frame).
The button layer lasts all five frames. Here's the script for "display1980":
on (rollOver) {
_root.display1981.gotoandstop(1);
_root.display1982.gotoandstop(1);
_root.display1983.gotoandstop(1);
.
.
.
_root.display2003.gotoandstop(1);
_root.display2004.gotoandstop(1);
_root.display2005.gotoandstop(1);}
on (release) {
_root.Play();
play();
}
For each instance, there is no line of script that refers to itself. In this example for display1980, "_root.display1980.gotoandstop(1);" is not used.
As I mentioned earlier, each instance is on the main stage on its own layer. I've done this with only eight of my instances, so there are now eight layers. (There are--in fact--more than eight layers, but those are not part of this issue.)
The script I created does the job of getting rid of any previously displayed movie clip, but I created a new conumdrum: If I rollover any other button, the currently displayed clip closes. I've tried replacing "on (rollOver)" with "on (press)" but that doesn't work.
Like I said, I suspect I'm buildng this wrong. Is what I built a waste of time, or can it be salvaged? Or, is there a much better and efficient way (and I suppose there is) that can be described so that my green experience can absorb to good effect?
Accessing Movieclip Instance Within Another Movieclip Instance
Accessing library movieclip instance within another library movieclip instance issues.
I have a movieclip in the Library called menuBar. In the menuBar mc I added two buttons. I want to be able to click on each button to play a video for each corresponding button. When I mouse over the button the pointer turns into the hand, suggesting it recognizes it as a button. But I'm unable to access the button (menuBar.button1 in AS2) in my code, I'm using AS3. Any help would be much appreciated. Thank you for your time.
Getting An Instance Name
hello folks,
i am working on a flash site that duplicates a movie clip and gives it a name according to the original movie clip plus the loop . i.e original clip square, new name square1, square2 etc.
these are all draggable, and it all works ok, but i need to know when being dragged which of the clips is being dragged, i.e. i need to get its instance name.
ideally i want to be able to do something like:
onPress(
moviename=Getinstance name;
)
clearly getinstance name isnt possible but you get the picture..
thanks in advance
bob splendid
http://www.sensoriumdesign.net/
About Instance Name.
Dear all,
Can I name a instance name by running a PHP file?
That means the instance name is named by the PHP file.
** INSTANCE NAME? **
hello,
please help me...
i want the each MC to find out its own instance name and play the correspoiding MC...
for example, if the MC instance called steve is rolled over, the another MC called steve_dot is played, too.
on (rollOver) {
Mouse.hide();
this.gotoandplay(2);
startDrag ("cross");
x = this._name;
_root.teams.x+"_dot".gotoandstop(2);
}
this does not work!! why?
i've been stuck for a week sorting this out...
any help appreciated.
reynard
An Instance
"Place an instance of the movie into your stage"
how do you do this ???? what is an instance..??
Instance Name
i have an script what duplicate a movie
but i will give the movie an instancename when
it will be duplicate
how can i do that
Instance Within An Instance
How do I make an instance load within an instance? Lets say I have instance abc + def. Both of which are in, yet another instance off of the main stage. In instance abc..I have instance def which will play at the end of instance abc. Inside that instance, I have it going back and playing part of abc again. How do I make this happen? If they were on the same field, in instance def...I would have it tell target /abc ; but since it is inside of abc, it will have to be /(main stage instance name).abc I dont know what to put there. I need to know how to make an extension from one instance to another..if its a dot or a / or something. I dont get it.
Instance
I'm following a tutorial to the letter which tells me to go into Modify>Instance. Where oh where is Instance. Basically I want to take a photograph and wash it out so that as the movie runs, it appears to fade in. BTW, I'm using the new FlashMX.
An Instance
I know this is probably a dumb question but how do I control an object loaded in actionscript. Like if i'm loading a jpg, how can I give it a name so that I can set the x,y coords and resize it.
i'm using
loadMovie("./images/image"+whichPic+".jpg", 1);
but once it's loaded how do I alter it's attributes?
I don't want to load it into a target movie clip that already has an instance name. Is there someway of doing this?
Instance Name 0
Aargh! Flash MX notation is getting in the way:
I want to tell a movie clip named 0 (or 1 or 2, same problem) ... to move its _x position. Yet when I declare:
_level0.nav.0._x = 200;
...it says that's invalid code (i assume because it thinks by using zero I'm declaring a frame on mc "nav" ... no no no!
I tried this: "_level0.nav.0" = 200; but that doesn't work either.
How do I convince Flash that I'm stating an instance name and not a timeline frame?
The reason I need this is because I'm doing an elastic menu system that finds the previous clip command by finding the instance that is named exactly one less than the one the action is taking place in.
Instance Name Help?
is there a way to call instance name in action script? I want to click on a button, and that button's instance name is sent to a function. thanks in advance guys and gals!
Instance Name
Hi there,
I've got a loop, and in that loop I create a variable (10 times), with the result
blok1
blok2
blok3
...
blok10
How can I put those values in a string like
_root.blok1._alpha=50; ?
I need this because it'll apply on 70 cubes...
friendly greetings, robin
Instance Name...
Is there a way to give an instance name to a symbol without it already being on the stage? ive tried exporting it for actionscript but i dont think thats right cause its not working...
any help would be greatly appreciated.
Lorren Biffin
How Do You Name An Instance.
In the actions menu I can choose a button that I created, but it looks like this:
"Actions for [No instance name assigned] [myButton]"
How do I assign and instance name, and what does that even mean?
Instance Name?
I am trying to make some text scroll, simple enough, and it works fine in its own flas file, but once i build it within my movie it gives me this error?
WARNING: This movie uses features that are not supported in the Flash 4 player
Symbol=scrollTwo, Layer=Layer 14, Frame=21: Flash MX Text Field Instance Name
It doesnt seem to like the Field Instance Name, but the turotial call this within the scroll button scripts. This is the code on the buttons
on (release) {
scrolltext.scroll -= 1;
}
Can someone explain this to me, and maybe help me get it going
Thanks
Ffoeg
How Do I Name An Instance?
I;m so close to learning something but I don't know how to name instances. I mean, I've looked, I tried the Flash tutorials, all kinds of stuff. I've been using Flash 5 but I;m trying MX now.
Thanks a bunch,
? Right ? Instance Name
How can (and is it possible) well, actually I don't know how to explain, but I guess this line of code will show you about what I mean
_root.("item_" add y)._x = _root.("item_" add x)._x;
x and y parameters are can be modified, and I want to be able to check their _x position, but I don't know how to call their instance name.
Instance?
how can i createb a instance hope i get a nice explenation
What Does /instance Name Mean?
hi,
i am looking at some actionscript examples and came across one script with this:
Code:
setProperty ("/f4", _x, Number(f4x*3)+6);
setProperty ("/f4", _y, Number(f4y*3)+6);
what do they have / before f4? f4 is the instance name of a created movie clip.
thanks
Get Instance
hi friends,
I got a little strange situation here..
is there any way thay I canget all the instance names of the movies that are placed inside a movie..
lets say I have a Movie (A) .. an in it there are 3 movies (one) (two) (three).. now the situation is that, that I dont know the instance names of those 3 movies.. or may be I dont know at all that how much movies are on there (in movie "A")..
so is there anyway that I can get those instance names ?
Thanks friends..
Instance Name Of MC
Is there a way to find ALL instance names of a particular MC is within flash, nomater what frame they may be on?
Instance
i heard about creating different instances of a symbol
how to do this in mx prof 2oo4
faith
If Instance Contains...
I have mc's name rock1, rock2, rock3...so on and so on. so, the point. Is there a way to make a hitTest that targets an instance that CONTAINS the work rock? If im not clear tell me.
Instance Name
Can an instance name be allocated to a symbol through hitTest or buttonDown, etc ?
EG: Like an instance name given to one of a random amount of symbols
What's The Instance Name Of My Value?
Got this code:
Code:
var movies = ["ball_mc", "ball2_mc", "ball3_mc"];
var distances = new Array();
var centerX:Number = center_mc._x;
var centerY:Number = center_mc._y;
//-----------------------Find furthest distance-------------------------------------
var max_dist:Number = 0;
for (var i = 0; i<movies.length; i++) {
var dx:Number = this[movies[i]]._x-centerX;
var dy:Number = this[movies[i]]._y-centerY;
curr_dist = Math.sqrt(dx*dx+dy*dy);
distances.push(curr_dist);
if (curr_dist>max_dist) {
max_dist = curr_dist;
}
}
//---------------------------Sort distances into the new array-------------------------
distances.sort(sortDescendingNumbers);
function sortDescendingNumbers(object1, object2) {
return object2-object1;
}
trace(distances)
What "distances.push(curr_dist);" is doing: placing in a new array the furthest distances we found in the first bit, then I apply a function that will sort these values as descending numbers in the array.
Now: How do I know the instance names related to these values stored in the new array?
Same Instance Name
is there a way to make 10 totally differnt movie clips all have the same instance name.
Because i want to do a hittest on all of them and if all of them turn out to be false that means that the object is not on the map.
Instance Name
Ok, so I have tried searching, but I dont think I am searching for the right thing.
I have a string "page_mc2" which is the name of movieclip instance on my stage.
How do I make it reference the instance itself. So I can access the attribues in the instance.
------ Code ------
// so this becomes "page_mc2"
var str_next_mc = "page_mc"+(_parent.selected_mc.nIndex+1);
// this doesn't work cause str_next_mc is a string... it needs to be the movie clip... help please!!!!
text_txt.text = str_next_mc.attributes.str_mc;
Get Instance Name?
Hi. I hope someone can help me with this problem. I've been trying to solve this for ages and just can't work it out.
I have 25 instances of a movieclip "mc", named mc0, mc1, etc. Each one has a variable "mctype", which is selected randomly from an array. On a completely seperate frame from the one in which the clip is duplicated, I to be able to click on any instance, and have a text field "mctext" return the mctype associated with the instance that's been clicked. mctext is not a child to mc; it is seperate.
This is the code I'm currently using for clicking mc.
Code:
for (n=0; n<25; n++) {
this["mc"+n].onRelease = function() {
mctext.text = this.mctype;
}
};
Currently, this returns "undefined". If I change the third line to "mctext.text = mctype;" it merely returns the mctype for the final instance. However, I've noticed that if I try, say, mc8.mctype, I will get mctype for that actual instance.
How can I get it to look up mctype for the instance I've actually clicked though?
Instance Name
how to call instance name inside of movie clip? i want to make buttons and use it in calling external file but i made my buttons have animated entry and name instance of "b1". but my button didnt work but if i remove it inside the movie clip
the buttons work but no nice entrance T_T pls help me
thx in advance
sorry for my bad english im asian >_<
[F8] Get Instance Name
Hi, I have an instance of a MC and I can't figure out how to make it return its name. I tried:
Code:
onRelease=function()
{
trace(this.name);
}
But that just returns "undefined".
What should I be using? Thanks.
Instance Name
Hi there..
in my movie I got an MC with the Instance Name: "partone"
there is a button on this MC. There is AS on that button (on release..)
In this AS I want to use the Instance Name "partone" but I want it to
be detected automatic so I can use the button several times and not
to make a new on for each part.
how can I get this Instance Name to use in my AS?
thnx!
_j
[F8] How To Tell Which Instance I Am In?
In my project i create a grid of 100 squares dynamically through actionscript using something like:
_root.createEmptyMovieClip("allGrid", 1);
var newBox:MovieClip = allGrid.attachMovie("box", "box"+count, count);
so it names the 100 squares box1 to box100. when i roll over one of the squares, how do i tell which instance i am rolling over?
i.e.
if inside the mc i put:
this.onRollOver = function(){}
how do i tell which instance "this" is?
if i use
trace(this);
it will tell me what this is, but, how do i pass the name of that instance that i am in to somewhere else in the program?
'Instance Of' Name
is there a way to get the 'instance of' name (NOT the 'instance name' = mc._name) of an mc?
|