A stopListener in AS3

I have AS2 code that listens for the end of an instance of FLVPlayback and a .js file that picks that event up and removes the transparent video from the layer above existing HTML content. (I think.) I've been using the combination for two years successfully on many sites. Since I discovered "preview" in the parameters in CS3/AS3 I miss it in AS2 but I don't know AS3 anywhere near well enough to duplicate what works in AS2. Is there a kind soul about who might? Here's the AS2 code:
import flash.external.*;
var fired:Boolean = false;
var stopListener:Object = new Object();
stopListener.stopped = function(eventObject:Object):Void
  trace("stopped");
  if (!fired)
   ExternalInterface.call("onVidStop");
   fired = true;
flvpb.addEventListener("stopped", stopListener);
Help much appreciated.
David Hurdon

Many thanks for your reply. I will try it shortly but meanwhile a question. If the video overlay had a "close" button and a visitor used it before the event was complete, to use your terminology, would that likely affect whether or not it exited? I'm still trying to find the .fla created in making this example:
http://www.netvideomaker.com/greeterclose/
Because I didn't position it over anything live I can't be sure that it's actually gone although it would seem so, and the .js files I always use in these projects, are present on the web server.
I guess my question is, would using stop vs complete cover more bases?
David
PS For the record I had lost track of the fact that I previously succeeded in mixing a close button with player controls and an exit function. When I came upon this example today I started looking for the project I made it with, and so far can't find the .fla. I want to be able to duplicate this result routinely, but in AS3 this time.

