A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: random header in flash 8?

  1. #1
    Junior Member
    Join Date
    Mar 2006

    random header in flash 8?

    Hi there,
    doe's anyone know how to do a random maths function in flash 8. I have a project which works real well in flash5, and am currently cleaning up some old work and having opened the old project in my newer version of flash, it won't work?

    footers = 4;
    directory = "http://www.billfreeth.com/footer";
    loadMovie(directory add Math.ceil()Math.random)*footers) add ".swf", _level10};

    thats the code and as i export it it says it comes up with errors saying that it was expecting "," or ")" i just can't suss it out at all? Anyone got any ideas? its driving me barmy!
    If anyone knows i will be truly thankfull

  2. #2
    Not Real since 1985
    Join Date
    Feb 2002
    I think it may be because 'add' is deprecated.
    Never accept the first 'impossible' unless it comes from a lady.

  3. #3
    Grandmaster Flash
    Join Date
    Apr 2004
    Edinburgh, Scotland
    Yes, Louis is correct. Also the you need to use Math.random() with the brackets or you will get something like [type Function] going into your string. There were also a couple of issues with your types or brackets.

    Try this:

    var footers:Number = 4;
    var directory:String = "http://www.billfreeth.com/footer";
    var filename:String = Math.ceil(Math.random() * footers).toString();
    loadMovie(directory+filename+".swf", _level10);
    You can remove the trace action if you want, it's just there to confirm you are getting the right results from the calc.

    If it ain't broke, don't fix it.

  4. #4
    Junior Member
    Join Date
    Mar 2006

    random header

    Hi there,
    Thanks for the response, i Appreciate it. The new code certainly has cured the errors i was getting, however it still won't bring up my header? Ive tried lots of different variations, but nothing seems to work?Ive exported as version 8, script version 2, Ive made sure all my filesare the newer versions. I did a dummy run and made a piece of text appear in place of the file with the script you gave me. so the problem seems to be with the code in some way. Unless the address i am quoting shouldnt start with http? just www ? Im clutching at straws now!
    If anyone has any ideas Id appreciate it

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