Simple site navigation using AS3 and classes

Posted on 2009-04-17
Last Modified: 2013-11-11
I currently have developed a site using AS2 ( To understand AS3 better, I want to re-code the site to use AS3 instead and I want to do it all using classes, I was told that the best way to do that is to load individual SWF files for each section. Then I should also populate an array with the different names of the states of the buttons, corresponding to the names of the different button instances.

Is there a link that shows an example of what I am trying to do? I am looking all over the web and in books and cannot find anything using classes only. I do so many examples of using frame-based navigation, but that's not how I want to code the site.
Question by:msukow
    LVL 11

    Expert Comment


    AS3 is truly Object Oriented and so, yes, classes are an integral part of using it.  One of the best resources you'll find for AS2 and AS3 are the video tutorials by Lee Brimelow at:

    Here's one for AS2, but it talks about classes.

    The idea is the same as in AS3.  You'll understand it better because you already use AS2, but there are a ton of AS3 tutorials there too.

    Here's an AS3 tutorial that talks about an object oriented scrollbar, and so uses classes and all the stuff that goes with it.  It would be good to learn from this one:

    Start with these, they can keep you occupied for weeks.

    Author Comment

    The biggest area I cannot understand is how to navigate from one section to another. In AS2, I would add each section in its own frame. I know I can do that as well, but I want to do everything in one frame with classes.

    That's what I cannot find - should I be creating each section in its own SWF and then use the loader class to dynamically load each section, depending on which button is pressed?

    Should I instead add and remove children depending on what button is pressed?

    I do not want to use the timeline at all - I want all my images to use the sprite class as much as possible and code the buttons as simpleButtons if I can.
    LVL 11

    Accepted Solution

    The questions you're asking are ones with long, complicated answers.

    I would recommend some of the AS3 books like the Keith Peters book on ActionScript.

    If you are shrinking everything down to 1 frame, then you are no longer using the timeline and what you have is like any other program out there, particularly Flex.  You don't create frames in ActionScript, you can only navigate to them if they already exist.  Given you don't have other frames, you have to decide what you want to display at any given time.  You could do that by loading a bunch of external swf's and displaying whichever one is needed, or you could create display objects in the AS code itself.  How you do it is up to you and there are benefits/disadvantages to both methods.

    I wouldn't be adding and removing children all the time if you don't have to.  I'd add them once and then change their visibility to on/off.  Go through the Flex tutorials and that's where you'll see what needs to be done.


    Author Comment

    Thanks - that really helps clear things up for me. I am also training in Flex and it seems like it may be easier to use Flex to create the site than Flash because I understand Flex more than Flash - weird, but true.

    Author Closing Comment

    Thanks - I spent hours trying to find your clear and concise answer on the web!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
    In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
    The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
    This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now