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:
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
And how I call the function from one of the buttons
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 – (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:
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:
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?
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!!!