The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 7 of 7

Thread: Flash CS3 AS3 UILoader fade in question

  1. #1
    14
    posts
    Registered User

    Flash CS3 AS3 UILoader fade in question

    Hey Guys,
    I REALLY need some help. I'm quite new to AS3 and am trying to write a script that will change the alpha of my UILoader instance (instance name: newsBG_mc) from 0 to 1 (100) once it has loaded in fully. My code doesn't work and I was wondering if anyone can take a look and give me some advice. Thanks for reading...

    _________

    newsBG_mc.scaleContent = true;

    newsBG_mc.addEventListener(Event.COMPLETE, completeHandler);

    function completeHandler(event:Event):void {

    newsBG_mc.alpha = newsBG_mc.alpha +0.05;

    if (newsBG_mc.alpha >= 1) {
    newsBG_mc.alpha = 1;
    newsBG_mc.removeEventListener(Event.COMPLETE, completeHandler);
    }

    }

  2. #2
    Just ask if you want me to explain the code better:
    Code:
    newsBG_mc.scaleContent = true;
    
    //This event is dispatched ONCE and only ONCE when the newsBG is done loading
    newsBG_mc.addEventListener(Event.COMPLETE, completeHandler);
    
    function completeHandler(event:Event):void 
    {
       //Removing the old listener might be a good idea
       newsBG_mc.removeEventListener(Event.COMPLETE, completeHandler);
       
       //Now it is done loading, so listen for ENTER_FRAME events until the alpha has become 1
       newsBG_mc.alpha = 0;
       this.addEventListener(Event.ENTER_FRAME, fadeIn);
    }
    
    function fadeIn(event:Event):void
    {
       newsBG_mc.alpha = newsBG_mc.alpha +0.05;
    
       if (newsBG_mc.alpha >= 1) {
          newsBG_mc.alpha = 1;
          this.removeEventListener(Event.ENTER_FRAME, fadeIn);
       }
    
    }
    Blog article of the month: Why My One Line 'if' Statements Are Unusual
    Twitter: @IQAndreas
    GitHub: IQAndreas

  3. #3
    You might also want to look into Tweening. A tween engine asks you to pass in an object, how long time you want it to run, and finally, which properties to tween and what you want the final value to be.

    One tween engine I really like using is "TweenLite". The library is free and can be found and downloaded here:
    http://blog.greensock.com/tweenliteas3/
    (I should get some sortof comission for how many beginners I have sent towards TweenLite.

    Do you need some help applying TweenLite to actual code, or do you think you got it? Google has plenty of help, but I am here for you as well.
    Blog article of the month: Why My One Line 'if' Statements Are Unusual
    Twitter: @IQAndreas
    GitHub: IQAndreas

  4. #4
    14
    posts
    Registered User
    Oh Man, thank you so much!!! Yes the frame event listener. Two days I haven't slept trying to figure this out. I love trying to learn things myself but this got the best of me as I've only started learning AS3 last week (big jump from AS2). So Tweening is a Transition class right? Let me experiment and learn and I'll post any questions I have regarding TweenLite. Thank you soooooooo much for your help.

  5. #5
    I'm glad it worked.

    If you want to get really good at AS3, Adobe released a free online book, "Programming ActionScript 3.0" which takes you through everything you need to know to get from 0 knowledge to intermediate, whizzing right through the beginner stage.
    http://help.adobe.com/en_US/ActionSc...rogrammingAS3/

    And if you have any questions along the way, we are always here for you, even though you may not always get a reply immediately. We have lives too (or so they say)
    Blog article of the month: Why My One Line 'if' Statements Are Unusual
    Twitter: @IQAndreas
    GitHub: IQAndreas

  6. #6
    14
    posts
    Registered User
    I'm reading "Programming ActionScript 3.0" right now. It's going to be perfect! Thanks for all your help. It's been invaluable and greatly appreciated!!

  7. #7
    @IqAndreas

    You saved another life here, I've smashing my head around this for few days now, but here we go, it works like a charm, but I need you to help me/us further with this a bit.

    I have 4 thumbnails in the stage, each time you click on one, it opens the larger image in the same UILoader - I just change the source in the code.

    However when the large image open, I have a next and previous button that appear, through those buttons then, I set a conditional statement to navigate through the other larger images,

    inside the click function of the next button there is:

    if (UILoader_instance.source == "image1.jpg")
    {
    UILoader_instance.source =="image2.jpg";
    }else{
    if ...
    }

    and so on.

    Now what I want to achieve, is that when Next is clicked, it fades out the actual larger image then it loads the next image with a fade in.

    Are you able to help with this please.

    If this is not clear enough let me know and I'll post the code I've got.

    Thanks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012