I'm trying to use a _root.movieclip.onrelease () function followed by a gotoandplay. When I test the movie it jumps to frame 2 as instructed, but stops intead of playing. I have also tried preceding it with an if framesloaded = totalframes. I am perplexed. Please help if you can. dan
Can you post the code that you are using? That would help narrow down the possible reasons.
thanks for replying. here's the code... FRAME1: stop(); _root.close.onRelease = function() { if (_framesloaded = _totalframes) { gotoAndPlay(2); stopAllSounds(); } }; this.onLoad = function() { setProperty(_root.close, _visible, false); }; this.onEnterFrame = function() { sunrotate = getProperty(_root.sun2, _rotation); sunalpha = getProperty(_root.sun2, _alpha); hilloney = getProperty(_root.hillone, _yscale); hillonex = getProperty(_root.hillone, _x); mountoney = getProperty(_root.mountone, _yscale); mountonex = getProperty(_root.mountone, _x); mountworot = getProperty(_root.mounttwo, _rotation); mountwox = getProperty(_root.mounttwo, _x); hilltwoy = getProperty(_root.hilltwo, _yscale); hilltwox = getProperty(_root.hilltwo, _x); trace("sunro" +sunrotate); trace("sunalph" +sunalpha); trace("hilly" +hilloney); trace("hillx" +hilltwox); if (sunrotate <= 100 && sunrotate >=80 &&sunalpha >=90 && hilloney > 40 && hilloney <= 100 && hillonex >213 && hillonex <290 && mountonex >=200 && mountonex <= 225 && mountoney >90 && mountwox > 295 && mountwox <=306 && mountworot == 0 && hilltwoy > 85 && hilltwox < 321 && hilltwoy < 325) { setProperty(_root.close, _visible, true); } }; FRAME 2: play(); what's going on is a five track mixer (pan knobs and faders) . The pan and faders also effect various properties of images in the background. This is a challenge/game sort of thing where the users needs to match the mix of each track with the provided mixdown . Once they've done that, a clip is set to visible true. All that works and its all on frame 1. On frame two, an alpha tween begins that should fade out the images. But it gets stuck there, on two, rather than playing out the tween. Also, I've tried it with and withou the play() on frame two. Thanks again for your help.
Not going to be much help I'm afraid. I can't reproduce what you are seeing. I took the code and without all the mixing stuff placed the general ideas in a movie and it worked. Sounds like you know a lot about AS so ignore what you've already done. 1) put a trace on frame 2 and the last frame of the tween to make sure that it is getting stuck on frame 2 and not that the graphics just aren't tweening. if that is ok then try 2) create a new movie and put in the bare shell of this code and get it working. Then add in the onEnterFrame code and see if it still works. Then the onLoad code, etc. Sorry I couldn't be more definitive with answers. Tim
I have two comments: 1) You used: if (_framesloaded = _totalframes) { You should be using == not =. == checks equality and = sets the value. 2) You have an enormous if statment with like 20 conditions. (with the &&'s). I've heard that you should put each part of the condition in parenthesis... For example, say you had: if(a>b && c<2 && !p){ trace('Yup.'); } You should use: if((a>b) && (c<2) && (!p)){ trace('Yup.'); } I think flash sometimes gets mixed up, and might think it's a>(b && c) && !p, or something like that.
I played around with it for a while, adding mc's to frame two that have nothing to do with frame one and they play out perfectly. I think it has something to do with setting the properties of the image mc's in frame one that is making them untweenable in frame two. I don't know. it's not a neccessary effect, so maybe i'll try something else. Also thanks for the AS cred, but I'm only five weeks into writing code (in any language), and thus know J.S. about AS. All I know is this is an amazing program for getting ideas tangible. Thanks again for your help. -Dan
N, Good advice on the parenthesis and the ==. I will use it in the future, however, I don't think that's the problem I'm having. Thanks for taking a look at the code.
Wait, are you trying to motion tween a MovieClip that you are changing the alpha (or any of those major properties, like _x, _y...), because I don't think you can do that since the tween will be different than it was planned to be... And you're welcome.
Once you start controlling the '_' properties of a movie via script, the timeline relinquishes its control .. so tweens will no longer work. A clip (like a man) cannot serve two masters. And if it tries to (as can happen when you use swapDepths on timeline objects) you can get weird results. -- Jeckyl
The extra () make no difference to Flash ... it will always do comparisons before it does && or || (unless () tell it otherwise). It is more for readability for us poor humans (and more importantly, for yourself when you try to read your code in a few months or years time). -- Jeckyl
Alright, I haven't tried it yet, but maybe I can achieve the same tweening effect in AS, with an: on release onenterframe whatever_mc._alpha -= 5 ignore the shoddy freehand code, but in practice that'll work right?
Yeup .. something like that should be fine .. I'd probably put code in to kill the onEnterFrame handler once the alpha gets to <= 0. As long as you animate using either one method or the other (ie timeline and tweens vs script) and not try to mix them up for a given object. Generally well written script gives you smaller file size over tweens (as one little script animates over several frames, vs transforms on every frame of a tween). But tweens do give you skewing and shape tweens, which you can't do in script (unless you draw your shapes completely via scripted drawing API), and tweens are (once you get your head around the UI) easier to set up directly with the UI (no code), -- Jeckyl
Don't see what you're looking for? Try a search.
|