Detect end of swf & reload another

Hi,
Currently I am using this code to play a selection of .swf files using the keyboard.
var myrequest:URLRequest=new URLRequest("1.swf");
var myloader:Loader=new Loader();
myloader.load(myrequest);
stage.addChild(myloader);
//Adds event listener to the stage.
stage.addEventListener(KeyboardEvent.KEY_DOWN, detectKey);
function detectKey(event:KeyboardEvent):void {
if (event.keyCode==81) {
   var myrequest1:URLRequest=new URLRequest("2.swf");
myloader.load(myrequest1);
if (event.keyCode==87) {
   var myrequest2:URLRequest=new URLRequest("1.swf");
myloader.load(myrequest2);
if (event.keyCode==69) {
  var myrequest3:URLRequest=new URLRequest("3.swf");
myloader.load(myrequest3);
Now I would like to detect the end of, say, 1.swf to load into a different swf, does anyone know how best to acheive this? I have tried a few tutorials with no success!
Many Thanks

One way would be to have each swf be assigned an event listener after being loaded so that you could have each one dispatch an event when they complete.  The event handler function for the listener would take care of loading the next swf.
Another approach, if these are frame by frame animations, could be to continually compare the currentFrame versus the totalFrames as soon as the files are loaded and initialized.  When the two values are equal, trigger loading the next.
In both cases you should include listeners to determine when the files are loaded before establishing either method.

Similar Messages

  • Detect end of captivate swf

    I am loading a swf that I created in captivate into another
    flash file. I would like to be able to detect when tha captivate
    swf is at the end. Is there a way in flash to detect when a
    captivate swf is at the end?

    Hi Jencarter,
    another possbility could be to embed a small swf-animation
    into the captivate-movie that calls a function in the root, in this
    case the flash-file which loads the captivate-movie.
    We had the same problem, in the flash-file a function
    "chapterend" should be called as soon the captivate-swf is at the
    end.
    So I've build a small swf which just calles the actionscript:
    _root.chapterend();
    This swf can be imported into the last slide of the
    captivate-movie (or on any other position, if you need it).
    Best regards

  • Detect end of the .swf file from captivate

    Hi,
    I've a .swf file sent by our clients. They want to put that .swf file on the webpage. The .swf file is published from captivate.
    Now they want to display a submit button on end of the .swf (video). I don't know how to detect end of the video.
    Need help...!!!
    Thank you,
    Himadri

    Welcome to our community
    Within Captivate you are able to choose different actions to occur when the Captivate movie completes play. Of course if you don't have Captivate and the project file you are pretty much stuck with what you have. If you *DO* have access to the source, you would then configure the end action to be what you like. Perhaps execute some JavaScript, load a different page, etc.
    If you don't have access to the source file, you may be better off asking whomever provided the SWF to you to make a small change to the end action. They would then compile a new SWF and provide that to you to use.
    You just said a "Submit" button should appear after the video plays. What exactly is this button supposed to do?
    Cheers... Rick
    Helpful and Handy Links
    Begin learning Captivate 5 moments from now! $29.95
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcererStone Blog
    Captivate eBooks

  • AS3 - 1) Countdown Timer to the designated Date for Live-Broadcast-Event yet to take place; 2) Detect End of Live Stream on FLVPlayback with FLVPlayback.isLive = true - ActionScript 3 - flash cs3 cs4

    Hi folks,
    Ronny's here again on forums, having particularly 2 (two) questions/problems to resolve:
    1) Countdown Timer to the designated Date for Live-Broadcast-Event yet to take place
    2) Detect End of Live Stream on FLVPlayback with FLVPlayback.isLive = true
    attached is the .zip file (as3_Countdown Timer_ver 1.0.1_by Ronny Depp.zip) with all flash source files containing:
    a) The FLash Source (file: timer_module.fla) - (FLA flash source file - Flash CS3 Professional, Flash Player 9, actionscript 3.0)
    b) com.othenticmedia.utils.dateAndTimeManagement package including 2 .as actionscript 3.0 Class files.
           i) com.othenticmedia.utils.dateAndTimeManagement.DateAndTimeManager Class in the said package. (file: DateAndTimeManager.as)
           ii) com.othenticmedia.utils.dateAndTimeManagement.CountdownTimer Class in the package. (file: CountdownTimer.as)
    c) The compiled SWF file version of this Application's blueprint. (file: timer_module.swf).
    What i need to confirm is: ........................................................ see the next post of mine. (for Problems  need to be Resolved)

    Problems to Resolve:
    Problem#1) - Countdown Timer to the designated Date for Live-Broadcast-Event yet to take place.
    Problem#2) - Detect End of Live Stream on FLVPlayback with FLVPlayback.isLive = true;
    Problem#1 Description:
    I need to pinpoint the Logical TimeSync Exception, i am still unable to figure out. That is I'm using a webservice in my Application to Synchronize the Time with the actual ET (eastern time) with accomodation of auto-adjustment for EDT GMT-4 (eastern daylight time) & EST GMT-5 (eastern standard time), times. I am using the zipcode: "10012" to pass it to the Web Service in urlRequest object, to retrieve the Current ET eastern time according to EDT & EST time settings for Manhattan/Brooklyn areas or others within  New York, NY 10012.
    Currently the Web Service is returning accurate date/time based on local EDT GMT-4 daylight time.
    Is there some defined set of dates for EDT & EST times for New York region that I can check for to ensure the correct Dates/Times for Eastern Time in New York area ??? I am using NY zipcodes because i am sure to get correct ET values.
    The Major Problem Part: is I need to correct the time by 2 seconds or approx. 2 secs, some millisecs.
    When I retrieve the Time Value from WebService, it lags behind for 2 seconds as compared to DateObj i create using computer's local time, on my Windows XP Service Pack 2 with Automatic Updates turned-on. And I'm sure about my Windows will be having latest updates for Time Management already installed. I also added the 2 secs. to the TimeSync(ed) Date to make correction to this Date obj.
    I call my custom fucntion addSeconds(dateObj:Date, secs:int) to add 2 seconds to the Date by Converting Seconds to Milliseconds.
    Please comb through the as code in files attached and Help Me Out !!!
    Problem#2 Description:
    Secondly I need to Detect the End of Stream state while using FLVPlayback component, an rtmp:// live Stream from FLASH MEDIA SERVER.
    I need to Play a YuMe Post-Roll Ad when Steam Finishes/Ends.
    Live Broadcast Stream Event starts every night on Wednesdays & Saturdays exactly  at 10:59 PM EDT GMT-4.
    Live Events only Streams/Broadcasts the stream for 50secs. exactly. When [playback stopped] it plays a PostRoll Ad and after the CountdownTimer again comes back to life. The Next upcoming Event is calculated & the Countdown begins until Next Event's time/date is reached.
    Here is the  code on the frame 1 on the MainTimeline: (rest of the params like source, volume, skinAutoHide are Set using Property Inspector for FLVPlayback instance on Stage)
    //myStream instance of FLVPlayback is on the Stage
    myStream.isLive = true;// Frame 1 Actions in the FLA
    myStream.addEventListener(VideoEvent.COMPLETE, onEndOfStream);
    myStream.addEventListener(VideoEvent.STATE_CHANGE, onState);
    myStream.addEventListener(String(VideoError.NO_CONNECTION), onStreamError);
    myStream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
    /*if(myStream.stopped){
         trace("tracy: "+myStream.state);
    } else if(myStream.state == VideoState.STOPPED){
         trace("tracy: "+myStream.state);
    function onStreamError(event:VideoError) {
         trace(event.code + "\n\t" + event);
    function onState(event:VideoEvent) {
         trace(event.state + "\n\t" + event.toString());
    function onEndOfStream(event:VideoEvent) {
         trace(event.state + "\n\t" + event.toString());
    function netStatusHandler(event:NetStatusEvent):void {
         switch (event.info.code) {
              case "NetConnection.Connect.Success":
                   //connectStream();
                   break;
              case "NetStream.Play.StreamNotFound":
                   trace("Stream not found: "/* + myStream.source*/);
                   break;

  • How to call one .SWF from another?

    How do I call one .SWF from another. I built a very beefy
    base .SWF, and want to add music overlay, and an intro slide show
    to the exsting Flash animation, but put it in a second .FLA/.SWF
    file. How do I call one from the other?
    This will be embedded in an HTML file but I assume this is
    superfluous to my question.
    F.Z.

    I think you should open that Another SWF (FLA),
    and add some actionscript..
    For example, you could create a movie clip, and write
    actionscript in the
    first keyframe:
    loadMovie("
    http://www.somewebpage.com/movie.swf",
    this);
    "FredZimmerman" <[email protected]> wrote in
    message
    news:ftnjas$mj5$[email protected]..
    > How do I call one .SWF from another. I built a very
    beefy base .SWF, and
    > want
    > to add music overlay, and an intro slide show to the
    exsting Flash
    > animation,
    > but put it in a second .FLA/.SWF file. How do I call one
    from the other?
    >
    > This will be embedded in an HTML file but I assume this
    is superfluous to
    > my
    > question.
    >
    > F.Z.
    >

  • One swf to another

    I don't know if this can be done but here it goes. I have 2
    flash anamation on my site. Both have several scenes in them. My
    question is? When linking over from one swf. to another. Can you
    script it to start at a specific scene or must you start at the
    begining of the swf.
    Thanks

    from the loaded swf's main timeline:
    MovieClip(parent.parent)
    will reference the timeline to which the swf's loader has been added.  so, to reference a variable (eg, scoreVar) on that timeline, use:
    MovieClip(parent.parent).scoreVar

  • How to merge  one swf to another

    Hi,
    I want to merge two swf file in to a single swf file, how i
    can achieve that , since i have done some part of my project
    modules in cairngorm framework and other parts of module i have
    coded with out using any frame work, intern both the module
    generates separate swf file, i just want to merge these two swf
    files in to single swf file so that i can get whole project in a
    single swf.
    Regards
    Kumar

    To have one application SWF load another application SWF, use
    the SWFLoader component. If you have in fact created Flex modules,
    then use ModuleLoader component.

  • Swf reloaded autometically in aspx page and buttons dissappear from flash content

    Hi, I am facing a problem with flash content in aspx.
    After spending some time, the swf embeded in the aspx page is
    reloaded autometically ( without refresing the aspx page only swf
    reload ) and two buttons from that swf dissappear.
    I can't understand why the swf reload ?
    Can any one help me !!

    Hi,
    Thanks Darr_darshan.
    I had embed the swf directly. And the swf is reloaded using
    backend coding, so i can't get the idea about that how the swf is
    reloaded ?

  • Passing variables from one swf to another

    I am facing problem to pass variable from one swf to another.
    I am using loadMovie to load another swf. how can I pass a variable
    value to another swf. Can anyone help me plz? It is somewhat
    urgent.
    thanx in advance.

    first of all:
    this is the Flash Media Server and your problem is not
    related to FMS....
    second thing related to the "somewhat urgent" :
    we, users on this forum, are not there to do your job... so
    calm down otherwise no people will answer your question. This forum
    is a free support forum that community of Flash developer use to
    learn tricks and to solve problems.
    Possibles solutions:
    If the two swf are seperate you can use LocalConnection to
    establish a connection between different swf.
    If you load a second swf into the first one you can interact
    like a standard movieClip(only if there from the same domain or if
    you a policy file on the other server)
    You can use SetVariable(via Javascript) to modify a root
    variable on the other swf and check with an _root.onEnterFrame to
    see if the variable had changed in the second swf.
    * MovieClipLoader will do a better job, in your specify case,
    than the loadMovie. Use the onLoadInit event to see when the swf is
    really totaly loaded into the first one otherwise you will have
    timing issues.
    My final answer(lol) is the solution 2 with the
    notice(*)

  • Is there any way to pass value from one SWF to another ?

    I am doing project using flash, now I cant pass a value from one SWF to another, is there any way to pass value from one SWF to another.
    thanks

    Hi,
    Just to confirm here do you simply want to communicate between two SWFs without involving Flash Media Server. If this is the case one good way of doing it is to use a local connection. It can be used for direct communication between two separate instances of the flash player. However if you want to involve multiple clients sharing a common variable then you may have to use Shared Object for this. Please let me know what is the actual use case, is it multiple clients sharing a common variable or different player instances communicating between themselves.
    Thanks,
    Abhishek

  • Detect "end of file" while send n numbers files over a socket?

    Hi!
    I�m trying to find a way to detect "end of file" while send n numbers files over a socket.
    What i'm looking for is how to detect on the client side when the file i�m sending is downloaded.
    Here is the example i�m working on.
    Client side.
    import java.io.*;
    import java.net.*;
    public class fileTransfer {
        private InputStream fromServer;
        public fileTransfer(String fileName) throws FileNotFoundException, IOException {
            Socket socket = new Socket("localhost", 2006);
            fromServer = socket.getInputStream();
            for(int i=0; i<10; i++)
                receive(new File(i+fileName));
        private void receive(File uploadedFile) throws FileNotFoundException, IOException {
            uploadedFile.createNewFile();
            FileOutputStream toFile = new FileOutputStream(uploadedFile);
            byte[] buffer = new byte[4096];
            int bytesRead = 0;
            while ((bytesRead = fromServer.read(buffer)) != -1) {
                toFile.write(buffer, 0, bytesRead);
        public static void main(String[] args) {
            try {
                new fileTransfer("testa.jpg");
            } catch (Exception ex) {ex.printStackTrace();}
    }Server side.
    import java.io.*;
    import java.net.*;
    public class fileTransferSend {
        Socket serv = null;
        OutputStream toClient;
        public fileTransferSend(String fileName) throws FileNotFoundException, IOException {
            StartServer();       
            for(int i =0; i<10; i++)
                send(new File(fileName));
        public void StartServer() throws IOException {
            ServerSocket ssocket = new ServerSocket(2006);
            System.out.println("Waiting for incomming");
            serv = ssocket.accept();
            System.out.println("incomming");
            toClient = serv.getOutputStream();
        private void send(File f) throws FileNotFoundException, IOException {
            if(f.exists() && f.canRead()) {
                FileInputStream fromFile = new FileInputStream(f);
                try {
                    byte[] buffer = new byte[4096]; // 4K
                    int bytesRead = 0;
                    System.out.println("sending: "+f.getName());
                    while ((bytesRead = fromFile.read(buffer)) != -1) {
                        toClient.flush();
                        toClient.write(buffer, 0, bytesRead);
                finally {
                    //toClient.close();
                    fromFile.close();
            } else {
                System.out.println("no files");
        public static void main(String[] args) {
            try {
                new fileTransferSend("test.jpg");
            }catch(Exception e) {e.printStackTrace();}
    I know that the client never reads -1 becuase i doesn�t close the stream.
    Is there anyway to tell the client that the file is downloaded?

    A common (and easy) TCP/IP protocol is to send length, followed by data.
    Because TCP/IP is a stream-oriented protocol, a receiver can never absolutely determine where the first packet ends and the second packet begins. So it is common to send the length of the packet, followed by the packet itself.
    In your case, you could send length of file, followed by file data. It should be fairly easy to obtain file length and send that as a 32-bit (or 64-bit value). Here is an idea (not code) for the receiver:
    receive (4) // where 4 = number bytes to receive
    unsigned length = convert 4 bytes to unsigned integer
    while (length != 0)
    n = receive ( length ) // where n = number bytes actually received, and length = number bytes desired
    Or, you can use the concept of an "Escape" character in the stream. Arbitrarily choose an ESCAPE character of 0x1B (although it could be any 8-bit value). When the receiver detects an ESCAPE char, the next character can be either control or data. So for end of file you might send 0x1B 0x00. If the byte to be sent is 0x1B, then send 0x1B 0x1B. The receiver would look something like this:
    b = read one byte from stream
    if (b == 0x1B)
    b = read one byte from stream
    if (b == 0x00) then end of file
    else place b in buffer
    else
    place b in buffer
    Later.

  • How to detect end of FLV Video - and then call another web page?

    I'm using Flash CS3 v9 on a PC to...
    - use File > Import an AVI video and convert it to an FLV video.
    - use File > publish to publish it.
    - Then upload the four files...
    .. MyVideo.flv
    .. MyPage.html,
    .. MyPage swf
    .. AC_RunActiveContent.js
    to my website.
    Works Great!
    My Question:
    Since Javascript seems to run the .swf file which pays the .flv video... (or some such)
    Can I use Javascript (or html) to tell when the FLV Video has finished playing...
    And then automatically call another webpage...
    If so would someone be kind enough to share a code sample with me to get me quick started.
    Thanks for any help.

    I'm using the defaults in Flash CS3 ver9.
    I'm not creating any action script myself.
    I open Flash and select from the Flash menuio options...
    "Create New Flash File (Action Script 3.0)"
    I then File | Import my AVI video to convert it to an FLV video...
    and choose the player options for controls, etc
    and then punch through the menu's until Flash finally imports the video.
    I then "Publish" the project to the the 4 files mentioned in my initial posting.
    So, I think the answer to your question is...
    Yes, I'm using the default Flash playback component to play the flv
    and yes, I'm letting Flash default to CS3 even though I'm not writing the code... Flash is.
    Thanks for the help.

  • How to detect end of flash movie (SWF file) in Javascript

    I have used Dreamweaver CS4 to integrate my SWF file as shown
    below. So far so good. See GoToNext()
    my website
    What I wouldd like to do is have the SWF movie trigger a
    javascript function in my html page when the video is stopped
    playing (i.e. when it is finished) There are no controlls in that
    SWF file - it is basically am add banner. I would think this would
    be easiest done by rasinng an event in SWF that is communicated to
    javascript, where I can add an event listener, and thus trigger my
    function.
    How can this be done in the simplest way?
    <div id="bodyFlash"
    class="clearfloat"><p> </p>
    <object
    classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="760"
    height="150" id="FlashID" title="Chillifire Banner">
    <param name="movie" value="flash/chillifire.swf" />
    <param name="quality" value="high" />
    <param name="wmode" value="transparent" />
    <param name="swfversion" value="6.0.65.0" />
    <!-- This param tag prompts users with Flash Player 6.0
    r65 and higher to download the latest version of Flash Player.
    Delete it if you don’t want users to see the prompt. -->
    <param name="expressinstall"
    value="Scripts/expressInstall.swf" />
    <!-- Next object tag is for non-IE browsers. So hide it
    from IE using IECC. -->
    <!--[if !IE]>-->
    <object type="application/x-shockwave-flash"
    data="flash/chillifire.swf" width="760" height="150">
    <!--<![endif]-->
    <param name="quality" value="high" />
    <param name="wmode" value="transparent" />
    <param name="swfversion" value="6.0.65.0" />
    <param name="expressinstall"
    value="Scripts/expressInstall.swf" />
    <!-- The browser displays the following alternative
    content for users with Flash Player 6.0 and older. -->
    <div>
    <h4>Content on this page requires a newer version of
    Adobe Flash Player.</h4>
    <p><a href="
    http://www.adobe.com/go/getflashplayer"><img
    src="
    http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"
    alt="Get Adobe Flash player" width="112" height="33"
    /></a></p>
    </div>
    <!--[if !IE]>-->
    </object>
    <!--<![endif]-->
    </object>
    </div>
    ...

    on the last frame in the banner file you can use the
    ExternalInterface class to call a specific JS method, and even pass
    data if needed.

  • Help needed to detect end of movie

    I am using loadMovie to play an external SWF file in my main
    movie. How can I detect when the loaded movie has ended so I can
    move onto the next frame?
    Thx

    Hi Krishna,
    From any Transaction, use menupath System > Status... The click on the "magnifying glass" icon just below the "Component Version" field - that will open another dialog screen with the Support Package Level for Installed Software Components.
    Find the entry for component SLL-LEG - that's the GTS system.  Up to 8, the versioning is quite obvious, but release 900 is actually GTS 10.0, and 901 is GTS 10.1.
    Hope that works ok for you.
    Regards,
    Dave

  • Load one swf after another?

    Hey!
    I've created a presentation in Flash that exceeds the maximum number of frames. I broke it up into a few different files, and now I need these .swfs to load one after another automatically, without prompting or clicking anything on the screen.
    The presentation is for an interpretation program at work and will be played for an audience several times a day. It was originally a 6-slide-projector presentation that I simplified, and this is the last step to replacing the old projection system altogether.
    Does anyone know how to solve my problem, as simply as possible?
    Thank you!

    you'll probably want to load them all at the start of you presentation so they're ready for display without waiting.
    so, use standard preloader code to load your swfs.  use a loop or dispatch an event to detect when one ends and another needs to start.

Maybe you are looking for

  • OC4J에서 DEFAULT로 제공하는 JDBC CLASSES를 원하는 JDBC CLASSES FILE로 변경하는 방법

    제품 : JDBC 작성날짜 : OC4J에서 DEFAULT로 제공하는 JDBC CLASSES를 원하는 JDBC CLASSES FILE로 변경하는 방법 ================================================================= PURPOSE 9iAS에서 JDBC thin driver인 classes file을 새로운 version으로 변경하기 위한 여러가지 방법을 정리한다. Explanation 9iAS

  • Airport Express "choppy"; Apple TV Perfect

    Hey Guys and Gals I'm throughoully confused! I have two apple TV's in my home, both work flawlessy whether streaming from Netflix etc or using as an AirPlay reciever. However, when I try to stream music to my Airport Express, I can't get through 30 s

  • Manual reconfigue EA2700

    Sorry, if this is a dumb question... After a rare power outage, my EA2700 will not connect to the Internet. I can connect to the router but not the Internet. My desktop computer is wired to the router and nolonger can reach the Internet either. Once

  • DoFilter() method is being called only at the second request

    Hi, I have implemented a simple Filter class Here is the code public class BasicFilter implements Filter FilterConfig config; public void init(FilterConfig config) System.out.println("Filter Initialised"); this.config = config; public void doFilter(S

  • I can't restore my classic!! Says Error 1418

    Also I haven't been able to get a full charge.