Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Creating Functions And Passing Instance Names To It.



I have a bit of script that I'd like to turn into a function. I need to call this function from a button located within a movieclip (this clip is the one the function will act upon) I need to pass the instance name of this clip into the function. Here is what I have, placed on the main timeline, but it's not working:


Code:


function moveWindow(window) {
_root.window.gotoAndPlay("Open");
_root.createEmptyMovieClip("windowAnchor_mc",0);
_root.windowAnchor_mc._y = _root.window._y;
var winanch:String = _root.windowAnchor_mc._y ;
trace (winanch);
_root.window.onEnterFrame = function() {
_root.window._y -= (_root.window._y-_root.News_Window_mc._y)*.5;
_root.News_Window_mc._alpha = _root.News_Window_mc._alpha-10;
_root.Photos_Window_mc._alpha = _root.Photos_Window_mc._alpha-10;
_root.Store_Window_mc._alpha = _root.News_Window_mc._alpha-10;
_root.Shows_Window_mc._alpha = _root.News_Window_mc._alpha-10;
_root.Lyrics_Window_mc._alpha = _root.News_Window_mc._alpha-10;
trace("hello");
trace (winanch);
if (_root.window._y == _root.News_Window_mc._y) {
delete _root.window.onEnterFrame;
}
};
}


And then on my button

on (press) {
moveWindow(this);
}

or moveWindow(_root.Contact_Window_mc);

Also, as you can see I have a couple of repetitous commands (changing the ._alpha of 5 movie clips). If I were in php, I'd stick the names of those in an array and do a "for each" loop on it to cut down on all of that code - is there a way to do that in flash?



DevShed > Flash Help
Posted on: January 11th, 2005, 10:04 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Passing Instance Names To Functions
Howdy!

I'm new. Not very bright either. Learning functions after wandering in the darkness for a very long time. I have an instance on the stage that was created using the duplicateMoveClip method. Users can drag these instances to positions on the stage for later use. It would be nice to have them simply pass off the task to a function in the main timeline, but I can't get it to work.

Here's the function:

code: function SensorDrag(ClipName:String){
_root.ClipName.startDrag();
}



Here's the actionscript for the instance:

