all groups > flash actionscript > june 2004 >
You're in the

flash actionscript

group:

actionscript 2.0 - passing objects (such as MovieClips and TextAreas) by reference?


actionscript 2.0 - passing objects (such as MovieClips and TextAreas) by reference? junk NO[at]SPAM idea-multimedia.com
6/30/2004 8:46:24 PM
flash actionscript:
i have a question regarding functions in actionscript 2.0 - i would
like to be able to pass movieclips or textareas by reference into
functions in an external .as file. specifically, i want to call a
function from my scripts.as file in my flash movie to manipulate a
movie clip on the stage. id also like to be able to manipulate text
areas with functions if possible.
i could accomplish the functionality i need by passing in numeric or
string data and returning values, but manipulating the clips
themselves within the functions would be much cleaner and easier for
future maintenance. because im reusing these functions for numerous
clips and in different movies, it would be ideal to pass in movieclips
by reference.

any help/examples or suggestions would be appreciated. thanks!!
Re: actionscript 2.0 - passing objects (such as MovieClips and TextAreas) by reference? Christopher Homer
7/1/2004 1:10:08 AM
When you use attachMovie, you can pass an Object to the movie you are
attaching. This might be what you are looking to do. You can take a
look around the Flash directories and you may find he code for how
Re: actionscript 2.0 - passing objects (such as MovieClips and TextAreas) by reference? junk NO[at]SPAM idea-multimedia.com
7/1/2004 10:14:42 AM
[quoted text, click to view]

that is what i suspected, ive tried KnowMind's suggestions and have
had no luck with that method so far. that is how i initially tried to
do this, but so far have not been able to accomplish any manipulation.
here's what i have:

there is a movieclip on the stage with instance name "mapLoader" and
a textArea on the stage named "textbox".

the actionscripts on this particular frame are as follows:

function testmc(mc:MovieClip)
{
mc._x = mc._x + 100;
}

function testtb(tb:TextArea)
{
tb.text = "testing";
}

testmc(mapLoader);

testtb(textbox);

getting no result from this, no errors either.
thanks!
Re: actionscript 2.0 - passing objects (such as MovieClips and TextAreas) by reference? KnowMind
7/1/2004 10:14:46 AM
Try this in your scripts.as file...

function manipulate_MC(my_mc:MovieClip){
//do whatever you want with my_mc...
}

In the flash movie...Call this function passing the moviclip instance name
as the parameter
Eg:
var scriptInstance=new scripts();
scriptInstance.manipulate_MC( mc_instanceName) // instance name without
quotes

Try this with text fields also..by changing the argument to a textField
variable.

Hope this helps..
--KM





[quoted text, click to view]

Re: actionscript 2.0 - passing objects (such as MovieClips and TextAreas) by reference? Jeckyl
7/1/2004 7:50:52 PM
MovieClips and other objects (like arrays) are always passed by reference
anyway

Re: actionscript 2.0 - passing objects (such as MovieClips and TextAreas) by reference? junk NO[at]SPAM idea-multimedia.com
7/2/2004 5:13:16 PM
flash had somehow lost its prefs and defaulted back to actionscript
1.0, hence the problem. nice. thanks!
j


[quoted text, click to view]
AddThis Social Bookmark Button