I am trying to have everything happen on the first actions frame of my movie. Therefore I am loading all movie clip instances from there. The problem is that I would like to have a couple MCs load after a few others. Say my interface loads and takes 3 secs. Can I tell my main logo to load fram frame 1 but start after 3 secs? Does this invovle the setInterval function? If you know of agood tutorial on this please let me know. I should note that I have been using an onClipEvent() on the actual MCs to bring them in. Example: On the background mc onClipEvent(load) { _alpha =0; speed= 5; _x=389.5; _y=289.5; } onClipEvent(enterFrame) { if(_alpha<100) { _alpha += speed; } else { _alpha = 100; } } Thanks in advance.
onClipEvent is an old flash 5 way of doing things so you'll want to migrate over to putting all your code on the timeline in one layer, the benefits of this are far too numerous to go through, but trust me, once you do it you'll never look back. You can still apply the same functionality to mc's for instance in this case you have a on enterframe fading out itself, you could put this code on the time line and put it in a loop to apply the same functionality to any mc you like all at once. e.g. my_mc.onEnterFrame = function(){ } or for a loop either name the mc's incrementally my1_mc, my2_mc etc... or put their names in an array e.g. my_array = for(var i=0;i<my_array.length;i++){ var mcName_str = my_array; this.onEnterFrame = function(){ } } using this approach you can have all the code to load the mc's in a hidden state in one function, then 3 seconds later trigger with a setInterval another function telling all the mc's loaded to show and apply properties to each. Hope that helps, dr_ross
dr_ross, Thanks for the reply. I can see the logic behind your suggestion but I'm afraid that I'm not sure how to apply it. I tried to place my code inside it as such: starField_mc.onEnterFrame = function(){ _alpha =0; speed= 2; if(_alpha<100) { _alpha += speed; } else { _alpha = 100; } } This didn't work. starfield_mc is one of the MCs that I want to execute first. Did I target that correctly with "starField_mc.onEnterFrame = function(){..."? or should I replace my_mc (from your example) with something else? Thanks in advance.
so if you're putting your code on a empty frame on your timeline, make sure the movieclip you're trying to reference is on the same frame but can be a different layer. You can check weather the reference is right to your movieclip by simply putting a trace(my_mc) (where my_mc is the name of your mc) on the timeline. If you get any more issues i'l make an example for you
I was able to do your trace test with success. I guess my question is, how do I get the following code (my fade in) to be a function that I can call for any other mc in my movie? onClipEvent (load) { _alpha = 0; speed = 2; } onClipEvent (enterFrame) { if (_alpha<100) { _alpha += speed; } else { _alpha = 100; } } I can't tell by your code if that is the shell of the function or the function call: my_mc.onEnterFrame = function(){ } It would seem to me, based on some reading I am doing, that because of the target "my_mc", that this is the call. Sorry, I'm definately new to functions.
doing my_mc.onEnterFrame = function(){ } is the same as having function onEframe(){ } my_mc.onEnterFrame = onEframe; every update of you movie depending on the fps you have set the onEnterFrame handelr of you movieclip is called, So to have my_mc fade itself out everyframe we'd do var speed = 5; my_mc.onEnterFrame = function(){ if(this._alpha<100){ this._alpha += this._parent.speed; }else{ this._alpha =100; delete this.onEnterFrame; } } we're using "this" as the scope of the function has changed so that everything points internally to the movieclip, and "this._parent" because the variable speed is located one step outside the movieclip on the _root. So we've tied everything down reletive to the movieclip. The "delete" is used to remove the onEnterFrame once its faded up so it's not being called evryframe when it doesn't need to be
Thanks for the reply and code example.
dr_ross, I tried exactly what you said but with no success. I have created a very small ..fla with 1 symbol (starField_mc) and 1 frame for actions. This is where I applied the advice you gave me. You can http://www.funkship.com/test/starField_test.fla if you wish to see exactly what I have done. pharaoh
seems to work fine mate, having set the alpha of the starfield to 0 then compileing it it faded up grand. To have it fade down simply change starField_mc.onEnterFrame = function() { if (this._alpha<100) { this._alpha += this._parent.speed; } else { this._alpha = 100; delete this.onEnterFrame; } }; for starField_mc.onEnterFrame = function() { if (this._alpha>0) { this._alpha -= this._parent.speed; } else { this._alpha = 0; delete this.onEnterFrame; } }; you might not be seeing it as it happens so fast due to your fps being set at 60, try setting it lower at 12 or 24, or adjust you speed to compensate
It is so odd that it works for you and not me. I copied & pasted the code from your last post just to be sure (including the var speed). I set the frame rate to both 12 & 24 fps, and experimented with lower speed values. I even extended the movie out to 60 frames and placed the starField_mc and the action script on the last frame to give my self some lead time before anything should happen, just to be sure I wasn't missing anything in the begining of the movie. It still pops up w/o any fade in. Now when I reversed the code to make it fade out, then it worked! At least I know how to do that, but what I really want is to make it fade in and after a few seconds (the original problem I was having). Let's pretend I want it to fade out ('cause we know that works), how do I tell this function to execute after, say, 5 seconds. Again, thanks for hanging in there with me. I really appreciate it! I will do some more reading & experimenting.
Don't see what you're looking for? Try a search.
|