Similar Messages

  • Photo gallery in as3

    I'm making photo gallery where photos will be loaded from external xml file but i have problem. I want to add an effect when photo is changing like on this site: http://www.studiomelon.pl/index.html#/1/  Could somebody help me with that? I am noob in flash so please explain it as clear as you can. Thanks.

    I was sesrching for that for a long time before i created this tread. There is many tutorials and exaple files for page flip or page turn but i cant find good one. Many of them was coded in as1 or as2 other using php and java script so its difficult  to understant. I just want one simple solution for that. It cant be so hard to create something like that. Could you help me to find some good and simple tutorial in as3?

  • Creating an "if" Statement in AS3

    I've been having a problem trying to implement 2 email forms in the same scene at different places in the timeline.  If I do just one form, there isn't a problem, but there is a problem with the 2nd form (I've tried using different instance names to no avail). However, it appears I have most of it figured out, but am still having a problem, which I believe I may have a solution for by using an "if" statement.  In the following AS3 code is a string that reads var URL_request:URLRequest = new URLRequest( "send_email.php" ); I believe I may be able to resolve the problem if I had a 2nd string (in the same code) that read var URL_request:URLRequest = new URLRequest( "send_email_02.php" ); Is there a way to include that string in the same AS3 by using an "if" statement telling the code to "submit" the 2nd form?  If so, could someone please give me an example of how to write that "if" statement? This form has been driving me nuts for 4 days now and any help would be greatly appreciated. Thank you.
    stop();
    contact_name.text = contact_email.text = contact_subject.text =
    contact_message.text = message_status.text = "";
    send_button.addEventListener(MouseEvent.CLICK, submit);
    reset_button.addEventListener(MouseEvent.CLICK, reset);
    var timer:Timer;
    var var_load:URLLoader = new URLLoader;
    var URL_request:URLRequest = new URLRequest( "send_email.php" );
    URL_request.method = URLRequestMethod.POST;
    function submit(e:MouseEvent):void
    if( contact_name.text == "" || contact_email.text == "" ||
      contact_subject.text == "" || contact_message.text == "" )
      message_status.text = "Please complete all text fields.";
    else if( !validate_email(contact_email.text) )
      message_status.text = "Please enter a valid email address.";
    else
      message_status.text = "sending...";
      var email_data:String = "name=" + contact_name.text
            + "&email=" + contact_email.text
            + "&subject=" + contact_subject.text
            + "&message=" + contact_message.text;
      var URL_vars:URLVariables = new URLVariables(email_data);
      URL_vars.dataFormat = URLLoaderDataFormat.TEXT;
      URL_request.data = URL_vars;
      var_load.load( URL_request );
      var_load.addEventListener(Event.COMPLETE, receive_response );
    function reset(e:MouseEvent):void
    contact_name.text = contact_email.text = contact_subject.text =
    contact_message.text = message_status.text = "";
    function validate_email(s:String):Boolean
    var p:RegExp = /(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/;
    var r:Object = p.exec(s);
    if( r == null )
      return false;
    return true;
    function receive_response(e:Event):void
    var loader:URLLoader = URLLoader(e.target);
        var email_status = new URLVariables(loader.data).success;
    if( email_status == "yes" )
      message_status.text = "Success! Your message was sent.";
      timer = new Timer(500);
      timer.addEventListener(TimerEvent.TIMER, on_timer);
      timer.start();
    else
      message_status.text = "Failed! Your message was not sent.";
    function on_timer(te:TimerEvent):void
    if( timer.currentCount >= 10 )
      contact_name.text = contact_email.text = contact_subject.text =
      contact_message.text = message_status.text = "";
      timer.removeEventListener(TimerEvent.TIMER, on_timer);

    While the overall scenario isn't all that clear to me, you don't necessarily need an if statement, but just have the different submit buttons assign the different URL_request values before they intiate any other processing.

  • Help with a preloader in AS3

    Hi,
    I upload a website and I have problems with the preloader did it in AS3. It starts after two or three minutes. I have a MC with an animation of 100 frames and the dynamic text of the percent. The preloader is located in the 1 frame to the 10, I mean, first frame with the actions and the other three layers (text, MC and background) with a lenght of 10. The movie has 525 frames. Here is the code:
    stop();
    addEventListener(Event.ENTER_FRAME, lodeando);
    function lodeando(event:Event):void
              var bytesTotales = stage.loaderInfo.bytesTotal;
              var bytesCargados = stage.loaderInfo.bytesLoaded;
              var porcentaje = Math.round(bytesCargados * 100 / bytesTotales);
              textoPorcentaje.text = porcentaje + "% Cargados";
              cargaAnimada_mc.gotoAndStop(porcentaje);
              if (bytesCargados == bytesTotales)
                        removeEventListener(Event.ENTER_FRAME, lodeando);
                        gotoAndPlay(2);
                        textoPorcentaje.text = "";
                        removeChild(textoPorcentaje);
                        removeChild(cargaAnimada_mc);
    Please, Could you help me?.

    These screen captures show the library of the movie. As you can see I export the most of them. However I have doubts about if I must convert to symbol the graphics. I have the preloader in the "presentación" folder without any exportation.
    Please, Could you correct the website?. Please, tell me an e-mail address and I send you the website via WeTransfer.

  • Text input action AS3

    I have a text input field on the timeline that I want the user to enter specific information in. When that information is correctly entered, I need the timeline to progress.
    I successfully used the following AS2, but I cant find corresponding code for AS3
    on (keyPress "x") {
    gotoAndPlay("s05");
    Any help on converting this function to AS3 is greatly appreciated.

    You can use an Event.CHANGE listener for the textfield and then test its value in the event handler function to see if it agrees with the required string...
    inputtField.addEventListener(Event.CHANGE, testEntry);
    function testEntry(evt:Event):void {
         if(inputField.text == "whatever"){
              // do stuff

  • New to Flash AS3, Need help with some weird issues, have .fla link attached...

    Basically, the buttons are not visible when siteplan_mc is replayeed after floorplan closes, but they still work. Most things are only working on double click for soe reason, tho I have them to function on click. and the back button only woorks on unit 1 floorplan, tho the code it the same for all floorplans. I have a feeling it has something to do with levels... but I really have no idea... hopefully someone can help!
    thanks in advance,
    Sarah
    http://www.30eastroosevelt.com/RRHA_SITE.fla

    There are at least two things you're doing wrong. You can't go to a frame where something exists for the first time, and immediately do something to it. Like in your playunit functios for example:
    gotoAndStop("unit1")
    unit1_mc.alpha = 1
    unit1_mc hasn't yet drawn itself on stage to have its alpha set, and so there's an error. That is something that was improved in Flash 10, so if you had set the Flash to publish for Flash 10 and not Flash 9, then the floor plans and the back buttons appears ok. It would sometimes work with double clicks because by the second time you clicked, the movieclip now existed. You might be able to do what you want by having all of the room units on frame 1 of the siteplan_mc, and then set their visible to true or false as you need them, instead of doing the gotoAndStop().
    The other problem is that you're trying to set listeners on the Back buttons that don't yet exist. Wait until you're on the frame where the buttons exists, and then set its listener for the mouse click.
    Other things you're doing could be improved too, but really you might want to get together with someone who has done more AS3, to help you become more familiar with how it works.

  • HELP! Uploading AS3 Game to server, no sound and Spacebar doesn´t work HELP!

    Hello, relatively new to AS3 and flash, this is the first time i am publishing anything. We are trying to upload our simple flashgame to our webserver, the game works perfectly fine locally save for one thing. We get an error regarding TLF which says it wont stream or something. So when it gets online, no sounds play and spacebar doesn't work, left and right arrow does work. We have three TLF text fields that are used to update score, lives and show you final score. If i turn these into classical text they stop working.
    Things we have tried: Changing default linkage from RLS to Merged into code, changing the text boxes to classical text(they then stop working), made sure the paths are correct(all files are in the same directory including the .swz file)
    This is the code from the soundclass:
    package 
        import flash.net.URLRequest;
        import flash.media.Sound;
        import flash.media.SoundChannel;
        import flash.events.*;
        public class MySound
            private var bgSound:Sound;
            private var fireSound:Sound;
            private var waterSound:Sound;
            private var earthSound:Sound;
            private var lightSound:Sound;
            private var soundChannel:SoundChannel;
            public function MySound()
                soundChannel = new SoundChannel();
                bgSound = new Sound();
                var req:URLRequest = new URLRequest("BackgroundSound.mp3");
                bgSound.load(req);
                //fire
                fireSound = new Sound();
                var req2:URLRequest = new URLRequest("soundFire.mp3");
                fireSound.load(req2);
                // water
                waterSound = new Sound();
                var req3:URLRequest = new URLRequest("soundWater.mp3");
                waterSound.load(req3);
                // earth
                earthSound = new Sound();
                var req4:URLRequest = new URLRequest("soundEarth.mp3");
                earthSound.load(req4);
                // light
                lightSound = new Sound();
                var req5:URLRequest = new URLRequest("soundLight.mp3");
                lightSound.load(req5);
            public function playBgSound()
                soundChannel = bgSound.play(0, 999999);
            public function stopBgSound()
                soundChannel.stop();
            public function playFireSound()
                fireSound.play();
            public function playWaterSound()
                waterSound.play();
            public function playEarthSound()
                earthSound.play();
            public function playLightSound()
                lightSound.play();
    I can somewhat get that sound can bugg out, but why does spacebar stop functioning? ANy help is greatly appreciated as this has to be delivered in twelve hours(published online) for a school assignment.

    Also might add publishing it locally in my own browser everything works, as does ofcourse playing it in flash itself. Changing from RLS to merged into code stops the error from coming, but doesn´t fix the problem on the server.
    Code from main class related to sound and spacebar:
    import flash.display.*;
        import flash.events.*;
        import flash.ui.Keyboard;
        import flash.text.TextField;
        import flash.media.Sound;
        import flash.net.URLRequest;
        import flash.events.MouseEvent;
        import flash.utils.Timer;
        import flash.events.TimerEvent;
        public class main extends MovieClip
            private var fireTimer:Timer; //delay between shots
            private var canFire:Boolean = true;
            private var mySound:MySound;
            private var bulletSpeed:Number = -450;
              public function main()
                //load sounds
                mySound = new MySound();
            private function playGame(event:MouseEvent)
                gotoAndStop(2);
                // initialize
                myLives = 5;
                myHitsNo = 0;
                weaponType = 1;
                mybullets = new Array();
                enemys = new Array();       
                myScoreTxt.text = "Score: " + myHitsNo;
                myLivesTxt.text = "Lives: " + myLives;   
                fireTimer = new Timer(400, 1);
                fireTimer.addEventListener(TimerEvent.TIMER, shootTimerHandler, false, 0, true);
                stage.addEventListener(KeyboardEvent.KEY_DOWN, listenKeyDown);
                stage.addEventListener(Event.ENTER_FRAME, addEnemy);
                stage.addEventListener(Event.ENTER_FRAME, checkCollision);   
                player = new thePlayer(stage.stageWidth-40, spawnPoint2);// stage.stageHeight/2);
                stage.focus = player;
                addChild(player);
                mySound.playBgSound();
    public function listenKeyDown(event:KeyboardEvent)  // Controls and weapontype selector
                if (event.keyCode == 37) //left
                    player.movethePlayerDown();
                if (event.keyCode == 39) //right
                    player.movethePlayerUp();
    if (event.keyCode == Keyboard.SPACE) //space
                    shootBullet();
                    //soundFX.attachSound("Pistol Fire.wav");
                    //soundFX.start();

  • How to use as3 in flash cs3 to add dynamic text from a text file into a flash file

    let me start out by saying today is my first day of scripting
    in flash.
    I have a text file text.txt
    it contains
    text1=hello world
    can someone please show me how to display this text in a
    flash file
    i have been searching for this for hours and there are
    solutions with flash mx and actionscript 2.0 but i would like to
    see how to do this in as3.
    just a simple frame that loads that file and displays it when
    you test run the program
    much apreciated
    RC

    I'm not up on AS3 yet, but many things are still similar. You
    need to use the LoadVars class to accomplish this, You can find
    information this in Flahs Help>Actionscript>Actionscript
    Language Reference>Actionscript classes.
    rem: the text.txt file and the text.fla file must be in the
    same directory.
    The code will look something like this:

  • AS3 Scripting for Animated GIF

    Hi,
    I am trying to create an animated GIF for a white noise animation (needed for those viewers who don't have access to a Flash player). The SWF version runs perfectly. Currently, all of the AS3 for the bitmapData.noise and bitmapData.palettemap script is in the first keyframe. So, when I export as an animated GIF, I get a white screen in playback.
    I think the problem for the animated GIF is that there are no frames past the first frame. But, I am not sure how to add frames or re-write the AS3 to get a 30 second animated GIF? I tried duplicating the first keyframe into several new keyframes and get error messages. I would appreciate any help.
    Here's the AS3 in the first keyframe that works well for a SWF (previous relevant thread: http://forums.adobe.com/thread/734335?tstart=0):
    var array:Array=new Array();
    for (var i:uint = 0; i < 255; i++) {
    array[i] = 0xffffff * (i % 2);
    var _bitmapData:BitmapData;
    var bDHolder:Sprite = new Sprite();
    _bitmapData = new BitmapData(stage.stageWidth/4, stage.stageHeight/4);
    bDHolder.addChild(new Bitmap(_bitmapData));
    bDHolder.scaleX = bDHolder.scaleY = 4;
    addChild(bDHolder);
    addEventListener(Event.ENTER_FRAME, onSpriteEnterFrame);
    function makeNoise():void {
                _bitmapData.noise(getTimer(), 100, 255, 7, true);
                _bitmapData.paletteMap(_bitmapData, _bitmapData.rect, new Point(0,0), array, array,array);
    function onSpriteEnterFrame(event:Event):void {
                makeNoise();
    var itsNoisy:Boolean = true;
    stage.addEventListener(MouseEvent.MOUSE_DOWN, manageNoise);
    function manageNoise(evt:MouseEvent):void {
         if(itsNoisy){
             removeEventListener(Event.ENTER_FRAME, onSpriteEnterFrame)
         } else {
             addEventListener(Event.ENTER_FRAME, onSpriteEnterFrame)
         itsNoisy = !itsNoisy;
    Kind Regards,

    Jimmy,
    You may (also) try to ask in the (most) relevant Photoshop forum.
    http://forums.adobe.com/community/photoshop

  • How to read a local file using as3 in a flash object in HTML? [urgent]

    My web site contains a flash object.
    I want to use as3 to read some local .txt file
    by getting the user directory of the file.
    i know AIR can support this by sth like:
    File.desktopDirectory.resolvePath
    but when i open a AIR file for this, it seems
    the action cant be run when i embed it in html.
    And i tried to use the above function in a normal
    flash file in the action script.
    But it cant recognize the File. class..
    How can it be done ?
    It's reli urgent,
    please help...
    Thanks !

    a web based flash app can't detect user directories.  you can use the filereference class'es browse method to let the user locate a file in any directory the user wants.  flash can then retrieve the file's name and type.  but, as mentioned before,  flash can't determine the file's directory.

  • How do I display AS3 Object in only one state?

    I created a AS3 object from a SWFLoader class as an animation, which I then place in a Flex stage.  I need to display the object programmatically in only one state but there is no "includeIn()" method to include it in just one state.
    Right now, it is showing up on all of the flex states.  I add this object at different times and positions in the state.  Everything is fine except it displays in all the states.
    How do I display a AS3 object in only one state?
    Thank you.

    When i use visible property as you suggested, it works, but only on one object.  I am generating more than one of these objects, so there could be 3 or 4, etc of these objects displaying concurrently at different x y positions in the state.
    Is there a way to grab all of the objects created by this AS3 class at once and apply the visible property?
    thanx

  • How can I display a Movie clip from library on stage in AS3?

    Hi,
    I have a movie clip in my library and I would like to display it on the stage using AS3.
    do I have to define it as a variable?Do  I need to use this code:  addchild(movieclip);
    can I use the 'x' and 'y' to position it?
    What would the code look like?
    Ben.

    Great! it works  well ! thanks
    But I have another question, if I wanted to used the same movie clip but postion it at different x and y positions when a different btn is selected how could I do that?
    Would I have to make a copy of the movie clip and give it a different name?
    or is there an better way around it?
    Ben.

  • AS3: How to access and control embedded sounds in an external swf?

    I rarely use sounds in AS3/Flash. I am using Flash Pro CS6, but I can't seem to figure out how to access, control (play, stop, etc) sounds embedded in an external SWF loaded into the main SWF.
    It's easy to control them when embedded on the main swf. However, on an externally loaded SWR, I get all kinds of errors. For this app, I really need to embed them in the external SWF.
    I read several solutions, but none seem to work.
    I embed the sound an mp3 file called soundSegment1.mp3 using Flash CS6 import tool and then open the actionscript properties panel on flash to select the class name: SoundSegment1. Then I edit the class code and create a file called SoundSegment1.as and it's saved right next to my document class main.as in the same directory. The code of the SoundSegment1 class looks like this:
    package  {
        import flash.media.*;
        public class SoundSegment1 extends Sound
            public function SoundSegment1 ()
                // no code in here
            public function playSound()
                var soundSegment1:Sound = new SoundSegment1();
                var channel:SoundChannel = soundSegment1.play();
    Then, in my main.as, I have done several attempts to play this sound such as:
    var fileLocation:URLRequest = new URLRequest(SWFToLoad); loader.load(fileLocation); loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressListener); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeListener); loader.contentLoaderInfo.addEventListener(Event.INIT, initListener); 
    function initListener(e:Event):void // I also placed this code on the completeListener and it didn't work {      loader.content.soundSegment1.playSound(); // doesn't work.  }
    I get:
    Line XXX 1061: Call to a possibly undefined method playSound through a reference with static type flash.display:DisplayObject.
    or, I also read that I should be able to do something like this anywhere in the Main.as file:
    var theClass:Class = Class(loader.content.getDefinitionByName("SoundSegment1")); var theSound:theClass = new theClass(); theSound.play()  //doesn't work either.
    I also tried on the completeListener:
    var TheClass:Class = e.target.applicationDomain.getDefinition("SoundSegment1") as Class; var theSound:TheClass = new TheClass();
    theSound.play()  //doesn't work either.
    I get:
    ReferenceError: Error #1065: Variable SoundSegment1 is not defined. at flash.system::ApplicationDomain/getDefinition()
    I am stuck and I really need to get this to work. I would be genuinely grateful for your help.
    Thank you in advance for any help provided. I really need to get it to work, because I can't simply embed them in the main SWF or load them individually externally one by one.
    Thanks again!

    THANK YOU!
    I think your code may be over my head though. I think you are using an anonymous function which is not something I am familiar with (but I want to learn about if it's useful).
    I also don't know where the classS came from. I see that it's a parameter sent along with the event, but I don't really see where that came from.
    Someone at: http://www.kirupa.com/forum/showthread.php?305098-Playing-a-embedded-sound-in-an-external- swf&p=2658098#post2658098
    Is showing what seems to be an easier solution, but my problem there is I can't access the source file of the "child" swf....  ayayay.....
    I am going to tinker with your solution and see if it gets me anywhere. Thanks so much for your help again.

  • How can you use one NetStream to publish video and audio from another NetStream in AS3?

    Let's say one of your client programs in AS3 is able to receive live video and audio from a NetStream and play it on the screen.  How could you make it also take that video/audio stream that it's receiving, copy it over into another NetStream, and publish it elsewhere?  I need to know how to do with this regardless of whether RTMP, RTMFP, or some mixture is involved.  The reason why the stream needs to be relayed this way is a real long story, but it's necessary in this particular case. Thanks!

    RTMP is TCP, which has higher overhead and latency because it guarantees packets are delivered (handshaking, causing latency and overhead). It also doesn't allow you to share connections directly between clients forcing the server to do all the work.
    RTMFP uses UDP, which is a choice protocol for streaming video because it's the opposite. It's lossy which decreases latency and overhead from no retransmissions and most importantly (in some applications) allows you to connect directly from one Flash Player to another Flash Player (p2p) so the server overhead is dramatically reduced. The server is only required to negotiate the initial connection and then it's up to the clients to continue to facilitate that.
    How you code your one to many or many to many relationship broadcast network will be based entirely on which of those you choose.
    URLStream is very common to use in p2p. Here's an older Adobe article on p2p and an alternate quick old video tutorial (FP10) as a quick simple example of p2p over RTMFP you can view the source of.

  • How do I create a play button for movie clip using AS3

    Hello.
    Bit new to this and have been searching the adobe forums and google. I am trying to create a button that will play an imported MovieClip.
    I have a movie clip that I've imported into it's own layer (Layer1) Frame 1.  I've given the MovieClip an instance name of foundationMovie.
    I've created a button and have that on its own layer(Layer2) above layer1, it is also in Frame 1.
    I've added a
    stop (); action to layer2
    The video is not set to autoplay.
    I want the video to start playing when the viewer clicks the button.  I know I've got to put some kind of event listener using AS3 in my timeline somewhere.
    I've found some code and I've been trying to work with it.  I'm sure I've mutilated it beyond usability but this is what I've got.
    stop ();
    player.addEventListener(MouseEvent.CLICK,play);
    function play(event:MouseEvent)
    gotoAndPlay("foundationMovie");
    If someone could point me the right direction or help me with my code I would really appreciate it.  Thanks.

    First, you need to clear up what you are working with... a movieclip and a video are usually entirely different things.
    Next, your code may get you started on your way with some changes.   You shouldn't use "play" as a function name due to there already being a play() method/function in Flash.
    If the movieclip is a movieclip and has an instance name of "foundationMovie", and your button has an instance name of "player" then the following adjusted code would normally work...
    stop ();
    player.addEventListener(MouseEvent.CLICK,playMovie);
    function playMovie(event:MouseEvent)
         foundationMovie.play();

Maybe you are looking for

  • IPhoto slideshow to DVD for TV and PC viewing

    I am creating a slideshow that needs to be able to be played on a DVD with unknow TV and a PC with a projector. Will not know exactly which one. The slideshow is simple (200 images estimated), would like to have Ken Burns effect if possible. I also h

  • Buttons don't navigate properly in Apple DVD Player!

    Hello there, This is extraordinarily frustrating! Can somebody please help ASAP? We're running DVD Studio Pro 4.0.2 on Mac OS X 10.3.9, and we just finished authoring a DVD with a layered menu created from a Photoshop document. When we put the DVD in

  • ADF 11g - Query Component - How to set default values for search criteria

    I have defined a VO with named query (with 2 search criteria). I created a page and drop a query with table. It works just fine until this point. My requirement is to set a default values for the two search criteria. For example, I have release and c

  • Sharing email on a pc

    I want to set up my friends P3/550 MHz pc to dual boot Win98 and Arch Linux.  How would I set it up so that he could read and compose the same email in both systems?

  • How to Find the Query used by the Workbook ?

    Hi , I am currently involved in trouble shooting a work book where some master data values are not being displayed. How do i find, which Query the work books is using ? or Let me know as to how should i proceed in solving the same .