# An essential concept eludes me: \_alpha +=5 loop, loadClip (orMovie?)

**URL:** https://forum.kirupa.com/t/an-essential-concept-eludes-me--alpha-5-loop-loadclip-ormovie/232099
**Category:** flash
**Created:** [July 11, 2007, 8:38am UTC](https://forum.kirupa.com/t/an-essential-concept-eludes-me--alpha-5-loop-loadclip-ormovie/232099 "2007-07-11T08:38:54Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![auntialias](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/auntialias/32/3793_2.png) [@auntialias](https://forum.kirupa.com/u/auntialias)
#### Post date: [July 11, 2007, 8:38am UTC](https://forum.kirupa.com/t/an-essential-concept-eludes-me--alpha-5-loop-loadclip-ormovie/232099/1 "2007-07-11T08:38:54Z")

</div>

Flash 8, AS 2. I’m a quasi-noob. I know that once I understand what’s going on, I’ll thwack my own forehead in one of those, “Duh! Obvious!” responses. But I’m not there yet. Sorry for the length of this post, but I want to make sure I cover all the pertinent parts.

**My fla file has these elements** on stage, w/ instance names in bold:[LIST]  
[_]an empty movieclip (masked): **loader\_mc**  
[_]a bunch of buttons: **client1\_btn** , **client2\_btn** , etc.  
[_]a dynamic text field. Well, two, actually: **ClientName\_txt** , **projInfo\_txt** [/LIST]\*\*  
What I want the fla to do (in plain English):\*\*  
when a button is clicked…[LIST]  
[_]_[done]_ playhead goes to unique labeled part of timeline (button appearance changes slightly)  
[_]_[done]\* text from external text file gets loaded into each of dynamic text fields  
[_]_[done]\* a particular image gets loaded into empty movie clip  
[\*]**[where I’m stuck]** that particular image fades in by looping through alpha adjustments[/LIST]I feel as tho I almost have it, but looping isn’t happening.

**Code that works, so far**  
Here’s function that’ll be called by button onRelease:

```auto
function showandTell(imagePath:String, thenumber:Number) {
    //Fix letterspacing bug for dynamic text. I had to call this inside function
    //thanks to Bob Walton for this fix. See link below code snippet for fix
    //sorry this is here twice, almost identical. 
    //Did I mention I am a noob? Well yeah, and here's proof. 
    var fmt:TextFormat = ClientName_txt.getTextFormat();
    ClientName_txt.setTextFormat(fmt);
    ClientName_txt.setNewTextFormat(fmt);
    var frmt:TextFormat = projInfo_txt.getTextFormat();
    projInfo_txt.setTextFormat(frmt);
    projInfo_txt.setNewTextFormat(frmt);
    //put the right text in the text box from caption file
    ClientName_txt.text = eval("myCaptions.clientname"+thenumber);
    projInfo_txt.text = eval("myCaptions.projectinfo"+thenumber);
    //this replays an animating movieclip each time button is pressed
    imageheaderBg_mc.gotoAndPlay(1);
    //-------OHAI, START LOOKING AT MY CODE. 
    //-------THIS IS WHERE I'M STUCK WITH GETTING THE FADE TO HAPPEN
    //-------KTHXBYE
    loader_mc.loadMovie("packaging/"+imagePath);
}

```

[Link to Bob Walton’s text formatting hack](http://bobspace.wordpress.com/2006/09/28/flash-yourmomgettextformat-is-the-key-to-letterspacing/)

And how I call the function from one of the buttons

```auto
client1_btn.onRelease = function() {
    gotoAndStop("one");
    showandTell("image1.jpg", 1);

```

Code as shown works to do all the things I marked [done] in bulleted list above. So now I’m trying to add an alpha fade without breaking everything else.

**In which I fiddle around, trying to make the fade to work. A series of examples and attempts**

I’m trying to adapt Example 7 (scroll way down) in [Senocular’s tutorial on preloading](http://www.senocular.com/flash/tutorials/preloading/) – (it preloads images, swaps depths and fades from one to the other). Since this is happening for a single movieclip (and because I couldn’t get the swap depth for two versions to work), I’m trying to do the simplest alpha fade on the one image loaded into the movieclip.

A function from Senocular’s Example 7 that looks promising:

```auto
function fadeIn(){
    if (this._alpha < 100){
        this._alpha += 5;
    }else{
        delete this.onEnterFrame;
    }
}

```

I’ve tried replacing or adding to the code below the OHAI…KTHXBYE comments, at the end of the showandTell function, above:

```auto
      loader_mc._alpha = 0;
      if (loader_mc._alpha < 100){
        loader_mc._alpha += 20;
    }

```

But this does not loop.

Must I preload the clip before I start in on changing the alpha?

```auto
      my_mcl.loadClip("packaging/"+imagePath , "loader_mc");

```

I’ve taken random stabs at including the sample fadeIn function, but don’t know how to call it inside of my showandTell function.

I guess I really don’t understand onEnterFrame. Can one have _gotoAndStop(“someLabel”)_  
where the playback head enters the “someLabel” frame while simultaneously invoking onEnterFrame? Does the playback head, staying in “someLabel” then continue to re-enter that frame where loops such as this might work?

\*\*Please help me over this last hurdle. \*\*What code should I use in my showandTell function (or outside it), and what is the Flash Actionscript concept that I don’t yet understand?

Many many thanks!!!
