dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: as2 to as3 Migration help...easy question!

  1. #1
    Junior Member
    Join Date
    Mar 2009
    Posts
    12

    as2 to as3 Migration help...easy question!

    Hey guys, first of I would like to apologize if this question has been already answered

    I need help translating this follow AS2 code:
    PHP Code:
    onClipEvent(load){
    var 
    speed 5;
    var 
    jump 10;
    var 
    gravity 10;

    Basically what I'm trying to ask is if there is an addeventlistener or something that would load all of your variables just like how as2 did

    hmm any replies would be greatly appreciated
    Thanks!!

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    What does that do in as2? I would expect it to declare a few variables in a scope which immediately exits, and has no greater effect. If those variables go into the larger scope of the movie, then to approximate that in AS3, you need to declare the variables outside and initialize them inside the event handler. Or you can rely on dynamic property declarations, but I don't recommend that.

    Code:
    var speed:Number;
    var jump:Number;
    var gravity:Number;
    
    loaderInfo.addEventListener(Event.COMPLETE, onLoad){
      speed = 5;
      jump = 10;
      gravity = 10;
    }
    I have no idea why you'd want to delay setting hardcoded values like that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center