Results 1 to 4 of 4

Thread: Stopping a .swf by clicking anywhere outside of movie

  1. #1
    Join Date
    Apr 2010
    Posts
    58
    Thanks
    5
    Thanked 1 Time in 1 Post

    Default Stopping a .swf by clicking anywhere outside of movie

    Hello,

    So I am having a problem on my HTML page. I have a flash (.swf) video player that is controlled by AS 3 and the problem I am having is that I need the video player to stop whatever its playing when the user clicks anywhere on the screen.

    If there are any other details that are needed please let me know.

    Thanks in advance for any help

  2. #2
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    In AS3 it is pretty easy. You will want to relace the traces here with your code, but it would be like this:

    Code:
    function main():void
    {
        stage.addEventListener(Event.DEACTIVATE, windowNotActive);
        stage.addEventListener(Event.ACTIVATE, windowActive);
    }
    main();
    
    function windowNotActive(e:Event):void
    {
        trace("NOT ACTIVE");
    }
    
    function windowActive(e:Event):void
    {
        trace("ACTIVE");
    }
    When the Flash areas has the focus then you will see "ACTIVE" in the output window, when you click outside the output window will say "NOT ACTIVE". Just put the functions in your script where you need them, and add a pause effect into the windowNotActive function.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #3
    Join Date
    Apr 2010
    Posts
    58
    Thanks
    5
    Thanked 1 Time in 1 Post

    Default

    Thanks for the reply, quick question though, when you say "replace the traces with your code" does that mean replaces the traces with the file name of the code? I am generally a designer and don't know much about coding but if that isn't the case, what code should I put there?

  4. #4
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Well, you want to stop the movie when it doesn't have focus.

    So your focus event will be something like:

    Code:
    function main():void
    {
        stage.addEventListener(Event.DEACTIVATE, windowNotActive);
        stage.addEventListener(Event.ACTIVATE, windowActive);
    }
    main();
    
    function windowNotActive(e:Event):void
    {
        stop();
    }
    
    function windowActive(e:Event):void
    {
        play();
    }
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •