Link to home
Start Free TrialLog in
Avatar of steverguy
steverguy

asked on

Help with understanding the Actionscript 2 code

I'm learning AS3 and trying to dissect source code I received.  The source code is in AS2, so i figured converting it to AS3 would help  I've stumbled on a portion that I'm not sure what the problem is, but it won't run in AS3.  I believe it is because it's not declared properly.  Here's the code:

cv = {} //calendar setup vars
cv.horizontalSpacing = 25
cv.verticalSpacing = 25
cv.horizontalOffset = 19
cv.verticalOffset = 69

I don't understand the cv = {} - is this a way of dynamically creating a class in AS2?  I've never used it.  How would this be declared in AS3?

Thanks for your help!  
Avatar of blue-genie
blue-genie
Flag of South Africa image

{} means you're initialising the cv object.

in AS3 you'll then need to create a cv class.
create it's variables.

if you don't know how to create classes have a look in the help file for examples with explanations.
Avatar of steverguy
steverguy

ASKER

that makes sense i can find the examples for creating classes.  

So for actionscript 2 you only needed cv = {}  to create a class?

Thanks for the quick answer, I appreciate the help!
Avatar of rascalpants
no, a class (in AS 2.0) is setup in the below, very basic structure... and make sure you also give the class a file name that matches the class name exactly.. ie  MyClass.as


rp / ZA


// put import statements here
 
class MyClass
{ 
   // put class properties here   
   function MyClass(){ 
      // constructor 
   } 
   // put class methods here
 
} 

Open in new window

Does it run with AS2?
ASKER CERTIFIED SOLUTION
Avatar of ccarey
ccarey
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you!
Thank you for your help.  It was really hard to search for this concept in Google.   The author of the code I'm studying uses that method several times - and it seems straight forward, and it didn't make sense that AS3 couldn't handle it.

Thanks again.
no probs