Spawning Enemies to Stage in Flash AS3

I have the enemies appearing on my stage  and spawning accordingly.  I have the location on where I want them to  spawn. The problem is that they are spawning on the first frame of my  game which is the main menu before entering the actual playing field. Not the second frame where my game commences.
How can i go about  this?
I tried this command and it just starts the game on the second frame.
I wrote this code within my createEnemy function.
   createEnemy.start(2);
        function commenceGame():void
                //Sliding Duck Objects
                enemy = 1000;
                enemyTimer = new Timer(1000, enemy);
                enemyStorage = new MovieClip();
                addChild(enemyStorage);
                enemyTimer.addEventListener(TimerEvent.TIMER,createEnemy);
                enemyTimer.start();
                cursor = new Cursor();
                addChild(cursor);
                cursor.enabled=true;
                Mouse.hide();
                stage.addEventListener(MouseEvent.MOUSE_MOVE,shiftCursor);
        //Creates Enemies on the Stage
        function createEnemy(event:TimerEvent):void
                var enemyAppear = new MovieClip;
                enemyAppear = new Enemy();
                enemyAppear.x = 245;
                enemyAppear.y = 285;
                enemyStorage.addChild(enemyAppear);
          commenceGame();
Hope this is enough code of my game to determine how to go about what I request.
Thanks Casey

If you don't want the enemiies to be generated until you are in frame 2, then put the enemy generating code in frame 2.

