-
Redirect after swf ends.
Need some help. I have a very big swf file and I like to redirect the page after the swf ends. So I made one container to load the swf and then play the swf. But could not get the way to redirect after the swf ends. Here is the code I am using.
Code:
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
image_mcl.loadClip("main.swf", container_mc);
I know simple getURL will do the trick, but how can I make it after the swf ends.
-
Designer, Programmer, Musician
In your loaded swf, on the first frame of the animation or whatever it is, make a variable like
PHP Code:
var Redirect:Boolean=false;
and on the last frame
And in your container/Loader swf put
PHP Code:
onEnterFrame=function(){
if (container_mc.Redirect==true){
getURL("www.blabla.com", "_self");
}
}
Hope that helps (i have not tested it)
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
Originally Posted by angelhdz
In your loaded swf, on the first frame of the animation or whatever it is, make a variable like
PHP Code:
var Redirect:Boolean=false;
and on the last frame
And in your container/Loader swf put
PHP Code:
onEnterFrame=function(){ if (container_mc.Redirect==true){ getURL("www.blabla.com", "_self"); } }
Hope that helps (i have not tested it)
Thanks for the reply. But the problem is this swf is derived from one FLV by just converting it with the help of a converter. There is only one frame
where I put the "container_mc" and load the swf.The swf could not be decompiled in a fla. Now this is the situation, can you think of any other
method.
Thanks for the reply.
-
A 747 was halfway across the Atlantic when the captain got on the loud speaker, "Attention, passengers. We have lost one of our engines, but we can certainly reach London with the three we have left. Unfortunately, we will arrive an hour late as a r esult." http://www.mmomesos.com/mesos/Maple-Story-NX-US.html
Shortly thereafter, the passengers heard the captain's voice again, "Guess what, folks. We just lost our third engine, but please be assured we can fly with only one. We will now arrive in London three hours late."
At this point, one passenger became furious. "For Pete's sake," he shouted, "If we lose another engine, we'll be up here all night!" http://www.mmohome.com
-
Originally Posted by angelhdz
In your loaded swf, on the first frame of the animation or whatever it is, make a variable like
PHP Code:
var Redirect:Boolean=false;
and on the last frame
And in your container/Loader swf put
PHP Code:
onEnterFrame=function(){ if (container_mc.Redirect==true){ getURL("www.blabla.com", "_self"); } }
Hope that helps (i have not tested it)
The swf could not be opened because it is a converted swf.
Thanks for the reply.
-
Designer, Programmer, Musician
I see.
Ok try then creating a timer that counts until the loaded swf finishes. Example, if the loaded swf lasts 1 minute, then you put this in the first frame of your Container swf
PHP Code:
function timer(){
getURL("www.blabla.com", "_self"); clearInterval(sleep);
} var sleep=setInterval (timer, 60000);
The timer will count until 1 minute/60seconds/60000 miliseconds, and then will redirect the page. Hope that helps.
Last edited by angelhdz; 11-19-2012 at 10:49 PM.
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
Originally Posted by trnghosh
Need some help. I have a very big swf file and I like to redirect the page after the swf ends. So I made one container to load the swf and then play the swf. But could not get the way to redirect after the swf ends. I know simple getURL will do the trick, but how can I make it after the swf ends.
Originally Posted by trnghosh
The problem is this swf is derived from one FLV by just converting it with the help of a converter.
If the converter expanded the FLV video across the timeline within the SWF it made, then something like the following code should work. * However, if the FLV video just sits within a single frame in the SWF it made then it will NOT work. My guess is it did the former and not the latter though, what is the name of the converter used?
Code:
var mcl:MovieClipLoader = new MovieClipLoader();
var mclListener: Object = new Object();
mclListener.onLoadInit = function(target_mc: MovieClip) {
target_mc.onEnterFrame = function() {
if (this._currentframe == this._totalframes) {
delete this.onEnterFrame;
this.stop();
// your redirect code here
};
};
mcl.addListener(mclListener);
mcl.loadClip("main.swf", container_mc);
Give that a try in the FLA which loads your video SWF, obviously you need to add your redirect code and test it online etc., to confirm it works.
EDIT: If it does work for you, then you can post it in your threads at actionscript.org , kirupa, etc...
Last edited by FKLL7; 11-20-2012 at 06:15 PM.
-
Designer, Programmer, Musician
FKLL7, your script also do the trick, but it has a flaw, and maybe our friend trnghosh could have problems.
It needs a closing bracket at the end
PHP Code:
var mcl:MovieClipLoader = new MovieClipLoader(); var mclListener: Object = new Object(); mclListener.onLoadInit = function(target_mc: MovieClip) { target_mc.onEnterFrame = function() { if (this._currentframe == this._totalframes) { delete this.onEnterFrame; this.stop(); trace("do this"); }; }; }; //[B]this one[/B] mcl.addListener(mclListener); mcl.loadClip("main.swf", container_mc);
I tested it on a new FLA, and it works great. I created a simple tween animation, exported it to .swf, and loaded it with your script in a new fla, and then the
loaded swf reaches its end, it do the action, in this case i used a trace, but in our friend's case is the getURL. Good job
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
Originally Posted by angelhdz
FKLL7, your script also do the trick, but it has a flaw, and maybe our friend trnghosh could have problems.
It needs a closing bracket at the end I tested it on a new FLA, and it works great. ... the loaded swf reaches its end, it do the action ... Good job
Yes I knew it would work for what I described in my original post (SWF with timeline animation/frames). As for the problem of the missing bracket, thanks for pointing that out. I copy/pasted from some previous code I had into my above post and then edited it there in the browser removing a lot of other unrelated code, so I guess I over looked that when doing so. Worst case scenario is you would get an error saying:
"Scene=Scene 1, layer=Layer 1, frame=1, Line 3 - Statement block must be terminated by '}'"
... and a person could easily just add a "}" and have a working solution, not a bad trade off. ;-) To me this is the proper way of handling the end of the SWF, as its based on actual frames, where as using timers/setInterval as in your example could become inaccurate across different scenarios by different users. Anyway glad you liked it angelhdz, hope its beneficial to the OP trnghosh.
-
Do I bow to all of you, I don't know. You are great. Regarding posting in other forums, as I did not get answers I posted there also.
MY SALUTE TO ALL OF YOU.
Thanks.
-
Glad it worked for your situation.
What I meant was you can post the solution since it worked for your needs, in those other forums where you posted the question also (actionscript.org , kirupa, etc..), so those threads also have a solution and conclusion. ;-)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|