Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i loadmovie and then telltarget/gotoAndStop 2

Status
Not open for further replies.

montyj

Technical User
Jul 16, 2007
3
GB
hi, i know this may seem pretty dim but i'm having a bit of trouble with a file... i wanted to load an swf within main_mc. then within that swf go to certain frame withing a movie object... hard to explain but here's my rought code that i don't know how to correct!

on(release) {
_root.main_mc.loadMovie ("publications.swf")
gotoAndStop("release",5);
}

this loads the publications.swf fine but it doesn't goto frame 5 of the movie release.

any help appreciated.

many thanks,

Montyj
 
The path to the MovieClip would be:
[tt]_root.main_mc.release.gotoAndStop(5);[/tt]

But this won't work in your button script context because the SWF won't be loaded yet. Have a look at MovieClipLoader Class, which has onLoadInit event so that you can monitor whether the SWF has finished loading.



Kenneth Kawamoto
 
thanks for your reply kenneth but half of that was over my head. i'll look into what you've said and see what i can cunjure up!

oldnewbie. "release" is a movie clip within the external swf named publications....

thanks for your prompt replies.
 
Then try this...

var mclListener:Object = new Object()
mclListener.onLoadInit = function(target_mc:MovieClip) {
target_mc.release.gotoAndStop(5);
}
var image_mcl:MovieClipLoader = new MovieClipLoader()
image_mcl.addListener(mclListener)
image_mcl.loadClip("publications.swf", _root.main_mc)

Or...

_root.main_mc.loadMovie("publications.swf")
this.onEnterFrame=function(){
if(_root.main_mc){
_root.main_mc.release.gotoAndStop(5);
delete this.onEnterFrame
}
}

Regards. FLASH HELP - OPENED FOR BUSINESS!
TO GET YOUR OWN FREE WEBSITE HOSTING
 
By the way you must not use "release" as your MovieClip instance name, because "release" is ActionScript mouse event name and therefore forbidden. I'm surprised Flash actually let you name it as such...!

If I HAVE TO use your script style:
Code:
// "release" is renamed to "mcRelease"
on (release) {
	_root.main_mc.loadMovie("publications.swf");
	this.onEnterFrame = function() {
		if (_root.main_mc.mcRelease) {
			_root.main_mc.mcRelease.gotoAndStop(5);
			delete this.onEnterFrame;
		}
	};
}

Kenneth Kawamoto
 
Thanks for your help, it's been great. it didn't quite work probably because i didn't explain myself very well but this is the code that's made it work. and after your advice i changed 'release' to 'book_pages'

on (release) {
_root.main_mc.loadMovie("publications.swf")
_parent.onEnterFrame=function(){
if(_root.main_mc){
_root.main_mc.book_pages.gotoAndStop(5);
delete _parent.onEnterFrame
}
}
}

many many thanks.
 
I probably shouldn't bother but "this is the code that's made it work" - are you sure?

[tt]if(_root.main_mc)[/tt]

... this is always true, because main_mc does always exist when you evaluate this.

It should be:

[tt]if(_root.main_mc.book_pages)[/tt]

... because book_pages exists only after "publications.swf" is fully loaded, and that's the purpose of this test. Your code should not be working, at least in Flash Player 9.

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top