Copy link to clipboard
Copied
I've created a repaly button to replay an imported swf file (instance name=dpCuspSub_mc) located in frame 1 of a movie clip. It works, but then it starts looping and I want it to replay only once.
replay_btn.addEventListener(MouseEvent.CLICK,replay);
function replay(evt:MouseEvent):void {dpCuspSub_mc.gotoAndPlay(1);}
I'm a graphic artist who has just started learning Flash, so please simplify as much as possible.
Copy link to clipboard
Copied
is that swf really imported (in the ide) or are you using a loader to load it?
Copy link to clipboard
Copied
I imported it into the library. If you think it should be loaded, i guess i could try that, but I don't know how.
Copy link to clipboard
Copied
you should place a stop() on your external swf's last frame and load it using the loader class. then retest.
Copy link to clipboard
Copied
I put a stop in the last frame of the swf. Now on replay it does not play the entire swf. When you hit replay it plays those last few frames and restarts. as to the loader...I am a complete novice and do not know any AS3 code.
Copy link to clipboard
Copied
var ldr:Loader=new Loader();
var urlR:URLRequest=new URLRequest("putthefilenameofyourswfhere.swf");
ldr.load(urlR);
addChild(ldr);
// that will load your swf and place it on-stage at 0,0
for a button to restart your swf:
btn.addEventListener(MouseEvent.CLICK,replayF);
function replayF(e:MouseEvent){
MovieClip(ldr.content).gotoAndPlay(1);
}
Copy link to clipboard
Copied
now I get an error in the Output:
Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.
Also, what do I need to put in to have the swf place at 0, 113?
Copy link to clipboard
Copied
did you use the correct swf name?
position your loader wherever you want the swf to appear.
Copy link to clipboard
Copied
yes, the name is correct. Do you mean a UILoader? (yes, I'm THAT novice)
Copy link to clipboard
Copied
copy and paste the code you used to this forum.
Copy link to clipboard
Copied
var ldr:Loader=new Loader();
var urlR:URLRequest=new URLRequest("cuspsub.swf");
ldr.load(urlR);
addChild(ldr);
// that will load your swf and place it on-stage at 0,0
// for a button to restart your swf:
replay_btn.addEventListener(MouseEvent.CLICK,replayF);
function replayF(e:MouseEvent){
MovieClip(ldr.content).gotoAndPlay(1);
}
Copy link to clipboard
Copied
if you're testing in the flash test environment, cuspsub.swf is not the same directory as your published swf. if you're not testing in the test environment that swf may need to be elsewhere.
how are you testing?
Copy link to clipboard
Copied
i moved the swf to the same level as the .fla file. it ran but when I slicked the replay button I got an Output Error:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::AVM1Movie@638e6af1 to flash.display.MovieClip.
at OAC_2009_mcMT_fla::MainTimeline/replayF()
(OAC_2009 is the fla name, and mcMT is the movie clip in which the swf is playing.)
also I still need it to be at 0, 113
Copy link to clipboard
Copied
ldr.x=0;
ldr.y=113;
you can't control an avm1 swf when loading into an avm2 swf unless you use localconnection and that's not going to be easy for you.
why are you using both avm1 and avm2 swfs?
Copy link to clipboard
Copied
Honestly I have no idea what you are talking about.
Copy link to clipboard
Copied
you're using as3 in your current project, correct? and you're loading a swf that contains as2, correct?
why are you loading an as2 swf into an as3 swf?
Copy link to clipboard
Copied
Yes, AS3 fla. I created the swf in Fantamorph, then I did File_Import to Library. Someone suggested I had the wrong framerete on the swf?
Copy link to clipboard
Copied
you created a swf in fantamorph, then you imported that swf into the library of an as2 fla and then you load the as2 swf that you published from that as2 fla?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now