PDA

View Full Version : Calling a movieclip


Psygnosis
08-10-2009, 05:27 PM
Hi to all guys
I'm new of this forum and actionscripting...
I have A problem...

I have a movieclip script with on (rollOver) and on (rollOut) script to animate it when the mouse goes on the movieclip.

I want that when the mouse goes on that movieclip another movieclip of the same library is show!

But I don't know hot to do it, If I have to create a new level on the stage and what script I have to write.

Sorry for my english
and really thanks in advace

Cota
08-10-2009, 06:49 PM
There is an AS2 function called attachMovie() that allows you to call an item from the library and place it on the stage.

dplows
08-10-2009, 07:39 PM
I think you could just have 1 visible and the other invisible. Then when you rollOver, the 1st one becomes invisible and the other one is now visible & vice-versa.

mc1._visible = true;
mc2._visible = false;

mc1.onRollOver = function(){
mc1._visible = false;
mc2._visible = true;
}
mc2.onRollOut = function(){
mc2._visible = false;
mc1._visible = true;
}

Psygnosis
08-10-2009, 08:19 PM
thanks guys...
I think that cota's advice is better but I can't figure out how to use it

dplows
08-11-2009, 01:56 PM
thanks guys...
I think that cota's advice is better but I can't figure out how to use it

It's just nice to know that there's more than 1 way to do something. That's why Flash is great!

Some ways may be more efficient than others, but there's different methods to achieve the same effect.

Cota
08-11-2009, 03:45 PM
Agreed.

Here's a break down of how to use it,
http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002440.html

Aberrant
08-12-2009, 07:31 AM
@Cota & dplows

If you do call a mc from the library, wouldn't you still need to do a x,y script?

From my understanding (which is minimal). If you want a small file that is quick to respond, then Cota's suggestion is the way to go.

attachMovie()

If you want an approach that is friendly for beginners and n00bs (like myself), than dplows suggestion of making it invisible is the best way to go.

mc1._visible = true;
mc2._visible = false;

mc1.onRollOver = function(){
mc1._visible = false;
mc2._visible = true;
}
mc2.onRollOut = function(){
mc2._visible = false;
mc1._visible = true;
}


P.s. Dplows, I have been crook lately (i.e. common cold). I have yet to even attempt with those variables you had suggested. *Will still get around to it eventually* :)

Cota
08-12-2009, 03:52 PM
yes, the X, Y positions are also explained in the link I posted. If you do not include them, it defaults to 0, 0.

That approach could be considered easier, however, what happens when you have to do this for 10 different clips and want to reference them dynamically? Then you have a problem.

The path of least resistance isnt always the best route.

Aberrant
09-09-2009, 12:03 PM
@Cota
Thanks for the feedback and explanation.

Cheers.