Similar Messages

  • Creating a file on server, using Flash AS3 + PHP

    I have a very simple PHP script that creates a new file on my server using a random number for the file name (e.g., 412561.txt).  When I load the script directly from a browser, it works.  But when I load the script from a very simple Flash (AS3) script, it does not work (i.e., doesn't create a file).  The Flash script and PHP script are both in the same directory.  Permissions on the directory and its content are 755.  Temporarily setting those permissions to 777 does not solve the problem (i.e., PHP still doesn't create file when called via Flash).
    Here is my phpinfo.
    Here is the PHP file.
    The contents of the PHP file are:
    <?php
    error_reporting(E_ALL);
    ini_set("display_errors", 1);
    $RandomNumber = rand(1,1000000);
    $filename = "$RandomNumber" . ".txt";
    $filecontent = "This is the content of the file.";
    if(file_exists($filename))
              {$myTextFileHandler = fopen($filename,"r+"); }
    else
              {$myTextFileHandler = fopen($filename,"w"); }
    if($myTextFileHandler)
              {$writeInTxtFile = @fwrite($myTextFileHandler,"$filecontent");}     
    fclose($myTextFileHandler);   
    ?>
    Here is the html container for the Flash script.  The Flash script features a single button which calls the PHP script when pressed.  In case it helps, here is the raw Flash file itself.  The code of the Flash script is as follows:
    stop();
    var varLoader:URLLoader = new URLLoader;
    var varURL:URLRequest = new URLRequest("http://www.jasonfinley.com/research/testing/TestingSaveData.php");
    btnSave.addEventListener(MouseEvent.CLICK,fxnSave);
    function fxnSave(event:MouseEvent):void{
              btnSave.enabled=false;
              varLoader.load(varURL);
    Directory listing is enabled at the parent directory here, so you can see there when a new text file is created or not.  (Um, if this is a security disaster, please let me know!)
    Can anyone please help me understand why this isn't working and how I can fix it?  Thank you
    ~jason

    #1, Yes that is a security risk, please disable directory index viewing.
    #2, Always validate. I see no issue with the code you're using but clearly it's not working. The way you find out is your trusty errors.
    Make a new document (or paste this into your existing) where a button with the instance name btnSave is on screen:
    // import required libs
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.events.Event;
    import flash.events.IOErrorEvent;
    import flash.events.MouseEvent;
    import flash.events.SecurityErrorEvent;
    import flash.text.TextField;
    // assign handler
    btnSave.addEventListener(MouseEvent.CLICK, fxnSave);
    // make a textfield to display status
    var tf:TextField = new TextField();
    addChild(tf);
    tf.width = stage.stageWidth;
    tf.height = 300;
    tf.multiline = true;
    tf.wordWrap = true;
    tf.selectable = false;
    tf.text = "Loading...\n";
    // just making sure the textfield is below the button
    this.swapChildren(tf,btnSave);
    function fxnSave(event:MouseEvent):void
        // disable button
        event.currentTarget.enabled = false;
        // new loader
        var varLoader:URLLoader = new URLLoader();
        // listen for load success
        varLoader.addEventListener(Event.COMPLETE, _onCompleteHandler);
        // listen for general errors
        varLoader.addEventListener(IOErrorEvent.IO_ERROR, _onErrorHandler);
        // listen for security / cross-domain errors
        varLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, _onErrorHandler);
        // perform load
        varLoader.load(new URLRequest("http://www.jasonfinley.com/research/testing/TestingSaveData.php"));
    // complete handler
    function _onCompleteHandler(e:Event):void
        tf.appendText("Load complete: " + e);
    // error handler
    function _onErrorHandler(e:Event)
        if (e.type == SecurityErrorEvent.SECURITY_ERROR)
            tf.appendText("Load failed, Security error: " + e + " type[" + e.type + "]");
        else if (e.type == IOErrorEvent.IO_ERROR)
            tf.appendText("Load failed, IO error: " + e + " type[" + e.type + "]");
    I get a Event.COMPLETE for mine, so the PHP script is definitely firing. Change the URL to something invalid and you'll see the IOErrorEvent fire off right away.
    That leaves you to diagnose the PHP script. Check your error_log and see what is going wrong. You're suppressing errors on your file write which doesn't help you locate the issue saving the file. If you want to handle errors yourself you should do the usual try/catch and handle the error yourself (write a debug log file, anything).

  • How to load and show PDF on stage in Flash using AlivePDF or PurePDF external libraries?

    Hello,
    I searched a lot on internet but didn't find a proper way to load and open/show PDF on stage in Flash. Following are my understandings about this topic.
    I know Flash does not have the built-in functionality to load and show pdf document on stage.
    I know you can do this in AIR application using HTMLLoader class but it required adove reader to be installed on your machine.
    I have used AlivePDF/PurePDF and I know how to export/generate a PDF File using these libraries but I don't know how to use them to load and show PDF document on stage in Flash. According to my research, I think these libraries can accomplish my task but how, I don't know. That's because I am here for your help.
    People suggest to first convert pdf into an image or swf file and then import it into Flash but I don't want this solution because my clients will be importing/uplading PDF file into my software.
    Some people suggest to "Convert PDF renderer code written in C/C++ using Alchemy to flash library" and then use that library to my project. I don't have any idea how to do this. If anyone can help me to achieve required functionality this way, please guide me.
    Now you know about my understandings, so you can guide me in better way. Let me give you an example what kind of functionality I want. Please visit: https://www.pdffiller.com. Upload a pdf file there and you will see that it shows that pdf to user (At the moment, I want this functionality) and pdf annotation i.e. write text on pdf and other functionalities.
    NOTE: I am not a Flex and AIR developer. I am a Flash (Actionscript 3.0) Developer. So please first help according to flash. If you want to offer the solution according to Flex and AIR, you are most welcome.
    I specially want "ADOBE EXPERTS - Adobe Flash developer from Adobe" to comment on this and help me out. It's about 4th day I am without a solution. I am afraid, I'll loose my client if I'll not have a solution in next couple of days.
    Thanks,
    momersaleem
    eLearning Specialist

    Just to throw in a $0.02, I looked at those libraries myself quite a while ago and all they had the ability to do was give you information and assets from the PDF. At that point you literally had to read each page in the PDF (whatever the library could extract), use the information it extracted (position, type size, images, etc) and create a layout engine that could "reconstruct" the page piece by piece.
    I hope it's better these days but that's what I took from those libraries quite a while ago and it may still be true. That would explain "Convert PDF renderer code written in c/c++ using Alchemy to flash library". Someone may already have written a quality layout engine. Otherwise there was no "load pdf, run this ShowPDF() function to add to display list" functionality at all.

  • Other problems with loading Captivate files into Flash AS3 project

    I have a Captivate file done with Captivate 3, published to
    Flash player 9 that is being loaded into Flash AS3. The captivate
    is a simple recording of some mouse clicks in a browser. I am
    displaying the playbar along the bottom, and its buttons all work
    fine except for the progress bar, where you can drag the knob and
    scrub back & forth in your presentation.
    This progress bar is not working as it should. I see the
    mouse cursor change to a hand, but when I click I cannot drag the
    knob to control the progress bar. The other buttons in the playbar
    do work (replay, pause, play, back, forward).
    This is a unique problem in that it is only happening when
    viewed in IE (7) when loaded into my Flash AS3 project. When viewed
    in Firefox in my project, or as a standalone SWF, or as a SWF
    simply embedded onto a plain HTML page, it works just fine.
    Does anybody have any insight?
    Another thing I notice with loading Captivate files with AS3
    is the the amount of output messages it displays. Rather annoying
    (unless this is a "feature" I've yet to be aware of - heh)

    Hi,
    I know exactly how you feel, there is simple answer; replace
    Captivate for Camtasia Studio 5 at techsmith.com. The weight on
    those shoulders will be gone! You'll smile more, be more
    socialable. One Happy Person.
    I am very happy person ;)
    Kind Regards,
    Boxing Boom

  • How to load html page or website in flash as3

    hi
    how to load html page or web link (www.google.com)  in flash as3.
    please help me...

    Use the navigateToURL function...
    var url:String = "http://www.wherever.com";:
    var req:URLRequest = new URLRequest(url);
    navigateToURL(req);
    OR in one line...
    navugateToURL(new URLRequest("http://www.wherever.com"));

  • Controlling External Captivate 5 swf using flash AS3

    Hi,
    I have created a basic Flash AS3 interface in which I am trying to control the navigation (next slide / previous slide) of an external captivate 5 swf which I have added using a loader, but i cant work out the solution.
    My code is currently as follows:
    import flash.net.URLRequest;
    var Xpos: Number = 96
    var Ypos: Number = 94
    var my_loader:Loader = new Loader();
    my_loader.load(new URLRequest("content.swf"));
    my_loader.x = Xpos;
    my_loader.y = Ypos;
    addChild(my_loader);
    stop();
    nextBut.addEventListener(MouseEvent.MOUSE_UP,gotonextframe);
    function gotonextframe(event:MouseEvent){
    MovieClip(my_loader.content).rdcmndNextSlide();
    Any help would be much appreciated,
    thanks
    Dez

    Thats perfect, thanks for the reply, much appreciated!
    I guess you have tried:
    rdcmndRewindAndStop
    Set to 1 to rewind and stop the project.

  • How to get this PHP list in Flash AS3?

    Hi,
    I have the following PHP code (downloaded from net) which builds a list of all the files in a "MyPics" folders:
    PS php can build a list of all the files in a folder so you don't have to type them all out like that, plus it makes updating a sinch all you have to do is put a pic in the folder and it will be added to the list.
    PHP Code:
    <CODE>
    <?
    //this function goes through the defined directory and makes a list of all the files
    function parse_dir($dir,$level){
        $dp=opendir($dir); //opens the directory for reading
        while (false!=($file=readdir($dp))){  //runs until no more files
            if ($file!="." && $file!=".." && $file!=".htaccess"){  //so you don't get all the default folders
                $countervar=$countervar+1;  //just a counter for numbering the path names
                if (is_dir($dir."/".$file)) parse_dir  //recurses the subdirectories
    ($dir."/".$file,$level+1);
                else print "&path".$countervar."=".$dir."/".$file;  //pieces together something flash can read
    $start_dir="pathToMyPics";  //put the name of the folder with all the pics here
    $level=1;
    parse_dir($start_dir,$level);
    ?>
    <CODE/>
    The above php will output something like this
    &path1=pathToMyPics/pic1.jpg&path2=pathToMyPics/wowWhatAWierdPicName.jpg
    call the php in flash( loadVariables("fileListPHP.php") ) and viola you get easy to use paths to all you pictures.
    I am not able to understand the code to write on FLASH AS3 frame. Please help.
    Thanks.

    In AS3 you want to use the URLVariables class.  Search Google using "AS3 URLVariables tutorial" and you should find what you need to get going.  Here's one result from that search...
    http://www.metah.ch/blog/2008/01/using-urlvariables/

  • Convert Flash AS3 to JAVA .Jar-file?

    Hello All,
    in the old old version of Director, you could export a .JAR
    file from your project. If you stayed within the programming that
    the exporter supported.
    I wonder, as I have seen some "Java to Flash as3"-converters,
    if anything is out there for the opposite?
    Cause I need something to make a JAR file for some simple
    functionality in JAVA, and I thought Flash could aid me..?

    Can someone answer?

  • Create a toc from adobe flash as3?

    hi guys
    i wante to create a completely toc in adobe flash as3? is there any way to do this?
    for example i want to create a toc file with full size logo (photo form toc information)
    or change duration location with slide title
    i want also another questiion about sdk folder in adobe captivate, i found some swc file in this folder, but i want documetion to use this swf file in custome development,
    thank

    Hi
    Please elaborate a bit more as you want users to download pdf from your site or print site page as pdf etc
    If its regarding documents then you can add add df documents in your site and then link them to pages where users can download the pdf, if you are referring to print page then you can provide information for ctrl+p/cmd+p , or add html code for print shortcut.
    https://forums.adobe.com/message/6319543
    Thanks,
    Sanjit

  • Flash as3 code in Cap 7

    I would like to add a flash AS3 movie and buttons in my Cap project that would goto certian slides. I've looked everywhere to find  some code that would help me on my way, but no luck. Can anyone here help?
    THanks

    If you create a new widget in Captivate it will supply with the code to access Captivate. This should get you there.
    http://www.infosemantics.com.au/widgetking/category/captivate-variables/

  • Best way to interface flash AS3 with CF

    Does anyone know of any good examples of how to interface
    Flash AS3 with Coldfusion?
    Thanks!!!
    Carlos

    Unfortunately the camera does something with flash media, which could confuse the question. Do you mean that you want to use this camera for creating Adobe Flash Video content? If that's the case I would argue to use its 720p/24p mode, that would give you 24 fps 1280x720 movies that ought to work nicely in Flash, and could scale to smaller 16:9 sizes better than say a 1080i video would. You could use 720p/30p too if you want it a little smoother.
    If you have Studio 8 installed on the machine you're using, you can export straight from FCP to FLV, by choosing the Export to FLV option in the Export using QuickTime Conversion dialog.

  • Loading Flash AS3/XML into Flex 3

    I'm seriously at a loss.
    I'm loading a Flash AS3 SWF into Flex via SWFloader and it
    will not load the xml data the file normally loads. The Flash file
    is fairly basic and loads XML data from a local file.
    I've tried all sorts of scoping within the Flash file
    pointing to the xml file just in case but still nothing. What do I
    need to do to get this file to read the XML through Flex 3?
    <mx:SWFLoader x="9" y="14" width="140" height="90"
    source="swfs/sponsors/top_sponsors.swf"/>
    The xml file is in the same directory.

    The migration of this file to proper AS3 is brutal. It would
    be easier to just rewrite the whole thing in flex. Screw it.

  • Liquify Bloat effect in Flash as3

    I am looking for a technique to create a Liquify Bloat effect as in Photoshop. I need to create some tool which makes a person's face look a bit broad or you can say make him fat. The Liquify Bloat tool in Photoshop does almost the same of what is required but I was not able to find a technique to replicate it in Flash AS3. I have tried using the Perlin Noise and other liquify effects but not able to get what is required. I think it might be achievable by using the Perlin noise as shown here: http://www.erikhallander.com/dev/as3/more_perlin.html But Not sure what should be the perlin parameters for the required effect.

    I think PixelBender is the right approach for your needs: http://www.adobe.com/devnet/pixelbender.html
    I don't have an example right now, but I've already seen a few filters doing exactly what you want.

  • I Need a Pageflip Book for Flash AS3 Website (non-flex based)?

    Hello,
    I am rebuilding my website from a simple html based website to a Flash AS3 website. The problem I've run into is that I can not get my flex based flipbook onto my Flash AS3 website.
    Apparently AS3 is not flex base compatible. Does anyone know a pageflip book program I can use in Flash AS3? Oh, one more thing. I do not know computer code. I need something like Bannerzest. Thank you.

    for example , I have a book ..
    which has these chapters....
    Introducing Adobe Flex 2
    Working with MXML in Adobe Flex 2
    Working with ActionScript in Adobe Flex 2
    Nowhere , in this book ...integration with J2EE application has been described .
    can we really use it for J2EE application ? or I am chasing in wrong direction ?

  • PUT and DELETE in Flash AS3

    I am working on the Google Calendar API which has been built for Flex/AIR. In the API, for performing a Delete or Update operation, it uses DELETE or PUT methods in the URLRequest. But I think these being REST based calls are supported in AIR.
    I am using this API in a Flash/AS3 application and have successfully implemented the Update functionality by using X-HTTP-Method-Override method for PUT and instead using POST, which is supported in Flash. But when I try to do the same thing for Delete method, I get a 401 error in the API call.
    Any idea how this problem could be solved?

    AIR supports all the specified HTTP methods, but there seems to be a bug in the HTTPService class. Instead you should use URLLoader and URLRequest. If you change to that you won't even need to use the Method Override header.
    Read more here : http://spy6.blogspot.com/2009/06/adobe-air-put-delete-head-http-methods.html .

Maybe you are looking for