Flash As3 help Imageloader

Out of context: Reply #2

  • Started
  • Last post
  • 12 Responses
  • PonyBoy0

    if you're only loading 4 images - load all 4 at the same time and just set the movieclip holding each image to:
    myImage. visible = false;
    myImage. alpha = 0;

    when you click each button - call a function that changes the alpha / visibility for each image so only the image you want is showing

    button1. addEventListener (MouseEvent.MOUSE_DOWN, button1Function);

    function button1Function () {
    image1. alpha =1;
    image1. visible = true;
    image2. alpha =0;
    image2. visible = false;
    image3. alpha =0;
    image3. visible = false;
    image4. alpha =0;
    image4. visible = false;
    }

    this is redundant when you do it for four buttons - ideally you'd like to run one function and pass a parameter to that function telling the function what button you pressed in turn running a switch statement or a 'for' loop to adjust the mc alpha / visibility - but as you're new to AS3... ... just be redundant and be done with it if you're short on time. :)

    also - I advise not using the timeline for this (no 'gotoAndStop' stuff... just call a function based on which button you press that sets the alpha / visibility for the images)... ... if you want the images to fade-up / down - take a moment and check www.greensock.com - download and utilize either tweenMax or tweenLight... both are tweening engines that allow you to fade up / down based on time.

    • using 'visible' is important as the flash player won't redraw / consider that MC visible - if you just use 'alpha'... the image is...PonyBoy
    • still considered by the player and is 'redrawn'... using more processor / resourcesPonyBoy
    • lots to swallow - I know... :)
      AS3 requires some study / understanding regardless of what you're doing. Good Luck! :)
      PonyBoy

View thread