A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Need help with random loading movies

  1. #1
    Senior Member gkbdave's Avatar
    Join Date
    Nov 2000
    Location
    Fort Bragg, NC
    Posts
    304

    Need help with random loading movies

    I am working on loading swfs dynamically but want them to load randomly everytime user visits site and also aut scale to the content being loaded into the main timeline..

    What is the easiest way to do this? I am not very good at actionscripting..

    Thanks

  2. #2
    ReMember gobbles's Avatar
    Join Date
    Nov 2002
    Location
    Denmark
    Posts
    983
    Hi
    I dont know if you load them into other MC's or just in level 1..

    If you name your swf 0 1 2 3 4 ans so on its pretty easy..

    make an empty mc, place it where you want the movie to load, pu tthis action on the clip..

    onClipEvent(load){
    movie_num=random(5)
    loadMovie(movie_num+".swf",this)}

    this will first define a random number between 0 and 5, next it loads the movie with that number.. "glueing" .swf at the end of it and loading it into the position of the movie cip.. this will only be done once, due to the onClipEvent(load) this action is only runned when the MC loads the first time...
    if your movie has other names you have to make an array containing the names..

    like
    my_array=new Array("movie.swf","othermovie.swf")

    and so on..

    then on the clipevent use this instead

    movie_num = random(5)
    loadMovie(my_array[movie_num],this)

    have fun
    http://www.rickigregersen.com ...finally a blog!

    Your damned if you do...but your particually damned if you don´t

  3. #3
    Senior Member gkbdave's Avatar
    Join Date
    Nov 2000
    Location
    Fort Bragg, NC
    Posts
    304
    Thanks for the reply..

    Ok what about auto sizing the swf(or pic)? I have vertical and horizontal pictures actually and want them to autosize in the movie clip that they load into..

    how is this done?

  4. #4
    Senior Member gkbdave's Avatar
    Join Date
    Nov 2000
    Location
    Fort Bragg, NC
    Posts
    304
    I thought I had this working but its not... it doesn't do anything..
    I have named my swf as 0,1,2,3,4.swf

    but its just blank here is my code:
    onClipEvent(load){
    movie_num=random(4)
    loadMovie(movie_num+".swf",this)}

    I have put this on the empty movie clip is this correct??

    thanks for the help

  5. #5
    ReMember gobbles's Avatar
    Join Date
    Nov 2002
    Location
    Denmark
    Posts
    983
    Hmm I tried it to.. but cant get it to work with the onClipEvent either..

    put if you go inside your empty clip and place this on your first frame..

    Code:
    movie_num = random(2);
    movie_num = random(2);
    loadMovie(movie_num+".swf", _root.loader_clip);
    _root.loader_clip._height = 20;
    _root.loader_clip._height = 20;

    the _root.loader_clip is the instance name of the clip you load into, the _height is to scale it how you want.. you can allso use _xscale and _yscale

    sorry I didn't test the code in advance.. nut I was so sure.. I still am... strange should do the same... well enough about me being an idiot this work I tested it...
    http://www.rickigregersen.com ...finally a blog!

    Your damned if you do...but your particually damned if you don´t

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center