• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 351
  • Last Modified:

An swf inside an swf?

I have a question, I have a flash file (alpha.swf), which I have playing
in another swf file (bravo.swf). I basically want when alpha.swf stops playing,
just goto frame 2 of bravo.swf, the only problem is that I don't know the actual
length of alpha.swf. Alpha.swf is basically a file that I get from somewhere else
and I simply loadMovie from bravo.swf.

I think my syntax is alittle off, this is what I have:


container_mc.loadMovie("alpha.swf",_root);

container_mc.onEnterFrame = function(){
      if(this._currentframe == this._totalframes){
      _root.gotoAndStop(2);
      }
}


brief explanation:
alpha is a swf file with a video playing in it. When the video
stops playing I want bravo.swf to go to frame 2. I loaded alpha into
bravo.swf as you see above. My guess as towards my error is that I am
referencing alpha incorrectly right. I mean alpha is not a movieClip, its a
file. But when I reference it as a movieClip like above alpha doesn't load.

if you need more of an explanation let me know.

thanks, any help is much appreciated
0
mike314
Asked:
mike314
  • 10
  • 8
  • 5
1 Solution
 
BillystyxCommented:
this works - but strangely itdoesn't work twice ina row from the testing window - maybe this is your problem...

frame1:

var HomeLoader = new MovieClipLoader();
      HomeListener = new Object();

      HomeListener.onLoadComplete = function() {
            
            gotoAndPlay(2);
      };
      HomeListener.onLoadInit=function(){
            _level1.play();
      }
      HomeLoader.addListener(HomeListener);
      HomeLoader.loadClip("yourmovie.swf",1);
      stop();
frame2:-nothing
frame3:
if (_level1._currentframe<_level1._totalframes) {
      gotoAndPlay(2);
}
frame4:

unloadMovieNum(1);
stop();

Billystyx

I have not noticed this before - butit works every time from the generated swf, just not from the ctl-enter test movie window. Hope this helps.


0
 
negatyveCommented:
>My guess as towards my error is that I am referencing alpha incorrectly right. I mean alpha is not a movieClip, its a file.

no, your way of referencing it is ok. When you load an external movie in an empty movieclip, the external movie and the clip become the same thing, and you reference the movie with the clip instance name.
The problem, here, is that the

container_mc.onEnterFrame

you write, is wiped out when the first byte of the external movie arrives inside the clip. You see:

- you have the container_mc empty clip
- you create a variable in it (onEnterFrame)
- you load an external movie in it
- when the new movie arrives, it destroy everything inside the host clip
- you loose your variable (and the checking)

Solution?
Create a nested movieclip inside container:

// create the clip and reference it with the "mc" shortcut
var mc = container_mc.createEmptyMovieClip("loader", 1);
mc.loadMovie("alpha.swf");
container_mc.onEnterFrame = function()
{
     if(mc._currentframe == mc._totalframes && mc._totalframes > 1){
            delete this.onEnterFrame;
            _root.gotoAndStop(2);
     }
}
0
 
BillystyxCommented:
Negatyve - I have to admit this one puzzled me - I obviously used a different method (the loadMovieNum), but can you explain why in testing view my example only works once and yet in the swf it seems fine?

It seems the currentframe seems to get 'remembered' even when you shut the testing window and then retest.

Billystyx
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
negatyveCommented:
It happens, I know, in a lot of cases. It's a kind of bug, and you can see it especially while using components, when lot of variables "get remembered", polluting the next test... (yet, no solution find, at least by me)
0
 
BillystyxCommented:
thanks for clarifying - I thought I was missing something:)

Billystyx
0
 
mike314Author Commented:
Ok, I have tried what you provided above. I tried this: (all code in bravo.swf)

frame1:
var mc = container_mc.createEmptyMovieClip("loader", 1);
mc.loadMovie("alpha.swf",_root.intro);


container_mc.onEnterFrame = function()
{
     if(mc._currentframe == mc._totalframes && mc._totalframes > 1){
          delete this.onEnterFrame;
          _root.gotoAndStop(2);
     }
}

frame2:
Stop();
trace("Finished");


but it is not catching the if currentframe == totalframes.
I also tried the listener but its not working either.

