How to load and replace random swfs into same loader on stage?

Hi...this is very simple, but, for some reason escapes me: using AS3 how can a swf load another swf to replace itself in the same loader on the stage, while simultaneously calling a randomizing function in the first frame of the main timeline, to randomize the next swf?
At the end of each swf (called "koan_#.swf") there is the following old AS2 code...it was used to randomly select and then play a swf from koan array:
_root.index++
if(_root.index>_root.koan.length-1){
_root.index=0;
_root.koan.shuffle();
_root.koan_loader_mc.loadMovie(_root.koan[_root.index]);
This code on the first frame of the main timeline loads a random koan swf properly, but, after the koan plays I would like to load a new random koan swf.
function shuffle(a:Array):Array {
var len:Number = a.length-1;
for (var ivar:Number = len; ivar>=0; ivar--) {
  var p:Number = Math.floor(Math.random()*(ivar+1));
  var t = a[ivar];
  a[ivar] = a[p];
  a[p] = t;
return a;
var index:uint = 0;
var koan_loader:Loader = new Loader();
var koan:Array =["swfs/koans/koan_1.swf","swfs/koans/koan_2.swf", "swfs/koans/koan_3.swf", "swfs/koans/koan_4.swf", "swfs/koans/koan_5.swf", "swfs/koans/koan_6.swf", "swfs/koans/koan_7.swf", "swfs/koans/koan_8.swf", "swfs/koans/koan_9.swf", "swfs/koans/koan_10.swf", "swfs/koans/koan_11.swf", "swfs/koans/koan_12.swf"];
koan = shuffle(koan);
koan_loader.load(new URLRequest(koan[index]));
MovieClip(this).koan_loader_mc.addChild(koan_loader);
Thank you very much.  I've tried multiple variations of updated AS2 code but am at my wits end. 

Alright, the bloody forums won't attach the file for some reason, so here is the code:
Copy and paste this code into a text file and save it as InterfaceEvent.as
package {
     import flash.events.Event;
     public class InterfaceEvent extends Event {
          public static const KOAN_FINISHED:String = "koanFinished";
          public function InterfaceEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, index:int = -1, item:Object = null) {
               super(type, bubbles, cancelable);
               this.index = index;
               this.item = item;
          public var index:int = -1;
          public var item:Object = null;
          override public function clone():Event {
               return new InterfaceEvent(this.type, this.bubbles, this.cancelable, this.index, this.item);

Similar Messages

  • How to drag and drop another swf or fla into a template?

    I am building a flash website for a friend. We are using templates he purchased at flashden.net.
    I normally use wordpress, joomla and other such systems and am familiar with html, php, cgi and such.
    This is my first time dealing with a flash template.
    I have downloaded the trial version of the software and he wants to purchase adobe flash professional for me
    So that we can edit the template and add features he wants in the future.
    The website that sells the templates says you can easily drag and drop addons to templates in flash
    but I am not finding it so easy. Is there somewhere online where I can find a tutuorial on how to step by step
    drag and drop flash files into another template etc.?
    Also, where can I find good tutorials in general? I have downloaded adobe flash for dummies it is not as indepth as I need
    to get a handle on this software.
    Thank you to anyone that offers me any advice,
    David Doherty

    Ned,
    Thank you for responding.
    Flashden.net does claim its a simple drag and drop operation to do this but they have little to know information on the site about the subject and
    having difficulty with the sellers on step by step instructions. They claim it's easy it may be.
    The person I am building the website for had a bad experience with one of the sellers who refused to offer anything but basic instructions and claimed the cost of the software was not worth his time.
    Here are the instructions that were provided:
      Open news_rotator.fla
      Go to library.
      Select and copy NewsRotator movie clip.
      Paste it into your own project’s library.
      Now, you can drag and drop it into your own movie clips.
      Use news.xml to add/remove headlines.
    As you can see from what your telling me this is insufficent information on how to drag and drop this flash into another flash template.
    I will attempt to contact other selers at flashden for information as I have other flash templates we have purchased.
    Thank you,
    David Doherty

  • How to read and write a string into a txt.file

    Hi, I am now using BEA Workshop for Weblogic Platform version10. I am using J2EE is my programming language. The problem I encounter is as the above title; how to read and write a string into a txt.file with a specific root directory? Do you have any sample codes to reference?
    I hope someone can answer my question as soon as possible
    Thank you very much.

    Accessing the file system directly from a web app is a bad idea for several reasons. See http://weblogs.java.net/blog/simongbrown/archive/2003/10/file_access_in.html for a great discussion of the topic.
    On Weblogic there seems to be two ways to access files. First, use a File T3 connector from the console. Second, use java.net.URL with the file: protocol. The T3File object has been deprecated and suggests:
    Deprecated in WebLogic Server 6.1. Use java.net.URL.openConnection() instead.
    Edited by: m0smith on Mar 12, 2008 5:18 PM

  • How to find and replace data in form fields in acrobat xi, its not allowing to do so while trying, a

    how to find and replace data in form fields in acrobat xi, its not allowing to do so while trying, asking for adobe livecycle to get installed. please help.

    Easiest way to do it is the following:
    - Open the PDF file in Acrobat.
    - Go to Tools - Forms - More Form Options - Export Data.
    - Save the form data as an XML file somewhere on your system.
    - Open XML the file in a plain-text editor (I recommend Notepad++).
    - Let's say you want to replace all the years in the dates from "2013" to "2014". Do a global Search&Replace of "2013-" to "2014-" (I added the dash just to make sure that only date fields are edited).
    - Save the XML file (maybe under a new name).
    - Go back to the PDF file, and now go to Tools - Forms - More Form Options - Import Data.
    - Select the edited XML file and import it.
    - Done!

  • How to upload  and download a files into AL11 directory in ABAP

    Hi,
                   How to upload  and download a files into AL11 directory in ABAP
    thanks
    Moderator message: please search for available information/documentation.
    Edited by: Thomas Zloch on Mar 21, 2011 9:18 AM

    You should try one of these forums for an answer to your question:
    http://swforum.sun.com/jive/forum.jspa?forumID=116
    http://community.java.net/netbeans
    http://linux.java.net

  • How to find and replace any string between " "

    Hi everyone,
    Here my sample
    String szTest;
    szTest = "Yellow banana";
    szTest = "Blue monkey";
    szTest = "Red mango";
    szTest is only needed when it's in testing progress. Now I want to put all of that in the /*comment*/ so the released program won't run those code any more (but still keep szTest so I can use it for future develop testing).
    So Here what I want after using the Find and Replace Box:
    //String szTest; //Manual
    /*szTest = "Yellow banana";*/ //use find and replace
    /*szTest = "Blue monkey";*/ //use find and replace
    /*szTest = "Red mango";*/ //use find and replace
    I think I can do this with Regular expressions or Wildcards. But I don't know how to find and replace any string between " and ".
    Find: szTest = " ??Any string?? ";
    Replace with: /*szTest = " ??Any string?? ";*/
    Thanks for reading.

    Hi Nathan.j.Smith,
    Based on your issue, I suggest you can try the Joel's suggestion check your issue again. In addition, I find a MSDN document about how to use the Regex.Replace Method to match a regular expression pattern with a specified replacement string,
    maybe you will get some useful message.
    https://msdn.microsoft.com/en-us/library/xwewhkd1(v=vs.110).aspx
    If the above suggestion still could not provide you, could you please tell me what language you use to create the program for finding and replace any string using regular expression so that we will find the correct programming develop forum to support this
    issue?
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • In Pages, how to search and replace text involving invisible characters?

    In Pages documents, how to search and replace text involving invisible characters, colors and font sizes—a task which is so easy in Mircosoft Word?

    I read that an older version of Pages allowed users to enter special characters in the search/replace fields, but this did not work for me.
    Here: http://www.macworld.com/article/1156533/pagesspecialcharacters.html
    I still am looking for a way to do this.

  • How to remove and replace keyboard on HP Touchsmart Notebook 15-D020NR

    I spilled a drink on my keyboard and now I cannot get the Caps Lock to turn off and a number of keys do not work. I need the instructions on how to remove and replace this no frame keyboard. Thank you.    

    On your Support page- look for Maintenance and Service Guide under Manuals. http://support.hp.com/us-en/product/HP-15-d000-TouchSmart-Notebook-PC-series/6627588/model/6761859/manuals

  • Satellite A30-921: How to remove and replace the memory?

    hi, can anyone help me how to remove and replace the memory of sat A30-921. and also, please give a detailed instruction.
    thank you in advance.

    Hi
    There is no much to explain. At the bottom side in the middle there is placed memory cover (fixed with two screws). Remove the cover and you will see 2 slots there. I dont know how much memory has you there but as Stefan said you can use max 2 GB of RAM (2x PC2700 1024MB - PA3313U-1M1G). How to remove memory modules you can see on http://www.hardwaresecrets.com/article/189/5
    Bye

  • I want to change my apple id primary e-mail from a .msn address to a .gmail address. The problem is that currently my .gmail address is my cover address and I cannot figure out how to remove and replace my gmail recovery address.

    I want to change my apple id primary e-mail from a .msn address to a .gmail address. The problem is that currently my .gmail address is my recovery address; I cannot figure out how to remove and replace my gmail recovery address with a new e-mail address.  I want to do this because I no longer use my .msn address.

    You should be able to change your rescue address by going to My Apple ID, signing in to manage your ID, then selecting the the Password and Security section, and answering the two security questions.  If you have trouble with this, contact the Apple account security team for your country to verify your identity and ask for assistance: Apple ID: Contacting Apple for help with Apple ID account security.  If your country isn't listed, contact iTunes store support by filling out this form: https://www.apple.com/emea/support/itunes/contact.html.

  • Why I can't see the button fuse, when I drag and drop a folder into same name folder

    Why I can't see the button fuse, when I drag and drop a folder into same name folder
    I saw the option only one time, and i reseach in the internet and I find fuse option, but now never saw again.
    And Yes, I drag folders with the same name.

    Ok, Gracias por su pronta respuesta, yo necesito arrastar una carpeta a otra ubicacion con una carpeta del mismo nombre, entiendo que lion te advierte si desea reemplazar el contenido o fusionar (mexclar el contenido)
    como lo dice aqui :
    http://www.cioal.com/2011/06/29/las-cinco-novedades-mas-importantes-de-mac-os-x- lion/
    3. Podrás combinar tus archivos y carpetas. Seguro que alguna vez has perdido algún archivo al combinar carpetas o archivos del mismo nombre pero distinto contenido. Ahora, cuando intentes mover una carpeta a un lugar con otra de idéntico nombre, tu equipo te preguntará si prefieres combinar ambas o cambiar una por otra. Los archivos serán tratados de una manera similar: Cuando coincidan archivos con el mismo nombre, el sistema te preguntará también si quieres mantener ambas copias.
    y en muchas otras paginas que tratan el tema.
    mi problema es que esa opcion no me aparece. solo la opcion de reemplazar (o no reemplazar o detener)
    Lo increible es que alguna vez el mismo dia de hoy si me aperecio la opcion.

  • Load random swf into movie

    I need to load a randomly selected .swf into my main movie.
    Have found the code below which does all the loading fine...
    ... however, I need to keep elements from the original, so is
    there a way to load the new movie INTO the main one?
    I think I might need to load into an empty instance? If so,
    what does my code need to look like?
    Thanks in advance

    You should use the MovieClipLoader class.
    var mcl = new MovieClipLoader();
    var lis = new Object();
    lis.onLoadInit = function(target:MovieClip){
    //target is loaded and ready when this fires
    mcl.addListener(lis);
    function loadFile(fileURL){
    mcl.loadClip(fileURL, content);
    Now you can just call loadFile with a url and it will be
    loaded into the
    clip 'content', which can be an empty clip on stage. You
    don't have to do
    anything in the listener, but you can set width, height,
    alpha etc. in
    onLoadInit.
    HTH
    Dave -
    www.offroadfire.com
    Head Developer
    http://www.blurredistinction.com
    Adobe Community Expert
    http://www.adobe.com/communities/experts/

  • AS3 array used to load and play random swfs?

    Hi, I'm trying to use an array adapted from AS2 script to load random swfs called "koan_1.swf" or "koan_2.swf" etc into a "koan_loader_mc" on the stage.  Each "koan_#.swf" has code in its last frame to both advance the "shuffle" array in the action script in the first frame of the stage and to load the next koan swf.  The code below -- almost -- works, but....?
    Frame on main stage:
    // creates function called at the end of koan_#.swfs
    function shuffle(a:Array) {
    for (var ivar = a.length-1; ivar>=0; ivar--) {
    var p = Math.floor(Math.random())(ivar+1);
    var t = a[ivar];
    a[ivar] = a[p];
    a[p] = t;
    // loads koans into koan_loader_mc
    var index:uint = 0;
    var koan_loader:Loader = new Loader();
    var koan:Array =["swfs/koans/koan_1.swf","swfs/koans/koan_2.swf", "swfs/koans/koan_3.swf", "swfs/koans/koan_4.swf", "swfs/koans/koan_5.swf", "swfs/koans/koan_6.swf", "swfs/koans/koan_7.swf", "swfs/koans/koan_8.swf", "swfs/koans/koan_9.swf", "swfs/koans/koan_10.swf", "swfs/koans/koan_11.swf", "swfs/koans/koan_12.swf"];
    koan.shuffle();
    koan_loader.load(new URLRequest(koan[index]));
    MovieClip(this).koan_loader_mc.addChild(koan_loader);
    MovieClip(this).stop();
    Code is on the last frame of the loaded koan swfs:
    MovieClip(stage).index++
    if(MovieClip(stage).index>MovieClip(stage).koan.length-1){
    MovieClip(stage).index=0;
    MovieClip(stage).koan.shuffle();
    MovieClip(stage).koan_loader.load(new URLRequest(koan[MovieClip(stage).index]));
    MovieClip(stage).koan_loader_mc.addChild(koan_loader);
    Thanks for -- any -- guidance and suggestions...at my wit's end...

    Thank you for taking the time to help, but......unfortunately it still isn't working.  When the "koan.shuffle():" segment of code on the first frame of the stage timeline, below, is commented out, everything else in the movie (except randomizing of swfs) works fine.
    This code loads swfs (but they are not randomized/shuffled):
    // loads koans into koan_loader_mc
    var index:uint = 0;
    var koan_loader:Loader = new Loader();
    var koan:Array =["swfs/koans/koan_1.swf","swfs/koans/koan_2.swf", "swfs/koans/koan_3.swf", "swfs/koans/koan_4.swf", "swfs/koans/koan_5.swf", "swfs/koans/koan_6.swf", "swfs/koans/koan_7.swf", "swfs/koans/koan_8.swf", "swfs/koans/koan_9.swf", "swfs/koans/koan_10.swf", "swfs/koans/koan_11.swf", "swfs/koans/koan_12.swf"];
    //koan.shuffle(); 
    koan_loader.load(new URLRequest(koan[index]));
    MovieClip(this).koan_loader_mc.addChild(koan_loader);
    Thanks again for your help....

  • How to Edit and Replace Psd Files in Adobe Flash - Help!

    Hi Everyone,
    I am new to flash and I am trying to build my first flash site using a flash template. I can use flash to edit certain components like header text, etc. But The content is impossible for me to change. I think that these are psd files, which I can open with gimp or another program and edit. I save and replace that file, but when I view movie again, the content is the same. I guess what I need to know is how to get these files back into my flash movie after I have edited them. Please help, I am no computer expert, but I am learning. A how to for dummies answer would be awesome.

    Maybe You should try the Flash-forum:
    http://forums.adobe.com/community/flash

  • Re: Satellite P750 - need instructions how to access and replace Wi-Fi adapter

    I have searched all over the web to find a guide on how to replace the wifi adapter or at least which screws to remove before lifting the keyboard out. I presume that the wifi adapter sits underneath the keyboard and is accessible by removing the keyboard .
    Case is that I wuld like to use widi and therefore I need to replace the atheros adapter with an intel one.
    I will probably end up doing this even with out instructions. So any help would be greatly appreciated so as to avoid any damage to this wonderfull machine.
    Further I could use tips on wireing should I stick to a two antenna card, and is the card interchangeable as to existing wireing. I don't know maybe one of the antenneas is in support of blutooth functionality. WIll it be okay just to attach the antennas to the new wifi 'only' card in their current configuration.
    Best,
    Jesper

    I agree with user above.. its a new notebook and Im wondering why you want to risk warranty cancelationif I would be you, I would not do that
    However, in order to remove the keyboard, some screws needs to be removed.
    The battery should be removed too.
    At the bottom, near the memory bay you have to remove two screws and 3rd one is placed near battery bay.
    Then open the display panel and insert a pin into the opening in the battery bay to push the keyboard free. Lift up the keyboard and free it from the logic upper assembly. Disconnect the cable on the back of the keyboard from the motherboard and remove the keyboard. There you should see the WLan card.
    The black WLAN antenna cable should be connected to (aux). Its the connector on the left of the WLAN card, and the white WLAN antenna (main) to the connector on the right.
    But once again would not recommend doing this as this would cancel the warranty and you could also damage other parts.

Maybe you are looking for