Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Thread Tools Rate Thread Display Modes
Old 04-28-2012, 12:26 AM   #1
Registered User
Join Date: Oct 2011
Posts: 18
Default Converting a percentage to a decimal (after effects to flash scale conversion)

Hi All,

I have a function that receives scale information each frame as a percentage (from After Effects) that needs to be turned in to a decimal to work in flash. ie. values like 94.2627118644068 need to be 0.94.

I've tried this:

ActionScript Code:
if (prop == "Transform_Scale"){ // if cue point is scale related then,                                     var resultsS:Array = val.split(",",[3]);    // splits string into 3 figures of which im interested in only one which is a percentage like 94.2627118644068.                                     faceParent.faceContainer.scaleY = Number(("."+resultsS[1])*10); faceParent.faceContainer.scaleX = Number(("."+resultsS[1])*10); // trying to make it 0.94 and apply to movieclip. };

Because i am placing a decimal point manually its breaking as theres multiple decimal points along with the percentage decimals. i.e. this is clearly a noob attempt.

Is this just basic maths or does it require certain commands in AS3? I'm dealing with percentages that vary from sub 100 to over 100 but below 200.

Thanks for reading!
HarryBrook is offline   Reply With Quote
Old 04-28-2012, 01:03 AM   #2
Senior Member
Join Date: Feb 2006
Location: Washington, DC
Posts: 2,812
Send a message via AIM to abeall

To move the decimal left you need to divide:

ActionScript Code:
Number(resultsS[1]) / 100;
Aaron Beall | Flash portfolio | Fireworks extensions | Twitter
abeall is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 09:29 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.