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/

Similar Messages

  • Load random swf but not same

    someone here helped with the code to load random SWF files
    into a movie clip...however, i need to make sure it doesnt load the
    one that's already playing, that it goes on to a new one
    everytime..

    i dont think saying thank you really does it, but really,
    thank you.. you've helped me countless number of times, and it's
    only made me better at what I do, so I really am great full .
    Thanks again

  • How to Load an SWF into the Parent SWF

    Hi all,
    I have 3 SWFs.
    X.SWF - Parent application. Contains an empty movie clip for
    loading external swfs using loadClip() method.
    B.SWF - Has some text and pics. Gets loaded into the empty
    movieclip on X.SWF. Also has a button saying 'Load A.SWF'.
    A.SWF - Similar to B.SWF with a button saying 'Load B.SWF'.
    When I start the main application (X.SWF) and load B.SWF into
    it all is fine.
    But would like to click on the 'Load A.SWF' button on B.SWF
    and load A.SWF into X.SWF. And visa-vesa.
    The problem is I'm not able to refer to the parent container
    (X) from these child (A and B) SWFs.
    Is there any way to do this?
    Thanks

    First if you use
    Button.onPress=function(){
    this._parent.loadMovie();
    the movie try to load swf into B.swf because "this" mean the
    button.Try with more ._parent or just if you X.swf is into the one
    MovieClip in 1st stage _level0.SWF.loadMovie();.Also if you want to
    load the A,B.swf into the stage simultaneously just create two
    movieclips into the X.swf mcA and mcB and the path has gone to
    _level0.SWF.mcA.loadMovie("A.swf"); :)

  • Load AS2 swf into AS3 swf problem

    I have a flash with AS3 and inside this swf i load in a AS2 swf.
    to load swf works just fine, but the problem is when i load this i want to go to
    a specific part of it, for example i want to go to frame 3 in the loaded swf.
    i must control this from the AS3 swf, does someone know if this is possible?
    thanks in advance

    so can i do like this then to go to frame 3 in my loaded swf?
    MovieClip(ldr.content).gotoAndStop(3); ?
    sorry for being such an airhead
    thanks for helping me out =)
    Date: Sun, 7 Jun 2009 10:25:09 -0600
    From: [email protected]
    To: [email protected]
    Subject: load AS2 swf into AS3 swf problem
    no.
    if, in your loaded swf, you have a function f1() on the loaded swf's main timeline and you load that swf using a loader (say ldr), use:
    MovieClip(ldr.content).f1();   // to call f1() in the loaded swf
    >

  • Can I load a swf into my Flex app that loads other swf's?

    The code below loads an AS2 swf into my Flex mobile for IOS app and it works.  If that AS2 swf has like a circle in it that runs across the stage, it loads and displays properly when run in FlashBuilder.
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                                     xmlns:s="library://ns.adobe.com/flex/spark"
                                     xmlns:mx="library://ns.adobe.com/flex/mx"
                                     initialize="init()">
              <fx:Script>
                        <![CDATA[
                                  import mx.core.UIComponent;
                                  private var request:URLRequest = new URLRequest("http://PATH_TO_AS2_SWF");
                                  private var loader:Loader = new Loader();
                                  private var myComponent:UIComponent = new UIComponent; 
                                  private function init():void{
                                            myComponent.percentHeight = 100;
                                            myComponent.percentWidth = 100;
                                            loader.load(request);
                                            myComponent.addChild(loader);
                                            player.addElement(myComponent);
                        ]]>
              </fx:Script>
              <s:Group id="player"
                                   height="100%" width="100%"/>
    </s:Application>
    But if that AS2 swf loads other swf's, they don't load or display.  My FlashBuilder debugger reports no errors or security sand box violations.   I'm using the most elemental code in my AS2 swf so as to not cause problems.  This is it in its entirety:
    this.onLoad = function(){
              _root.loadMovie("http://[PATH_TO_REMOTE_SWF]");
    The paths to the remote content are fine because swf's load and display fine from AS2 swf when run on it's own - not embedded in Flex app.  They also load and run fine if I cut out the AS2 swf and access directly from my Flex code.  So I know there isn't a path issue.  More likely not accessing the right layer in the AS2 swf from Flex or something.  Or maybe security sandbox violation but I don't see anything reported in the FlashBuilder debug console.  When run console just reports:
    [SWF] SwfMobile.swf - 2,639,761 bytes after decompression
    [SWF] assets/swf/AS2.swf - 1,470 bytes after decompression
    Is there something inherently wrong with loading swf's that load other things?  Even if I have the AS2 swf load jpgs they don't load so the format of the target content at the end of the chain doesn't seem to be the issue.  Just the act of embedding a swf that loads other things seems to be the problem.

    Ah, yes. Using an AVM1 SWF could prove difficult...
    I'm going on about 3 hours of sleep at the moment, but let me toss out a few thoughts I have and hopefully something will stick...
    Ok, so my first thought what to try and cast the loaded content as a MovieClip and call methods on that, but the fact they are AVM1 throws that out the window.
    That leaves LocalConnection, as you mentioned. But this would require you to have code on the receiving end to handle the connection... no good either.
    But what if you created a "bridge" in AS2 that holds all the code for the receiving end of LocalConnection (or has the control logic itself, perhaps even eliminating the need for LocalConnection all together!). I think maybe this is what you were trying to do already by loading a SWF into a SWF? Well instead of loading your bridge at runtime, what if you statically linked it into your project as a class?
    *a few moments later*
    Well it looks like you can in fact link in a a symbol created for AVM1, but it will only come in as a SpriteAsset, and will not include any custom code (which makes sense, since they use entirely different class constructs).
    To do the test, I created a symbol exported for actionscript (AS2/Flash8), then linked it in with a CSS style embed. I then instantiated the class and called describeType on it.
    So in summery, it looks like calling custom code on the bridge is out (I did not test this extensively, that was just my first impression with this simple test). However, if you may be able to perform the actions you need by attempting to cast the loaded content into something AVM2 can recognize. Apparently it does this automatically when linked in statically, so maybe there is something there worth looking into... mainly, can you do what you need using only the base class and no custom code?
    Keep me posted!

  • Flash player 10.3.181.14 broke my site, loading multiple swfs into an array

    I load multiple swfs into an array, I add and remove the objects on the stage, this is for a rotating carousel.
    All the items locations are established in xml. If I only have one item loaded into the array it works fine, if I have more then one it will not a) play the swf, or b) show the swf.
    The swfs themselves contain code that fire events in the main container. Which cause other items to play or load.
    Is anyone else having this issue?

    Hi howet,
    EDIT:
    I've opened a flash bug in their bug system as I found I could reproduce the issue: https://bugs.adobe.com/jira/browse/FP-7071
    There are some workarounds I found on there.
    ORIGINAL MESSAGE:
    I was having a similar issue using a loading component which i've been using for several years with no issues. As with you the issue arose when loading multiple swfs (or even one swf and then a jpg) on 10.3 and above. It works fine on 10.2 and below still.
    I found a workaround whilst I look for a proper answer and that is to delay subsequent loads using a hacky setTimeout.
    For example:
    protected function manageLoaded (p_event : Event) : void {
    setTimeout(loadNext, 1);
    // following line breaks the gotoAndStop of loaded swfs.
    // loadNext();
    I hope this helps you too, let me know.
    Cheers,
    Dan.
    Message was edited by: Dan Wilkinson, 01/06/2011 11:37am BST (GMT + 1)

  • Loading an external SWF into movie?

    I am trying to laod an SWF into and empty movie clip using no
    human interaction. I.e the ovie laods once a certain point in the
    timeline is reached.
    Here is the code I have
    Can anyone help?

    i dont see how that code would work at all, to be honest...
    But, there are sooo many variations of a pre-loader, that it
    wouldnt surprise me if it did work.
    your formula is wrong. it should be...
    Math.round((loadedbytes/totalbytes) * 100)
    by your code i see that you are sending the playhead to the
    frame equal to the ammount loaded.
    In this case, you need the ammount loaded to be a WHOLE
    number, and not decimal numbers, as you can't say
    gotoAndPlay(5.22984749); for eg..
    ok this code should go on the first frame of the SWF you are
    loading into your main SWF.
    If its not there...it needs to be there.
    second: this pre-loader does what it's supposed to...but it
    doesnt specify the "who" part of the code.
    try thiese 2 alternatives..
    loadedbytes = this.getBytesLoaded();
    totalbytes = this.getBytesTotal();
    frame = int(loadedbytes/(totalbytes/100));
    if (frame > 100) {
    frame = 100;
    if (loadedbytes == totalbytes) {
    // this takes you to the next scene
    this.gotoAndPlay(5);
    OR
    this._lockroot = true;
    loadedbytes = _root.getBytesLoaded();
    totalbytes = _root.getBytesTotal();
    frame = int(loadedbytes/(totalbytes/100));
    if (frame > 100) {
    frame = 100;
    if (loadedbytes == totalbytes) {
    // this takes you to the next scene
    _root.gotoAndPlay(5);
    let me know how you go.

  • 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);

  • Loading random .swf's in html page

    Desired scenario: I have a site which I want random .swf
    files to load into index page each time a user refreshes or visits
    the site.
    Solution: I used a Javascript array solution in the .html
    page. Note: it works perfectly in Firefox and Safari.
    The javascript code for that is listed below.
    Problem: In IE, the page which is supposed to load the
    random .swfs in blank. I tried to solve the problem by using an IE
    conditional statement with a single .swf embedded (so at least
    visitor could have interactive experience).
    <!--[if IE]>
    <object
    classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="
    http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"
    width="800" height="600">
    <param name="movie" value="drinks.swf" />
    <param name="quality" value="high" />
    <embed src="drinks.swf" quality="high" pluginspage="
    http://www.macromedia.com/go/getflashplayer"
    type="application/x-shockwave-flash" width="800"
    height="600"></embed>
    </object>
    <script type="text/javascript"
    src="fixit.js"></script>
    <![endif]-->
    Any help would be appreciated. The link to the site in
    question is:
    http://www.jayminnickinteractive.com

    Thank you for checking. Yes right now they are all working.
    But many times I visit the flv's don't load - i wonder if it is a
    flash thing or more connected to my web host.
    Gary

  • Help loading external swf inside movie

    I am trying to load an external swf from inside a movie clip.
    I can get it to load but it takes me out of the current movie and
    into the external swf. How can i get it to load inside the
    specified mc in my movie?

    it definately tries to load the swf, but it goes back to the
    begining of my main movie. When I click on the button to go to the
    specified frame instance, instead of loading the swf it kicks back
    to the begining frame 1 of the main scene. I have this loading
    within another MC that is 4 layers deep.
    this is the code I have on the button:
    on(rollOver){
    b2.gotoAndPlay(2);
    on(rollOut, dragOut){
    b2.gotoAndPlay('go');
    on(release){
    _parent.gotoAndStop('ph2');
    The 'ph2' is the frame instance that I would like the
    'water1' mc to load in.
    I've tried a bunch of things and it either loads just the swf
    without my main movie, or it just loads blank within water1.
    Thanks again

  • Problem loading one SWF into another in Flash AS3

    I am trying to load an SWF file in another SWF file. The child SWF file works fine when run standalone like if I set visibility of an item to true or false, it works fine. But when the SWF is loaded into a parent SWF, I am not able to execute such commands, neither I get any errors...

    are both swfs as3 swfs?
    is the code in the loaded swf and is that code referencing objects in the loaded swf?

  • Load external swf into a specific _level

    Hi there,
    I am loading an external swf into the mc 'image' using:
    image.loadMovieNum("portfolio/100_design/1.swf", 1);
    Every time a new image loads, I want it to load the level above, ie:
    image.loadMovieNum("portfolio/100_design/1.swf", 2);
    Is there a way this can be done dynamically. For example, "current level + 1"
    Many thanks

    is the first frame of your loaded swf's empty?  if yes, then no problem using _levels.
    if not, do you mind a momentary flash when your next swf loads and before its _alpha is assigned 0 and then faded-in?  if you don't mind, then no problem using _levels.
    if you do mind that momentary flash, then using _levels will be more complex than using empty target movieclips.  is there some good reason to use _levels instead of target movieclips?

  • Error 2044 when loading external swf into my site

    Ok what i have is a site made from 1 flash file where i am loading external swf files for my picture galleries. now what is happening is in Flash, dreamweaver and when i test the site, everything is working perfectly, the problem is coming when i go into internet explorer go to the site and click on the flash button to go to the picture gallery, that is when it is giving me a Error #2044: Unhandled IOErrorEvent:. text=Error #2036: Load Never Completed.
    does anyone know why this is happening and a possible way to fix it? thanks

    See if the following link helps at all...
    http://www.gotoandlearnforum.com/viewtopic.php?f=29&t=20453

  • Loading external swf into Fla. not working

    I have created a Flash page that loads an external swf into
    it when you click a button. The swf loads but the actionscript
    assigned to the swf which scrolls images across does not work. When
    i open the swf in a browser window with the direct link to it the
    scroll works but inside the fla file the swf loads but the scroll
    buttons are not working at all. Would this be something in the
    actionscripting in the swf or fla file. Any advice would be greatly
    appreciated, thank you.

    var imageRequest:URLRequest = new URLRequest("my_gallery.swf");
    var imageLoader:Loader = new Loader();
    imageLoader.load(imageRequest);
    addChild(imageLoader);
    is as3 code.  that won't work in your as2 project.
    here's the equivalent in as2:
    this.createEmptyMovieClip("targetMC",this.getNextHighestDepth());
    targetMC.loadMovie("my_gallery.swf");

  • Problems loading Flex3 swf into AIR app

    This is a challenging problem that I have reduced down to the
    bare minimum and it is still reproduceable. I have built a minimal
    AIR application and added a SWFLoader to it which loads a SWF file
    named "Junk.swf" using an absolute path.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:WindowedApplication xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" title="Hello World">
    <mx:Style>
    WindowedApplication {
    background-color:"0x999999";
    background-alpha:"0.5";
    </mx:Style>
    <mx:SWFLoader
    source="C:/myProjectFolder/renderers/Junk.swf" width="100%"
    height="100%" />
    </mx:WindowedApplication>
    This works fine if I run the application from within Flex3,
    however when I build an installer, install the application to my
    windows vista system and execute it from the desktop the Junk.swf
    will not display. If I replace the Junk.swf with another SWF of the
    same name created in Flash CS3 then it will display properly when
    my test app is executed from either Flex or the desktop.
    The contents of the loaded SWF don't appear to be an issue
    since even the simplest of Flex3 SWFs fail to display.
    Interestingly when I add listeners to the SWFLoader to
    determine if any errors are happening no error events are sent, but
    I do receive both the INIT and COMPLETE events which tells me that
    the Junk.swf is found and loaded, just not displayed.
    Any assistance or even ideas that I could try would be
    appreciated.

    that's why i added those comments about the swf's domain.  for locally loaded swfs, use:
    SFMltd wrote:
    Hi Kglad, Thanks for the Example.
    if i run my class with securityDomain = SecurityDomain.currentDomain; then it throws this error: SecurityError: Error #2142: Security sandbox violation: local SWF files cannot use the LoaderContext.securityDomain property.
    The swf file im trying to load is stored locally so i guess this error makes sense. However if i comment out that line i get the same "cannot access Stage owned by app" error?
    See below for class:
    package  {
      import flash.display.MovieClip;
      import flash.filesystem.File;
      import flash.events.Event;
      import flash.net.FileReference;
      import flash.events.MouseEvent;
      import flash.display.Loader;
      import flash.net.URLRequest;
      import flash.system.LoaderContext;
      import flash.system.ApplicationDomain;
      import flash.system.SecurityDomain;
      public class assetPreview extends MovieClip {
      private var loader:Loader;
      private var mainSWF:MovieClip = new MovieClip();
      public function assetPreview() {
      addEventListener(Event.ADDED_TO_STAGE, initialise);
      public function initialise(e:Event):void
      removeEventListener(Event.ADDED_TO_STAGE, initialise);
      var allowSWF:LoaderContext = new LoaderContext(false,ApplicationDomain.currentDomain);
    // allowSWF.securityDomain = SecurityDomain.currentDomain;
      loader = new Loader();
      loader.load( new URLRequest(settingsXML.pathToSWF),allowSWF);
      loader.contentLoaderInfo.addEventListener(Event.COMPLETE, viewPreview);
      public function viewPreview(e:Event):void
      addChild(mainSWF);
      mainSWF.addChild(loader);

Maybe you are looking for

  • How do I use imac or mac mini as media server for Beoplay A*?

    We are contemplating buying a Beoplay A* and and appropraite Mac configuration to support it. I'd like to load all our musc into Itunes from CD's, as well as stream from things like Pandora. I'm having trouble fnding any helpful documentation. How do

  • In NEED of a new battery, but I do need help.

    I have the old macbook Pro, 15-inch, the all silver one, not the one with the black keys/border. Anyways, I know I need a new battery because when I take it off the charger, it dies within 30+ seconds. I was just wondering which battery I should get.

  • Template detach error

    Hi made pages with a template and want to detach them, but i'm getting the following error: Internal error (WWC-00006) An unexpected error has occurred (WWS-32100) An unexpected error has occurred (WWS-32100) ORA-6502: ORA-06502: PL/SQL: numeric or v

  • Isight cam and yahoomessenger 2.5.3

    Yikes! My friend has a pc and I can view her cam on yahoo messenger when she invites me but when I invite her to view my cam it says "My cam isn't avaiable" (something like that!) I tried to upgrade my yahoo to 3.O and it wouldnt let me sign in. Do I

  • Oracle support contact

    Hi All, We have some problems with queries in Oracle 9.2.0.7 I would like to open a service request with Oracle support for 9.2.0.7 specific performance issue on a solaris environment. Please let me know the procedure.