the actual shape of the banner is rectangular so the angles shouldn't actually be increments of 45 degrees like they were (see SOLVED)

thanks for the input tho


On 18 Feb 2008, at 13:46, Adrian Park wrote:

<quote>however, because the actual shape is a rectangle, i think there's an
issue
</quote>

What exactly is the issue you're seeing?

I think you may be over-complicating it. If the angles that your people look are in 45 degree increments then that's how your angles should be calculated
- i.e. using the square.

Adrian



On Feb 18, 2008 1:09 PM, Allandt Bik-Elliott (Receptacle) <
[EMAIL PROTECTED]> wrote:

hey guys - i have a question that i really hope someone can answer

i have a flash banner that i'm working on that is 300px wide x 250px
deep

i have done a mouse follower  that tracks the where the mouse is and
then chooses a frame of animation to show so that the people are
always looking at the mouse (roughly)
http://www.receptacledesign.com/portfolio/theonlinestudio/ herbalessence/

this gives a square (actually a circle but we'll used a square for
this) sliced into 8
http://www.receptacledesign.com/publicfiles/area1.gif

however, because the actual shape is a rectangle, i think there's an
issue with the movie choosing a frame for the corners as they're
getting cut off like this:
http://www.receptacledesign.com/publicfiles/area2.gif

could anyone tell me how i should amend my maths to make my rectangle
slice more like this:
http://www.receptacledesign.com/publicfiles/area3.gif

here is my code (note: there is a blurred 'overlap' between the
frames of animation that is governed by the blurDifference variable
as well)

//variables
var originX:Number = 200; // middle of x axis when not expanded
var originY:Number = 225; // middle of y axis when not expanded
var visibleClip = "people17"; // initialised at people17
var clip:MovieClip = content_mc; // clip reference
var blurDifference:Number = 13; // between 1 and 13 - 1 is the most,
13 the least
var degreesPerSlice:Number = 360/8; // 45 degrees
var centerArea:Number = 40; // centre area for the people to look
directly at the user

//mouse listener object
mouseListener.onMouseMove = function () {
       mouseMoved = true; // stop randomly looking
       if (mouseMoveEnabled) {
               lookAt(clip, originX, originY, _root._xmouse,
_root._ymouse);
       }
       //rollover on whole movie
if (!expandTime && roll_mc.hitTest(_root._xmouse, _root._ymouse)) {
               expandTime = getTimer() + expandTimeToWait;
       }
       updateAfterEvent();
}
Mouse.addListener(mouseListener);

//maths to find where mouse pointer is in relation to the origin
function lookAt (clip:MovieClip, originX:Number, originY:Number,
watchX:Number, watchY:Number):Void {
       var adjside:Number = a = watchX - originX;
       var b:Number = watchY - originY;
       var oppside:Number = -1*b;
       var angle:Number = Math.atan2(oppside, adjside); // in radians
var angle:Number = Math.round(angle/Math.PI*180); // convert to
degrees
       var angle:Number = -1*(angle); // invert
       var angle:Number = angle + (degreesPerSlice/2); // add half of
degreesPerSlice to correct eye level - will probably be removed when
maths is corrected
var c:Number = Math.sqrt((a*a)+(b*b)); // pythagoras a2 +b2=c2 to
find distance of mouse cursor from origin
       changeFrame(clip, angle, c);
}


//image frame selector
function changeFrame(clip:MovieClip, angle:Number,
distance:Number):Void {
       idleChangeTime = getTimer() + idleChangeRate;
       for (var i:Number=1; i<18; i++) {
               clip["people"+i]._visible = false;
       }
       if (distance>centerArea) {
               if (angle<0) {
                       angle = 360+angle;
               }
               var degreesPerSlice:Number = degreesPerSlice;
               var halfDegreesPerSlice:Number = degreesPerSlice/2;
               var blurDifference:Number = blurDifference;
var frame:Number = Math.ceil(angle/ halfDegreesPerSlice); var frameEdges:Number = Math.ceil(angle/ degreesPerSlice);
// looks
for edges of (non-blurred) frames
var distanceFromEdge:Number = (frameEdges*degreesPerSlice)
-
(angle); // find distance from edge of slice
               if (distanceFromEdge < blurDifference) {
                       if (frame % 2 == 0) {
                               if (frame<16) frame++;
                       }
               } else if ((degreesPerSlice - distanceFromEdge) <
blurDifference) {
                       if (frame % 2 == 0) {
                               if (frame>1) frame--;
                       }
               }
               clip["people"+frame]._visible = true;
               visibleClip = ["people"+frame];
       } else {
               clip.people17._visible = true;
               visibleClip = "people17";
       }
}

really stuck on this so any help you can give me will be great

thanks
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to