code: onClipEvent (load) {
var ClipName:String = this._name;
trace (ClipName);
startX = this._x;
startY = this._y;

onClipEvent (mouseDown){
_root.SensorDrag();
}

If I can get this to work,, I should be able to tackle more complex issues. What do I need to do?

Instance Names And Functions
im trying to use a function in a timeline to identify a symbol and do some stuff with it.

on the movie clip
onClipEvent (load) {
_root.test(_name);
}

on the timeline
function test (name) {
name._x=300;
}

this is not working. I basically want to have about 30 movie clips that all try to use the function "test"
i do not want to put the function on the movie clip.

i've tried some different things, such as eval, but can't get anything to work.

please help

jason

Sending Instance Names To Functions.
How do you send instance names to functions?


This is just a simple example, but I thought something like this would work:

code:

thisfunction ( "movie_mc" );




function thisfunction ( x ) {

x._visible = false;

}


It didn't. I've tried a few variations, but I'm not getting anywhere.
Where am I going wrong?

Assigning New Instance Names AND Using Them In Functions
Hey, I want every new instance created to have a unique name, then I want to be able to interact with that unique instance to drag it, color it, size it, etc. Everything I've tried has failed--do you guys have ideas? In other words, how can I change "newCircle" below to, say, "newCircle1" and then use "newCircle1" to call the function?


Code:
circle_btn.onRelease = function():Void{
attachMovie("mcCircle","newCircle",getNextHighestDepth());
trace( newCircle);
newCircle.onPress = myOnPress;
newCircle.onRelease = myOnRelease;
};

//====================== DRAG AND DROP FUNCTIONALITY =========================

myOnPress = function():Void {
//trace( this );
this.startDrag(false);
};
myOnRelease = function():Void {
this.stopDrag();
};

Passing Instance Names To A Function
Hi guys. New at this.

I want to create a function that animates a dynamic text field. I will create a few instances of an empty movieclip and give them all instance names. Then for each instance, I want to do create a text field filled over time by the function.

Question is this:

How do I tell the function what the name of the textfield is? I'm having problems with paths. I thought I could use this.textfieldname.text = 'texthere' --- but that doesn't work. It seems I need an absolute path:


PHP Code:



_root.something.textfieldname.text = 'texthere'; 




Can I pass the "something" as a variable to the function? How?

Bless all who respond,
J.

Passing Dynamic Instance Names In 1 Param
I am trying to pass a MC target to a function through one parameter... The problem is that there are multiple variables that are requiered to reference the MC properly.

is there a way to conjugate all my variables and pass the target reference to my function in one param? If so, how does it need to be sent to the function and how does it need to be reference from the function to an actual MC.

Thanks

Question About Passing Instance Names Through Vars
Here is what I am trying to do.

I set a variable. the variable contains an instance name for a movie clip.

Later on another movie clip plays and when it gets to a certain point, I want to to be able to tell the another clip, whose instance name is stored in a variable, to play.

I've tried

var clip_to_play = "playme";
_root.eval(clip_to_play).play();

It doesn't seem to work. Any help is appreciated.

Thanks

Passing Variable Names & MC Properties To Functions
I'm having trouble getting a function to understand the properties of an MC I'm passing to it. I'm using this...

Code:
function repelObj(repelTarget) {
this.onEnterFrame = function() {
var xdistance = repelTarget._x-this._x;
var ydistance = repelTarget._y-this._y;
distance = (xdistance*xdistance)+(ydistance*ydistance);
force = 9999999999/(distance*distance);
apply = force/distance;
movex = (xdistance*apply)+movex;
movey = (ydistance*apply)+movey;
repelTarget._x += movex;
repelTarget._y += movey;
}
What I'm passing to it is the _root path of the name of a duplicated MC. When I use trace(repelTarget) to tell me the name of the variable, it works fine, and I've double and triple checked that the MC exists on the stage, my having the MC trace its name when created. Yet when I tell it to trace (repelTarget._x), I get "undefined." Why can my function tell the MC's name, but not its properties?

EDIT: I think I've just figured out it has something to do with getting the relative path right, since the full MC instance name turned out to be something like _level10.etc.etc. Hope that helps.

Passing Movie Clip Names To Functions
Hey, i'm trying to create a game where I need to be able to spawn a bunch of different kinds of enemies so i figured i'd write a function to create an enemy. I've attached what I came up with.

now i'm assuming the problem is with these 2 lines. Am I allowd to pass data to a function and use it this way? Is there a special way I'd go about doing it? Can anybody suggest a better way to write this code? Thanks.


this.createEmptyMovieClip(_root[enemyName], this.getNextHighestDepth());
_root[enemyName].attachMovie(_root[enemyPicture], "enemyBlue1", this.getNextHighestDepth());








Attach Code

var enemyCounter:Number = 0;

function createEnemy(enemyName, enemyPicture, xvar, yvar){
this.createEmptyMovieClip(_root[enemyName], this.getNextHighestDepth());
_root[enemyName].attachMovie(_root[enemyPicture], "enemy"+enemyCounter, this.getNextHighestDepth());
enemyCounter++;
_root[enemyName]._x = xvar;
_root[enemyName]._y = yvar;
}


createEnemy("slimeSmall", "enemyBlue", 200, 200);

























Edited: 05/21/2007 at 01:55:51 AM by Gooms9

Creating Dynamic Instance Names
Hi,

I have a mc called "qu" on the stage which contains text boxes with instance names q1,q2...q10 and a1,a2...a10. I want to target these boxes from the main time line. However, rather than just targeting each individually from the maintime line like this

q1._visible = false

i want to target them dynamically using a counter from the maintime line. ie:

question = this["q"+i]
qu.question._visible = false

This does not work. However when i apply the following code inside the qu mc rather than the maintime line it does work:
this["q"+i]._visible = false

I hope this is clear what im talking about. can anyone help me to target these text boxes from the main time line properly?
thanks
john

Trouble Creating Unique Instance Names For AttachMovie
Hello everybody! 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;
cell3_isUsed = false;
cell4_isUsed = false;
cell5_isUsed = false;
cell6_isUsed = false;
cell7_isUsed = false;
cell8_isUsed = false;
cell9_isUsed = false;
theDepth = 100;

//cell_status : 1==X 2==O nil==0(zero). This keeps track of which cell belongs to X and to
//O, so that the checkForWinner function can keep track of when someone has won
var cell1_status = 0;
var cell2_status = 0;
var cell3_status = 0;
var cell4_status = 0;
var cell5_status = 0;
var cell6_status = 0;
var cell7_status = 0;
var cell8_status = 0;
var cell9_status = 0;

//this function is incomplete, it will check to see if any user has a tic-tac-toe and declare the winner
function checkForWinner() {
if ((cell1_status && cell2_status && cell3_status) == 1) {
whosTurn_txt.text = "Player 1 wins.";
}
}

//this function is responsible for alternating turns between players, not much else to say here
function switchTurns() {
if (_global.whosTurn == 1) {
_global.whosTurn = 2;
} else if (_global.whosTurn == 2) {
_global.whosTurn = 1;
}
}

//this minor function simply gets an x and y value for the placement of the X or the O, if
//you look further down at the markItUp function these values play the part of positioning
//the X or the O in the center of whichever cell the user selected
function placement(which_cell) {
placementX = which_cell._x;
placementY = which_cell._y;
}

//this is the function that is screwed up. the first X and the first O that are put onto the
// stage are great and do what it is supposed to do, but after that what I'm doing (due to
// my lack of coding knowledge ) is putting multiple movie clips on the stage with the SAME
// instance name. this is where the problem lies and where I need help figuring out how to
// give each movie clip its own unique name
function markItUp(which_cellStatus) {
if (whosTurn == 1) {
attachMovie("marker_X","xMarker",theDepth);//need to somehow declare unique movieclip instance names
_root.xMarker._x = placementX+8;
_root.xMarker._y = placementY+12;
which_cellStatus = 1;
switchTurns();
} else {
attachMovie("marker_O","yMarker",theDepth);//need to somehow declare unique movieclip instance names
_root.yMarker._x = placementX+8;
_root.yMarker._y = placementY+12;
switchTurns();
}
}

//this function handles all the above functions when a user clicks on a cell
function clickedCell(which_cellIsUsed, whichCell, cell_status) {
whichCell.onRelease = function() {
if (which_cellIsUsed == false) {
placement(whichCell);
markItUp(cell_status);
which_cellIsUsed = true;
theDepth++;
} else {
whosTurn_txt.text = "Pick a different cell";
}
//checkForWinner();
};
}

//sets up the clickedCell function
cell1.onPress = clickedCell(cell1_isUsed, cell1, cell1_status);
cell2.onPress = clickedCell(cell2_isUsed, cell2, cell2_status);
cell3.onPress = clickedCell(cell3_isUsed, cell3, cell3_status);
cell4.onPress = clickedCell(cell4_isUsed, cell4, cell4_status);
cell5.onPress = clickedCell(cell5_isUsed, cell5, cell5_status);
cell6.onPress = clickedCell(cell6_isUsed, cell6, cell6_status);
cell7.onPress = clickedCell(cell7_isUsed, cell7, cell7_status);
cell8.onPress = clickedCell(cell8_isUsed, cell8, cell8_status);
cell9.onPress = clickedCell(cell9_isUsed, cell9, cell9_status);
Sorry, I know it's a lot of code for someone to look at without being paid, but I would appreciate any help anyone could provide.

~Jason

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....

Dynamic Functions - Creating Functions At Runtime Without So Many Ifs/elses...
Hi, nice to register after lurking for a while and seeing how smart people are on here......

I am writing some code that needs to be very efficient, yet flexible. This is in a class and when the class gets initialized a function is setup. I want this function to run straight through without doing any time-consuming things such as calling other functions or routines, or doing any if/else logic/branching.

Now I know that you can setup a function at anytime during runtime such as:


Code:
var myFunction:Function = function() {trace('HELLO!')}
But what I am trying to do is to try and append code to a function based on logic, yet I don't want the function to be deciding this logic when it is running as it will only need deciding when the function is created.... imagine if it were a string it would be something like myFunction+="do somethingelse;" which would be the same as having initially setup myFunction as such:


Code:
var myFunction = function() {do something; do somethingelse;}
With this I seem to be having no luck

Here's an example where I setup the most compact/efficient function at runtime depending on what I want the function to do. Now this was fairly simple because when we create the function there are only a few possible variations, but I need someway of doing a function+= as my real code has quite a few variations and it would be a nightmare have a zillion if/else branches. REMEMBER I do not want any logic/decisions in the function itself as it to be the most efficient the function must be as compact as possible and run straight-through.


Code:
var dynamicFunction:Function;
//
// Setup the dynamic function & call it
// In this example outputs "Hello Jim" & "Goodbye Jim"
dynamicFunction = CrapSetupRoutine(true, true, "Jim");
dynamicFunction();
//
// Try and setup the dynamic function using a less ify/elsey (less complicated) routine & call it
// In this example it doesn't work if we try and make it say both Hello & Goodbye like above :(
dynamicFunction = SetupRoutineIWouldLike(true, true, "Jim");
dynamicFunction();
//
function CrapSetupRoutine(sayHello:Boolean, sayGoodbye:Boolean, yourName:String):Function {
var returnFunction:Function;
// Far too many ifs/elses...but remember the function created cannot have any if/else logic or calls to other functions
if (!sayHello and !sayGoodbye) {
returnFunction = function () {
trace("<dynamicFunction> sits bored");
};
} else if (sayHello and sayGoodbye) {
returnFunction = function () {
trace("Hello "+yourName);
trace("Goodbye "+yourName);
};
} else {
if (sayHello) {
returnFunction = function () {
trace("Hello "+yourName);
};
} else {
returnFunction = function () {
trace("Goodbye "+yourName);
};
}
}
return returnFunction;
}
//
//What I actually want the Setup function to resemble is this
function SetupRoutineIWouldLike(sayHello:Boolean, sayGoodbye:Boolean, yourName:String):Function {
var returnFunction:Function;
// the ifs/elses are as minimal as possible, which is good
if (!sayHello and !sayGoodbye) {
returnFunction = function () {
trace("<dynamicFunction> sits bored");
};
} else {
if (sayHello) {
returnFunction = function () {
trace("Hello "+yourName);
};
}
if (sayGoodbye) {
// the += below doesn't work.....so the question is how to append to it?????
returnFunction += function () {
trace("Goodbye "+yourName);
};
}
}
return returnFunction;
}
// The end
P.S. I knew the += would never work as this is a function and not a string. But at least if you think of the function as a string you'll get what I'm trying to do.....I suspect if it can be done it involves casting or something and maybe using strings initially??

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

Help On MC And Instance Names
Hello,

I want to how to get the instance name of a MC whenever is clicked? How can I do it?

Thanks,
Fabocp

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!

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!

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

Copyright © 2005-08 www.BigResource.com, All rights reserved