Thread: AS1 to AS3

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0

    AS1 to AS3


    Hi

    I am new to the forum and looking to get into AS3 more. I have not done AS since AS1 and I have skipped AS2. I am trying to get back into it but most forums like ultrashock and actionscript.org seem to be a dessert. I hope this forum is more lively as I need a lot of help with AS3 and learning it.




    How can I convert this code from AS1 to AS3


    This code is inside a timeline of a movie clip


    // It plays a random part of the movie clip
    gotoAndPlay(random(30));
    //The higher the numbers the bigger the bubbles.
    scale = random(31) + 70;
    _xscale = scale;
    _yscale = scale;


    This was inside a timeline of another separate movie clip

    // Go to and Play and random frame
    gotoAndPlay(random(30));
    // Scale it randomly to size 101.
    // The bigger the number the bigger the Bubbles
    scale = random(101);
    _xscale = scale;
    _yscale = scale;



    This was on the preloader movie clip.

    onClipEvent (load) {
    Total = Math.floor(_root.getBytesTotal() / 1000);
    // The Loading messages for the preloader
    loadMessage = new Array("Angel of God", "My guardian dear", "To who God's Love","Commits me here", "Ever this day", "Be at my side", "To light and guard", "To rule and guide", "Amen");
    currMessage = 0;
    }

    onClipEvent (enterFrame) {
    Loaded = Math.floor(_root.getBytesLoaded() / 1000);
    Percent = Math.floor(_root.getBytesLoaded() / _root.getBytesTotal() * 100);
    // Devide the length of the message by 100
    division = 100 / loadMessage.length;
    // Current message X division
    limitInf = currMessage * division;
    // Go through the messages one at a time according to the length
    limitSup = (currMessage + 1) * division;
    // Text Display
    _root.PercentDisplay = int(Loaded) + " KB Out Of" + " | " + (Total) + " KB" + " | " + (Percent) + " % | " + loadMessage[currMessage];
    // If the preloader is greater then current text in the message
    if (Percent > limitSup) {
    // move on to the next text in the Array
    currMessage++;
    }
    // Keep the length of the message equal to the preloader
    gotoAndPlay(Percent);
    // Set the width property of the Bar
    setProperty(_root.Preloader, _xscale, Percent);
    // Set the X position of the filled bubbles with the Bar
    _root.asb._x = _root.Preloader._width + _root.Preloader._x;
    // Set the X position of the Empty bubbles with the Bar
    _root.ahb._x = _root.Preloader._width + _root.Preloader._x;
    // If the Movie has loaded, play
    if (Percent == 100) {
    _root.play();
    }
    }
  2. #2
  3. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,678
    Rep Power
    3164
    Hi, the first block of code is quite simple to update since little has actually changed in the syntax:
    Code:
    // Sticking "this." as the prefix helps identify what you are intending to gotoAndPlay.
    // The random function has changed so it is now clearly part of the Math package.
    this.gotoAndPlay(Math.random() * 30);
    
    scale = (Math.random() * 31) + 70;
    
    // All properties that before were prefixed with an underscore now have none.
    // Also, the naming convention has been standardised so the operation comes first (scale) then the property it adjusts i.e. X or Y.
    this.scaleX = scale;
    this.scaleY = scale;
    As for the second block of code, well that's a fair amount to cover and since in explaining each line out I would be robbing you of the chance to learn something new yourself, I think the best thing would be if you read through an AS2 to AS3 migration guide which you can find here. I know you said you skipped AS2 but mostly what that really did was add extra functions and classes to AS1, syntax wise not a lot changed, at least from the level of code you posted.
    Quis custodiet ipsos custodes?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2010
    Location
    Spokane
    Posts
    14
    Rep Power
    0
    I believe there is plenty of software available online that can help you with that particular task
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0
    That's weird. I did not receive a notification that I got a reply. I am subscribed to this thread. I should have received one.


    Anyways, thanks for your help.

    I am not a programmer but a designer. I do a lot of design and animation work so studying to be a developer is not an option right now. I am not really into programming. The only language I can understand is html, PHP and AS. I am mostly ok with AS but since I have skipped AS2 I thought I would go straight into AS3.

    I would like to do things like change a line of code, make preloaders, contact forms and mostly the basic and intermediate stuff like an interactive website. I am not really a developer and would not be getting too deep into AS.

    Would you be able to convert that code for me into AS3? I don't think my schedule and hectic work life will allow me to study up on AS3 then convert that preloader to AS3 language.


    Thank you
  8. #5
  9. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,678
    Rep Power
    3164
    You see, when you open with:
    I am new to the forum and looking to get into AS3 more. I have not done AS since AS1 and I have skipped AS2. I am trying to get back into it
    That made it sound like you actually wanted to learn something. I'm not going to convert the last block of code for you as I too would rather spend my time doing other things. I can move the thread to either the "Project Help Wanted" or "Hire a Programmer" forums or you could just search for a ready made AS3 preloader since there are a lot of them out there already.
    Quis custodiet ipsos custodes?
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    3
    Rep Power
    0
    As I have said, I am a designer and I am trying to get back into it but not as deep as before. Only basic stuff like interaction between movie clips, contact forms etc... Nothing advanced as I used to be with AS1.

    Thanks for your help though.

IMN logo majestic logo threadwatch logo seochat tools logo