Basically if you want to create a small test version of what I am trying to get. create a file called alpha, and import a video to the stage, save it. Now create a new file called bravo, and add the loadMovie code. I basically just want to catch
when alpha stops playing. I want to create this because in the future I will not know the exact running time of alpha and I need it to go back to frame 2.

thanks
0
 
BillystyxCommented:
Did you try my method then. Basically I figured its not going to catch the currentframe, totalframes until the picture is fully loaded. So try that and see if it works.

Billystyx
0
 
negatyveCommented:
>Basically if you want to create a small test version of what I am trying to get.
>create a file called alpha, and import a video to the stage, save it.
>Now create a new file called bravo, and add the loadMovie code. I basically just want to catch

wait. are you saying that your alpha movie is a movie with *only one frame* (and a video in that frame)? If so, my code doesn't work because is verifying if _totalframe is greater than 1...
0
 
mike314Author Commented:
I don't know how many frames alpha has cause I'm loading the url in the loadMovie method. I called it alpha to prevent confusion.

loadMovie("http://www.theActualUrlLocation.com",_root)

since I know that alpha is a swf with an imported movie file I'm guessing that it has more than 1 frame in it right, I mean whenever you import a video file to the stage it should have more than 1 frame right?. basically when alpha stops playing I want to move to another frame in bravo.swf

thanks
0
 
negatyveCommented:
>I mean whenever you import a video file to the stage it should have more than 1 frame right?

In fact, no, because you could have a one frame movie with a movieclip and the videoclip inside it, right? That's what I'm trying to understand: are you sure your external movie has got more than one frame? Could you show me once?
0
 
mike314Author Commented:
what I do know is that alpha is an swf with an FLV video file in it.
0
 
mike314Author Commented:
ok might there be a way to make this work, if I change the way the alpha.swf file is made??
0
 
negatyveCommented:
yes. the problem is to know where the videoclip is (if inside the root, if inside a movieclip), because if the main timeline has got only one frame, and you don't know:

1. if there's an inner clip
2. if the inner clip has got an instance name
3. if it has got, what's the instance name

you cannot know when the videoclip finishes..
0
 
BillystyxCommented:
You can buy a product called flash decompiler which which help you see what's what inside the swf, (even for the free version it should give you enough info )(hopefully) to second guess it.

Billystyx
0
 
BillystyxCommented:
0
 
mike314Author Commented:
ok so bottom line I think I can find out how to modify the way alpha.swf is put together

what do I need to do to basically to do to have it so that I can basically have like a template model to follow.
I plan on using this alot, but I will not know how long the flv playing inside alpha.swf
is. So is there something I can do when I import the file to the stage of alpha.swf
to make it so that I can use that actionscript _currentframes == totalframes and basically be able to have bravo.swf detect when the flv inside alpha.swf stops playing

thanks
0
 
BillystyxCommented:
did you have a look at the flash decompiler - it may provide clues as to where the actual movie is inside the alpha.swf...

Billystyx
0
 
mike314Author Commented:
no I didn't but actually, I think I'm going to ask the people who put together alpha.swf to change the way they put it together, thats why I was wondering is there like a specific way you see that I should tell them about???

thanks
0
 
BillystyxCommented:
the obvious would be to put it all on the root timeline. Makes it easy for you - and unless there is some good reason why they don't, it shouldn't cause any problems...
o/w get them to let you know (as negatyve said) what the target path to the videoclip itself is.
Billystyx
0
 
mike314Author Commented:
so which would be easier, the video in 1 frame in alpha.swf or when its imported to stage like this

http://www.video-animation.com/flash_04.shtml

thanks, any more tips please let me know
0
 
BillystyxCommented:
Yes, like that - imported to the stage (starting on frame 1 of the root timeline - that's what I said in the last post)

That way, your detection of the last frame would be possible with either method.

Billystyx
0
 
mike314Author Commented:
ok thats one method, but I understand that with that method you tend to lose some functionability, like audio is not in sync with visual and there is a 10minute limit and the video has to be downloaded once accessed right???

anyway, I might have to go with that idea. But I think they are using Media Components, because I noticed that when I deleted the loadMovie line, the movie still loads. let me see what I can do.

thanks
0
 
BillystyxCommented:
If it isn't any good you can just get the path in the swf to the actual movie and work with that - if you think it is going to create problems to alter the swf then try this option

Billystyx
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 10
  • 8
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now