[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 162
  • Last Modified:

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!  
0
steverguy
Asked:
steverguy
1 Solution
 
blue-genieCommented:
{} 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.
0
 
steverguyAuthor Commented:
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!
0
 
rascalpantsCommented:
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

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
biyikCommented:
Does it run with AS2?
0
 
ccareyCommented:
The problem with your code (or rather the reason it doesn't work in AS3) is that the variable isn't initialised. If you put "var" in front of the declaration of cv then As3 will be happy. You didn't need to do this in AS2, which is why it would have worked before.

var cv = {} //calendar setup vars
cv.horizontalSpacing = 25
cv.verticalSpacing = 25
cv.horizontalOffset = 19
cv.verticalOffset = 69
0
 
steverguyAuthor Commented:
Thank you!
0
 
steverguyAuthor Commented:
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.
0
 
ccareyCommented:
no probs
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now