Displaying text in a dynmic text field
I'm trying to track the location of the bar (mc_InvestmentButton), set it equal to a percentage, and have it display continuously as the user is moving the slider in a dynamic text field. For example, if the the bar's y position is at 200, the text field should show 5%, if it's at 250 it should show 6%, and so on. I've tried some things but I'm not getting the desired result. See picture for the basic idea. Here is the code:
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.geom.Rectangle;
var sliderBounds: Rectangle = new Rectangle(slider_background_mc.x, slider_background_mc.y, 0, slider_background_mc.height);
mc_InvestmentButton.addEventListener(MouseEvent.MOUSE_DOWN, moveInvestmentButton);
mc_InvestmentButton.addEventListener(MouseEvent.MOUSE_UP, moveInvestmentButtonOFF);
txt_CurrentRate.text = String(mc_InvestmentButton.y);
var displayRate = txt_CurrentRate;
// Your start functions should now be this
function moveInvestmentButton(e: MouseEvent): void
{
mc_InvestmentButton.startDrag(false, sliderBounds);
stage.addEventListener(MouseEvent.MOUSE_UP, moveInvestmentButtonOFF);
trace(mc_InvestmentButton.y);
trace(displayRate);
}
function moveInvestmentButtonOFF(e: MouseEvent): void
{
mc_InvestmentButton.stopDrag();
stage.removeEventListener(MouseEvent.MOUSE_UP, moveInvestmentButtonOFF);
}
**********************
Here is the basic idea:
**********************
Here is the trace output data when I clicked on the slicer 3 times:
