Set scaleX property on a Sprite without altering the child inside
Is this possible?
My site is set up with next and prev buttons on the right and left sides respectively, and as you roll over either of the hit areas around the buttons a Sprite fades in which contains a TextField that describes the next page. Said Sprite calls the StartDrag() method, so it follows the mouse within the bounds, which is all fine and dandy on the left side of the page. Adobe, however, seems to have forgotten to put a way to dynamically alter the registration point of a Sprite, MC, whatever else, so when you roll over the right side of the page, the sprite is displayed from the top left and is mostly off the stage.
Trying to hack this problem I have tried numerous things ( classes written by others, other hacks) and the best that I have found is to use the scaleX method on the Sprite, changing the scale to -1. This, of course, makes the Sprite seem like it's reflected from its normal point, which means all its children show up backwards.
Is there anyway I can use this hack without it altering the text?
OR
Does anyone know a different way to go about displaying a Sprite from another corner? Any way to make a Sprite fade in and follow the mouse on the LEFT HAND side of the mouse pointer?
Thank you very much in advance.
Here is a snippet to give an idea of what's happening:
naxtPage.labelBG.scaleX = -1;
nextPage.labelBG.startDrag( true, nextHitRect );
nextPage.labelBG.x = nextPage.labelBG.parent.mouseX;
nextPage开发者_运维技巧.labelBG.y = nextPage.labelBG.parent.mouseY;
Cheers
You could do this entirely differently, by using an ENTER_FRAME
event. If you only create the event when a user rolls over a button, then inside the function the event fires you check the mouse's position relative to the stage's bounds, and determine where your pop up should appear in relation to the cursor. As that function will be called every frame, your pop-up will follow the mouse, always in the right place. Something like:
function onMouseOver(event:MouseEvent):void
{
addEventListener(Event.ENTER_FRAME, updatePopup);
}
function updatePopup(event:Event):void
{
if (mouseX > (stage.width - popup.width))
{
//Display the pop up on the left of the cursor
popup.x = mouseX - popup.width;
}
else
{
//Display the pop up on the right of the cursor as normal
popup.x = mouseX;
}
}
You'd also need to create a rollOut event, and when that fires remove the ENTER_FRAME
event listener. I haven't tested this code at all, but I'd guess that something along those lines will fix your problem.
Hope that helps.
debu
精彩评论