Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Aug 2007
    Posts
    36
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Randomising my banners to show up a different one

    Firstly sorry if the title is a bit confusing
    Secondly thanks for reading this post
    Now,
    I am doing my GCSE work for website design,
    I want to have a web banner that will show 1 of 3 animations i have created,
    I am very new at Flash a my teacher doesn't know how to fully use it,
    So i was wondering
    Does anyone know a way i can randomise my banner?




    Detailed
    Its for a website called "Healthy Kids"
    I have created the 3 banners on differenet flash docs but dont mind redoing them.

    Is this possible in Flash or would it be easier to use some sort of code on the actual website?



    Thank you,

  • #2
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    First, http://www.gotoandlearn.com is a great resource for learning actionscript.

    As far as the banner you could simply load them into a container movieclip. View the carousel tutorial on the site listed above for specific help on that.

    To randomly rotate threw the banners you can use the Math.random() like this.

    Code:
    var min:Number = 1;
    var max:Number = 3;
    
    var randomNum:Number = Math.floor(Math.random() * (max -  min)) + min;
    
    
    //just use a SELECT/SWITCH statement to pick which banner to load based on the random number selected
    Sorry, I couldn't remember which construct is used in actionscript. I haven't coded all day I've been busy designing a few web templates. But I believe its the Switch statement in AS.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #3
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    I would say that its better to use a PHP script to serve up the random flash file. That way you can add banners to the site that are or are not flash based, and unless they NEED to be flash based they should be images. It would be a more scalable solution.

    PS: Rules state that we are not to help with homework directly. We can help in general terms, but we want you to learn so we need to avoid giving you direct answers. Check out that site, as well as this post. Make sure your questions avoid violating ethical rules as stated below. Good luck.

    1.5) No homework assignments - Do not post your entire homework assignment and request that other members do it for you. This is considered cheating, and your thread may even be used by your school to prove your guilt. Now, you may ask for advice or help on a specific aspect of your assignment that you're having trouble with. Use common sense as far as what's acceptable in terms of soliciting help with homework assignments.
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #4
    New Coder
    Join Date
    Aug 2007
    Posts
    36
    Thanks
    2
    Thanked 0 Times in 0 Posts
    This isn't a homework task.
    The task is to design a website.
    It is my own personal choice to use a randomising web banner

  • #5
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    My apologies, I wasn't sure what you meant when you said 'teacher', and I thought it was a class project.
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.


  •  

    Posting Permissions

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