A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: [MX04] Load external images, fade in on completion.

  1. #1
    A Flurry of Activity
    Join Date
    Aug 2005
    Posts
    103

    [MX04] Load external images, fade in on completion.

    Code:
    loadee = new MovieClipLoader();
    ImageHolder._visible = false;
    loadee.load(bgfilename, ImageHolder);
    templistener = new Object();
    templistener.onLoadComplete = function() {
    	ImageHolder._alpha = 0;
    	ImageHolder._visible = true;
    };
    loadee.addListener(templistener);
    And back at the ImageHolder movie clip (a movie clip on stage at the lowest level filled with a shape of transparent fill color)

    Code:
    onClipEvent (enterFrame) {
    	if (ImageHolder._alpha < 100 && ImageHolder._visible == true) {
    		ImageHolder._alpha += 10;
    	} else {
    		ImageHolder._alpha = 100;
    	}
    }
    And.. no image is shown... Probably a simple syntax error, but I'm not seeing it, and flash says its ok.
    maximum width 300 no more maximum hieght 40 no more not interchangable

  2. #2
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    fix that footer and we'll talk.

  3. #3
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    taifunbrowser,

    Like jAQUAN said, you need to fix that footer of yours immediately, please.
    Here you have the rules you have to follow.
    Thanks.

  4. #4
    A Flurry of Activity
    Join Date
    Aug 2005
    Posts
    103
    Quote Originally Posted by jAQUAN
    fix that footer and we'll talk.
    is that a deal? k.

    Quote Originally Posted by THisSite
    Maximum File Size: 15kb
    *hrecK**cough**giggle*HAH

    15kb = no images allowed? got it.

    *sighs* its true though, this site has SWAMPED servers. I wont help. *removes sig*.

    And now, I assume yall saw it, in the way you replied?
    maximum width 300 no more maximum hieght 40 no more not interchangable

  5. #5
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    Reading doesn't seem to be working out so well. Let's try this visually. How about we get that footer down to these specs:


  6. #6
    A Flurry of Activity
    Join Date
    Aug 2005
    Posts
    103

    asdf

    *sigh*... Well, I'm not here to advertise me or my site, can we Please get my flash working?

    I'm sure all 3 of you now have seen the syntax error in my above code, and this account has been signature -less for the 1.5 years I've had this account.

    Sewww.... back to help?:
    maximum width 300 no more maximum hieght 40 no more not interchangable

  7. #7
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    When requesting help from others there is little need for sarcasm. There is something to be said for the phrase "I'm sorry".

  8. #8
    A Flurry of Activity
    Join Date
    Aug 2005
    Posts
    103
    *looks for sarcasm in above post.*

    I'm Sorry

    Syntactical Error Please?
    maximum width 300 no more maximum hieght 40 no more not interchangable

  9. #9
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    You should attach all the code to the timeline. Avoid attaching code to movie clips or buttons.

    Here's a simple example of what you want to do:
    code:

    this.createEmptyMovieClip("image_mc", this.getNextHighestDepth()); // create the holder
    var mclListener:Object = new Object(); // create the listener
    mclListener.onLoadStart = function(target_mc:MovieClip) { // when the image starts loading
    target_mc._alpha = 0; // hide it
    };
    mclListener.onLoadInit = function(target_mc:MovieClip) { // when the image finishes loading
    fadeIn (target_mc); // show it progressivly
    };
    var image_mcl:MovieClipLoader = new MovieClipLoader(); // create the MovieClipLoader Object
    image_mcl.addListener(mclListener); // add the listener
    image_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", image_mc);
    // function to fade in the movie clip, from 0 to 100
    function fadeIn(mc:MovieClip):Void
    {
    mc.onEnterFrame = function()
    {
    this._alpha = Math.min(this._alpha + 5, 100);
    if (this._alpha == 100)
    {
    delete this.onEnterFrame;
    }
    }
    }


    Just attach it to the main timeline.

  10. #10
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    Quote Originally Posted by taifunbrowser
    *sigh*... Well, I'm not here to advertise me or my site,
    BINGO!

    now,
    With mcl's and listener assignments:
    - the listener object must exist before it can be assigned
    - the mcl must exist before you can assign it a listener
    - the listener functions must be written before it's assigned
    - the loadClip() method must be called after everything else.

    Also, the MovieClipLoader has two optional methods for reacting to a finished load. onLoadComplete fires as soon as the data is all there. onLoadInit however fires as soon the new data has been drawn to the screen one time. I've found that in most cases, onLoadInit is preferrable.

    replace your first chunk with this:
    Code:
    ImageHolder._visible = false;
    templistener = new Object();
    templistener.onLoadInit = function() {
    	ImageHolder._alpha = 0;
    	ImageHolder._visible = true;
    };
    loadee = new MovieClipLoader();
    loadee.addListener(templistener);
    loadee.loadClip(bgfilename, ImageHolder); //<-- use loadClip(), not load()
    Last edited by jAQUAN; 12-01-2006 at 04:13 PM.

  11. #11
    A Flurry of Activity
    Join Date
    Aug 2005
    Posts
    103

    aasdf

    jaques, no matter how many times I applied your changes, the image just wouldnt load with those commands.

    Either way, the guy with the bull as an avatar's code works (for the reader's use), rather beautifully. very graceful fade in.
    maximum width 300 no more maximum hieght 40 no more not interchangable

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