Accessing Functions in Child Clips From Root.

  • dhonsvick
  • Beginner
  • Beginner
  • dhonsvick
  • Posts: 49

Post 3+ Months Ago

Layout of the Movie.

Parent Clip : _root
Child Clip: miniMe

miniMe. is 1 Frame wide Top Frame is actions Layer

I have a function there called cal();

function cal(){
trace("I like to eat, eat eat, apples and bananas");

Now under root I am trying to access the function;

Nothing happens .... I try the target key just to make sure I am not Fat Fingering somenthing;

Nothing Happens

The idea here is to make miniMe easily reusable - miniMe works great whena ll code is on the _root level.
  • classified
  • Expert
  • Expert
  • User avatar
  • Posts: 540
  • Loc: Bahrain

Post 3+ Months Ago

make sure of your instance name
make sure of your function name
make sure you have no errors .
make sure you have the code on root .

try using global functions
and yes google it :)
  • dhonsvick
  • Beginner
  • Beginner
  • dhonsvick
  • Posts: 49

Post 3+ Months Ago

Every thing was spelled/Named correctly. I can not use _root as this is being created to be a loaded module into another movie....however

I did find that it works fine when launched from a button after more testing yesterday...interesting....get ignoreed unless launched from a clip event.

So ... o on a button
} Works

but simply putting;

in my actions layer gets ignored. I suppose I could use an onEnterFrame to kick it off....I just didnt think this should have to...
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1253
  • Loc: Ro

Post 3+ Months Ago

rule number 1 when working with movieclips is to place them 1 frame before you try to call any function inside them. Because first the actionscript from main timeline is executed and then the movieclip is initialized. This rule is also applied for any nested movie.
Therefor, if you have movieclip miniMe, place it in frame 1 of the main timeline, then make the call for the function in frame 2.

Same would be if inside miniMe you have a movieclip named mcTest. If it's placed in frame 1 and in same frame 1 you try to call a function from it, it will not work.

If you use only user triggered events, then it's ok to place the movieclip and the actions in the same frame.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 6 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum

© 1998-2016. Ozzu® is a registered trademark of Unmelted, LLC.