Whats wrong with my code?

Hey
ActionScript Code:
[LEFT][COLOR=#0000FF]import[/COLOR] mx.[COLOR=#000080]transitions[/COLOR].[COLOR=#000080]Tween[/COLOR];
[COLOR=#0000FF]import[/COLOR] mx.[COLOR=#000080]transitions[/COLOR].[COLOR=#000080]easing[/COLOR];
[COLOR=#000000]var[/COLOR] popLoad:Tween = [COLOR=#000000]new[/COLOR] Tween[COLOR=#000000]([/COLOR]popupMC.[COLOR=#000080]bgMC[/COLOR], [COLOR=#FF0000]"_alpha"[/COLOR], Elastic.[COLOR=#000080]easeIn[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]80[/COLOR], [COLOR=#000080]40[/COLOR], [COLOR=#000000]false[/COLOR][COLOR=#000000])[/COLOR];

popupMC.[COLOR=#0000FF]pop[/COLOR].[COLOR=#0000FF]_visible[/COLOR] = [COLOR=#000000]false[/COLOR];
[COLOR=#808080]**[/COLOR]

showPopUp = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]if[/COLOR] [COLOR=#000000]([/COLOR]popupMC.[COLOR=#000080]bgMC[/COLOR].[COLOR=#0000FF]_alpha[/COLOR] >= [COLOR=#000080]78[/COLOR][COLOR=#000000])[/COLOR]
popupMC.[COLOR=#0000FF]pop[/COLOR].[COLOR=#0000FF]_visible[/COLOR] = [COLOR=#000000]true[/COLOR];

[COLOR=#000000]}[/COLOR]
[COLOR=#0000FF]onEnterFrame[/COLOR] = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
showPopUpCOLOR=#000000[/COLOR];
[COLOR=#0000FF]trace[/COLOR][COLOR=#000000]([/COLOR]popupMC.[COLOR=#000080]bgMC[/COLOR].[COLOR=#0000FF]_alpha[/COLOR] [COLOR=#000000])[/COLOR]

[COLOR=#000000]}[/COLOR]

hidePopup = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]if[/COLOR] [COLOR=#000000]([/COLOR]popupMC.[COLOR=#000080]bgMC[/COLOR].[COLOR=#0000FF]_alpha[/COLOR] <= [COLOR=#000080]78[/COLOR][COLOR=#000000])[/COLOR]
popupMC.[COLOR=#0000FF]pop[/COLOR].[COLOR=#0000FF]_visible[/COLOR] = [COLOR=#000000]false[/COLOR];
[COLOR=#000000]}[/COLOR]

popupMC.[COLOR=#0000FF]pop[/COLOR].[COLOR=#0000FF]close[/COLOR].[COLOR=#0000FF]onRelease[/COLOR] = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#808080]//trace(popupMC.bgMC._alpha )[/COLOR]
[COLOR=#808080]//unloadMovie(popupMC)[/COLOR]
hidePopupCOLOR=#000000[/COLOR];
[COLOR=#000000]var[/COLOR] popUnload:Tween = [COLOR=#000000]new[/COLOR] Tween[COLOR=#000000]([/COLOR]popupMC.[COLOR=#000080]bgMC[/COLOR], [COLOR=#FF0000]"_alpha"[/COLOR], Elastic.[COLOR=#000080]easeOut[/COLOR], [COLOR=#000080]80[/COLOR], [COLOR=#000080]0[/COLOR], [COLOR=#000080]40[/COLOR], [COLOR=#000000]false[/COLOR][COLOR=#000000])[/COLOR];

[COLOR=#000000]}[/COLOR]
[/LEFT]

What I’m trying to do is when the fla loads the background’s alpha will go from 0 to 80, then the “pop” will appear >80. How come when I trace the alpha stays at 79.6875?

Also,
When I try to hide popup, it doesn’t work.

If someone can look at my code and tell me whats wrong with it, it will be a great help.

thanks vxd

looks like you are using a Flash function reserved name for an MC name, that usually mucks up code

ActionScript Code:
[LEFT][COLOR=#0000ff]

import mx.transitions.Tween; 
import mx.transitions.easing;
var popLoad:Tween = new Tween(popupMC.bgMC, "_alpha", Elastic.easeIn, 0, 80, 40, false); 

popupMC.popbox._visible = false;

//hidePopup

showPopUp = function() {
    if (popupMC.bgMC._alpha >= 78) {
            popupMC.popbox._visible = true;    
    }
    
        
}
onEnterFrame = function() {
    showPopUp();
    trace(popupMC.bgMC._alpha )

}

hidePopup = function() {
    if (popupMC.bgMC._alpha <= 78) {
            popupMC.popbox._visible = false;
    }
}

popupMC.popbox.close_btn.onRelease = function() {
    //trace(popupMC.bgMC._alpha )
    //unloadMovie(popupMC)
    hidePopup();
    var popUnload:Tween = new Tween(popupMC.bgMC, "_alpha", Elastic.easeOut, 80, 0, 40, false);
    

    
}

[/COLOR]
[/LEFT]

ok I’ve changed them. Still not working. When I click on the “x” twice thats when it actually closes the popup box

if (popupMC.bgMC._alpha <= 78) seems iffy, I assume thats what enables the double click?

I think you should use tween.onFinish() {hidePopup()}

then add a real double click control…which isn’t easy …if you wish

got it working, heres what I did.

 
import mx.transitions.Tween;
import mx.transitions.easing;
var popLoad:Tween = new Tween(popupMC.bgMC, "_alpha", Elastic.easeIn, 0, 80, 40, false);

popupMC.popbox._visible = false;


onEnterFrame = function () {
	if (popupMC.bgMC._alpha>=78) {
		popupMC.popbox._visible = true;
		}else if (popupMC.bgMC._alpha<=78) {
		popupMC.popbox._visible = false;
	}
	
	//trace(popupMC.bgMC._alpha);
};

popupMC.popbox.close_btn.onRelease = function() {
	//trace(popupMC.bgMC._alpha )
	//unloadMovie(popupMC)
	var popUnload:Tween = new Tween(popupMC.bgMC, "_alpha", Elastic.easeOut, 80, 0, 40, false);
};

thanks randomagain for your help but I didn’t know where to put tween.onFinish() {hidePopup()} and gave me a syntax error.

well thats because I made it up :P… there is an onFinish thingy though (SP)

ah makes sense, may want to stick it on setInterval rather than a onEnterFrame, as “oEF” takes more processing power

can you give me an example of how setInterval would look like.
Googleling it now, seem confusing.

its the same but you specify in miliseconds or the like how often you want it to check

ie onenterframe can fire 100s of times needlessly

countDown = function(message){
[COLOR=#0000ff]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
popupMC.[COLOR=#000080]popbox[/COLOR].[COLOR=#0000ff]_visible[/COLOR] = [COLOR=#000000]true[/COLOR];
[COLOR=#000000]}[/COLOR][COLOR=#0000ff]else[/COLOR] [COLOR=#0000ff]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
popupMC.[COLOR=#000080]popbox[/COLOR].[COLOR=#0000ff]_visible[/COLOR] = [COLOR=#000000]false[/COLOR];
[COLOR=#000000]}[/COLOR]

}
}
timer = setInterval(countDown, 1000);

Thank “again” Randomagain.
I just need to use it a few more times so I know whats going on.

just a quick question: How do I reference a instance name from a loaded MC?

eg: Main movie loads popup. actionscript from main movie’s uses popup’s instance name to unload popup?

should be the same as whatever it is call in the seperate swf.

the only difference is the path, if you load it into an MC it would be localMC.externalInstance

though I thought you knew that

I do, I’ve been trying over and over maybe I’ve made a mistake somewhere.

I’ll look over it again when I get home.

Thanks


//View Contact
contact_btn.onRelease = function() {
	popLoader.loadMovie("contact.swf");
	
};
popLoader.popupMC.popbox.close_btn.onRelease = function() {
	unloadMovie("contact.swf")
}

Is this not right?

nope :stuck_out_tongue:

when you load a swf into a container, you have to unload the container its within

why anyone unloads god knows? shrugs