Subject: Re: Thunderdome: Placing scripts or something like that Date: Tue, 27 Nov 2001 13:07:38 -0500 From: Mary Obelnicki To: Jeff Seal CC: external_thunderdome@adobe.com Jeff - I probably did make this with a build later than 67. Here's what the file contains. A square, with two states named normal (colored black) and red (colored red), a dynamic text field on _root's(the composition) timeline with variable name display and this code on the onEnterFrame handler of the square: var bounds = this.getBounds(); // the bounds in the object's coordinate space. _root.display = bounds.xMin + " " + bounds.xMax +" " + _xmouse +"\n"; if((_xmouse >= bounds.xMin) && (_xmouse <= bounds.xMax)) { this.lmSetCurrentState("red"); _root.display += "state is red\n" } else { this.lmSetCurrentState("normal"); _root.display += "state is normal"; } - Mary At 12:43 PM 11/27/2001, Jeff Seal wrote: >Mary, > >I wanted to open this file but it says it is corrupt or not a LM file. >Was it built with a later build than 67? > >Jeff > > > True, getBounds() is broken in preview, but there are a couple of other > > problems with your plan which will occur even on export. > > > > 1) when you use getBounds(), it returns an object what contains the > > _current_ bounds of the object in it's coordinate system. Even if the > > bounds of the object change the properties of the object returned by > > getBounds() will not change. You must call getBounds() each time you want > > the current bounds of the object. > > > > 2) due to the way things currently export. accessing child objects in the > > onLoad handler of the parent may not work. You should put this code in a > > keyframe script on the first frame that the object exists, or you should > > put in the onLoad handler of the object. What's probably happening in your > > script on export is that the property 'bounds' is not defined leading to > > junk values in your equality test. > > > > 3) be careful with your coordinate spaces, it can lead to really funky > > stuff, especially with the mouse. getBound() by default returns the bounds > > of the object in it's coordinate space. In your code you are getting the > > bounds of square in it's coordinate space and testing against the position > > of the mouse in _root's coordinate space this will not get the results you > > want. > > > > 4) in terms of organization, I would put code that only deals with a > > specific movie clip, in the movie clip's event handlers rather than in the > > composition's event handlers. That way the code is localized and doesn't > > depend on the hierarchy of your movie clips. > > > > Attached is a working (on export) example, all code in on the onEnterFrame > > handler of square. > > > > - Mary > > > > At 02:08 PM 11/24/2001, Joe Bowden wrote: > >> Phil, > >> > >> The getBounds method is currently broken- the properties that are returned > >> such as xMin and xMax are undefined, which is why your script isn't > working. > >> This is a known bug. > >> > >> Try calling another method, and if you run into any problems, please > let us > >> know. > >> > >> Sorry, > >> -Joe > >> > >> -- > >> Joe Bowden > >> Quality Engineer > >> Adobe LiveMotion > >> > >> > >>> From: Phil > >>> Organization: VClassics International > >>> Date: Fri, 23 Nov 2001 15:47:56 -0800 > >>> To: T Dome > >>> Subject: Thunderdome: Placing scripts or something like that > >>> > >>> I'm having a really frustrating time figuring out where to centralize > >>> scripts, without having to put every snippet in its own MCG or keyframe > >>> on a timeline (which I can do pretty successfully by now). So, trying to > >>> take the smallest little baby steps possible to figure this out, I've > >>> made a simple example that doesn't work. > >>> > >>> In a fresh comp, I drew a square, made it a simple MC, and named it > >>> 'square'. > >>> > >>> In the comp's onLoad handler, I declare a variable: > >>> > >>> var bounds = square.getBounds(); > >>> > >>> In the comp's onEnterFrame handler -- there only exists one frame -- I > >>> have this: > >>> > >>> if ((_xmouse >= bounds.xMin) && (_xMouse <= bounds.xMax)) { > >>> square.lmSetCurrentState("red"); > >>> } else { > >>> square.lmSetCurrentState("normal"); > >>> } > >>> > >>> (Of course, I've given 'square' a custom state called 'red') > >>> > >>> So, if the mouse is within the x coordinates of 'square', and never mind > >>> the y axis, 'square' should change state, right? No. In preview, it just > >>> flickers the timeline and nothing happens. In browser, state switches to > >>> 'red' an instant after loading, then switches to 'normal' the first time > >>> the mouse passes within the x coords of 'square', and that's all. It > >>> starts out backwards and then dies after one reversal. > >>> > >>> What's wrong with this? Is my 'if' condition goofy? Why won't the value > >>> of 'bounds' update as I expect? > >>> > >>> Aaaaarrrrr....... There are some really basic concepts I *still* don't > >>> seem to get. Thanks for anything that'll clarify whatever those are for > >>> me. > >>> > >>> --Phil S. > >>> > >