Skip to main content
Inspiring
October 8, 2024
Answered

removing repative elements in symbol names to shorten code

  • October 8, 2024
  • 1 reply
  • 778 views

wondering whats the easiest way to shorten elements that for instance, clearly were pragmatically programmed as the symbol names neaRLY  all contain for instance "front and "back" and var 3  is "arm" well the code looks really really ugly typing this out in full  this each time in an array. .  for instance can i set a static element with var1=front and  then just call that and for the back say var2=back to  do the same.

the files all contain for a shirt the following

12 front and back arms

a torso front and back

 

using the variables

"var1"_+"var3"+"var4" is one (var 1=front, var 3=arm,  with a counter at the end to make the #

im adding the as var4  the dress and jacket are front_arm_jacket or front_arm_dress and im trying to accoumdate this in the same script. im a bit confused how to set this, im aware in arrays you can push things to in/out etc so if its not needed its NULL and if that catagory needs it, pushes the thing to it

 

 

This topic has been closed for replies.
Correct answer kglad

there's no problem using strings in arrays and coercing them into objects.  eg,

 

var aspectA = ["front","back"];

var body_partA = ["arm","leg"];

 

// this.front_arm =

this[aspectA[0]+"_"+body_partA[0]] 

1 reply

kglad
Community Expert
Community Expert
October 8, 2024

yes.  use bracket notation to coerce strings to objects.

Inspiring
October 8, 2024

i'm also looking into using arrays and rather than the last fiasco(hey the chart at least shows the depth  of the problem!!)

using this video so far....one of the craziest qiuestioon was "why do i still use actionscrpt vs html5" and theirs a wierd solution to that, when i tried converting a assembled one, the animations are running slow and the thing looks wounded ...for a idle animation and i'm not sure why.

this is the adobe video for arays , anything standing out as missing here to you i should know about? (IT SEEMS like this was a common topic as tehris 10 videos on it on yt from the era) .

https://www.youtube.com/watch?v=mhICNj1SQRQ

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
October 8, 2024

there's no problem using strings in arrays and coercing them into objects.  eg,

 

var aspectA = ["front","back"];

var body_partA = ["arm","leg"];

 

// this.front_arm =

this[aspectA[0]+"_"+body_partA[0]]