Groups | Blog | Home
all groups > flash actionscript > may 2005 >

flash actionscript : nextFrame from a loaded SWF


MonkeyPiePdx
5/15/2005 12:00:00 AM
Ok - newbie. I've loaded a swf into a level and I want to advance the main
timeline (that this movie is loaded into) by one frame from the loaded swf.
With a button, I tried: on(release) {_root.nextFrame(); } and I tried
on(release) {_root._root.nextFrame();} - but neither worked. I don't think i'm
quite getting this notation right.

Thanks
OverRatedMedia
5/15/2005 12:00:00 AM
hey! I actually was just thinking about that yesterday, and I don't think that
you can use the next frame thing on a timeline... Make the content a movie
clip, then make it stop. You have to apply an instance name to it to make it
work... Let's name it loaded_swf. Now, put:
on (release) {
loaded_swf.nextFrame();
}
I hope that helped!
kglad
5/15/2005 12:00:00 AM
overrated is mistaken. you just need to reference the correct timeline. the
_root timeline refers to the most basic timeline on that _level. when you load
a movieclip into a non-zero _level, _root refers to the _root on that level,
not the _level0 timeline.

so, use:

on(release){
_level0.nextFrame();
}
MonkeyPiePdx
5/15/2005 12:00:00 AM
Exactly what I needed! Thanks once again Kglad!

MonkeyPiePdx
5/16/2005 12:00:00 AM
One more question: I want to use a gotoAndPlay button from that same loaded
SWF mentioned above on another loaded swf. Now I was able to do this with just
simple clean on (release) . . . calling the correct level and MC. But - I want
to use a variable for the Level number - Using this to calculate that variable:
( _level0._currentframe - 10). But I'm not sure how to define the variable and
then exactly how to use it in the 'on (release) . . . .' for the button.

Thanks
kglad
5/16/2005 12:00:00 AM
you can use a variable for _level and a variable for the frame number in that _level:

MonkeyPiePdx
5/16/2005 12:00:00 AM
Thanks! The 'eval(....." was the piece I was missing. It works perfectly. I
declared the var1 in the swf with the button but then needed to advance the
'var1++' since it apparently didn't keep doing the check for
"_level0_currentframe". I read something that said unless you use the 'var'
declaration that all variables are Global, but I tried defining the variable in
the main timeline (_level0) and it didn't work properly. I guess not as
"Global" as I thought or did I miss something? Thanks again for your help. Man
you're on here alot - I thought you had a 'real' job:D!
kglad
5/16/2005 12:00:00 AM
var makes a variable local to a { } block - like a function or for-loop.
otherwise, it doesn't do anything useful.

timeline variables are already local to the timeline and to access them you
need to use the correct path whether you use a var prefix or not (unless you
make them _global).

and i do have a real job. 1.2 real jobs, actually. plus, all the repairs and
tending that goes with taking care of a house on 1 acre of land.
AddThis Social Bookmark Button