Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

I need my replay btn to replay a swf only once, not loop

Guest
Jul 01, 2009 Jul 01, 2009

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.

TOPICS
ActionScript
2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 01, 2009 Jul 01, 2009

is that swf really imported (in the ide) or are you using a loader to load it?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 01, 2009 Jul 01, 2009

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 01, 2009 Jul 01, 2009

you should place a stop() on your external swf's last frame and load it using the loader class.  then retest.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 01, 2009 Jul 01, 2009

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 01, 2009 Jul 01, 2009

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);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 01, 2009 Jul 01, 2009

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 01, 2009 Jul 01, 2009

did you use the correct swf name?

position your loader wherever you want the swf to appear.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 01, 2009 Jul 01, 2009

yes, the name is correct. Do you mean a UILoader? (yes, I'm THAT novice)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 01, 2009 Jul 01, 2009

copy and paste the code you used to this forum.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 01, 2009 Jul 01, 2009

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);
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 01, 2009 Jul 01, 2009

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 01, 2009 Jul 01, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 01, 2009 Jul 01, 2009

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 02, 2009 Jul 02, 2009

Honestly I have no idea what you are talking about.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 02, 2009 Jul 02, 2009

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 02, 2009 Jul 02, 2009

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 02, 2009 Jul 02, 2009
LATEST

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines