Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bar graph, _xscale property and referencing movieclips

Status
Not open for further replies.

jwhittlestone

Programmer
Apr 19, 2006
16
GB
I think I may have the referncing incorrect to alter the _xscale property of a movie clip within a movie clip

The bars should be showing as I alter the _xscale property in a function, but this is not happening. I hope someone may be able to help an AS newbie (as I'm close to tears )

As you can see, the vote data is fetched from the db ok and displays.

Percentages are calculated from the vote figures and this is functioning ok as you can see from the text box on the left. ie.
var percent1 = (Number(votes1) / total) * 100;

In the same frame where these percentages are worked out, this code is executed to alter the _xscale property ie.
percentBar1.setPos(percent);

The function definition to this is in the first frame of the movieclip of which percentBar1 is an instance. ie.
function setPos (percent){
bar._xscale = percent;
}


bar is an instance on the timeline in the same frame as this definition (the timeline is only one frame long.

I'm used to director - and am not too sure about referencing of instance vars. The fla file can be found here
thanks so much in advance

Jon
 
Try:

[tt]//
setPos(percentBar1, percent1);
setPos(percentBar2, percent2);
setPos(percentBar3, percent3);
//
function setPos(targetMC, persent) {
targetMC._xscale = persent;
}
//[/tt]

(Don't place scripts in MovieClips - bad practice.)

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top