AS3 preoloader - code overload

Is there an easier way to create a custom preloader animation
in AS3? The
only information I can find on the web tends to have about
two pages of code
with stuff like "packages" and "public/private functions"
which I've never
used and unfortunately do not understand. The idea seems
simple to me [(var
ratio = (bytesLoaded/bytesTotal)*100) then have a movie clip
(load_mc) one
hundred frames long displaying 00-99 respectively for each
frame. Then find
some way to call a function that says
[load_mc.gotoAndStop(ratio);]. I've
seen AS2 tutorials on this subject and they all kinda follow
this general
idea. Why then in AS3 do you need two pages of code for an
action that
required 5 or 6 lines of code in a previous version of
ActionScript (AS2)?
No..no...sorry that's not my question. **sighs** I just need
to know if
there is an easier-to-understand method to creating
prealoaders in AS3? I'm
making an intro movie for a new website and the final swiff
will probably be
close to 1 MB so I want to display a simple loading animation
instead of a
blank screen. Any help is greatly appreciated.

I saw this first over in the AS1-2 forum. You'll find my
answer there.

Similar Messages

  • AS3 preloader - code overload

    Is there an easier way to create a custom preloader animation
    in AS3? The
    only information I can find on the web tends to have about
    two pages of code
    with stuff like "packages" and "public/private functions"
    which I've never
    used and unfortunately do not understand. The idea seems
    simple to me [(var
    ratio = (bytesLoaded/bytesTotal)*100) then have a movie clip
    (load_mc) one
    hundred frames long displaying 00-99 respectively for each
    frame. Then find
    some way to call a function that says
    [load_mc.gotoAndStop(ratio);]. I've
    seen AS2 tutorials on this subject and they all kinda follow
    this general
    idea. Why then in AS3 do you need two pages of code for an
    action that
    required 5 or 6 lines of code in a previous version of
    ActionScript (AS2)?
    No..no...sorry that's not my question. **sighs** I just need
    to know if
    there is an easier-to-understand method to creating
    prealoaders in AS3? I'm
    making an intro movie for a new website and the final swiff
    will probably be
    close to 1 MB so I want to display a simple loading animation
    instead of a
    blank screen. Any help is greatly appreciated.

    Yes, AS3 can look very complex, and many times it is. You
    don't need to create packages to use AS3. You can, but you don't
    have to. Writing classes in packages allow you to create libraries
    of reusable code. You can just write code that will work for you in
    a frame script space in a layer of your movie. In many cases, and
    for simple movies, this works just fine.
    To create a preloader animation, you can use the UILoader and
    ProgressBar classes. You can also use the Loader class. Here's an
    example that uses the Loader class:

  • AS3 Motion Code

    I am using the AS3 Copy Code as Motion. All works good but I need to listen when the motion is Ended or Complete. I looked through the help docs under AnimatorFactory and MotionBase but unable to find any Events on these two. What I want to do is listen for the Notion to be completed then do something. Any ideas?
    Thanks

    the animatorbase class has a motionend event.

  • Dynamically creating a AS3.0 code based on animations made at runtime

    Hello everyone,
    I am new to AS3.0 and always getting tasks that is very very challenging. Here is the challenge.
    Need to create a flash application where the user can create animations using images(upload) and text dynamically and export to a swf file. This was my previous post and the answers from the forum members was "impossible - 95%" and "Possible - 5%" (my average calcu).
    http://forums.adobe.com/thread/678202?tstart=0
    Now i got an idea from the "Possible - 5%". That is
    as per the discussion in the above link there are compliers that can create swf files from the command prompt using haxe, swfmill, neko etc etc. these requires a AS3.0 class file to get the output.
    now my question is can we generate the AS3.0 code from the swf file where the animations using images, text are done on the runtime stage. after the user is done with his animations he can click publish btn were we need to create the AS3.0 code and send to the command promt for getting the swf file as output.
    i think this task is quite hard. but any help regarding this will let me in a right direction.
    thanks in adv for any helps

    Assuming that WYSIWYG concept is valid, you are better off with Flex. Flex offers xml structure that you can use as template and just write values. Then this XML can be used by compiler as it is used in Flex.
    In any case, this is a very tedious and advanced task you are embarking on. If you are talking about couple of objects and simple animations - it is not that bad. But if there is more - it is difficult mainly because of the multitude of use cases and exponential growth in objects relationships from both display list and user interaction standpoint.
    I was a part of such project about 2 years ago and I see that one has to be an excellent UX engineer, very good architect and an advanced AS developer in order to make this kind of application worth pursuing.

  • Global vars in as3 and code run order

    two questions:
    1)how can i declare a global variable in as3, like in as2 i
    could write for example :
    _global.variableName = "variableValue"
    and then access the var from anywhere.
    2)how can i tell a part of the code from the root to run only
    after the code ran in all the other movieclips when the swf loads?
    thx

    As far as the first irem goes... AS3 does not support the
    _global reference. Just Google "AS3 _global" and you can probably
    find a few options. Here's one result:
    http://www.websitemediaplayers.com/blog/global-variables-as3/

  • AS3.0 code for tooltip

    Hello, I'm able to find AS2.0 code for a tooltip, but can't seem to find a simple one for AS3.0.
    When the pointer hovers over a point on the map, a tooltip appears with the name of the city. I need to be able to change the city name depending on the point.
    I appreciate anyone's help!

    // create one buttonObj for all your buttons
    var buttonObj:Object={};
    //////////////////////////////////////change nothing above ////////////////////////////////////
    //the next 3 lines need to be done for all your buttons
    buttonObj[yourbutton.name] = ["hello",2,2];
    yourbutton.addEventListener(MouseEvent.MOUSE_OVER,addToolTipF) ;
    yourbutton.addEventListener(MouseEvent.MOUSE_OUT, removeToolTipF);
    ////////////////////////////////////change nothing below/////////////////////////
    function addToolTipF(e:MouseEvent):void{
    var a:Array = buttonObj[e.currentTarget.name];
    var tf:TextField=new TextField();
    buttonObj[e.currentTarget.name].push(tf);
    tf.text=a[0];
    tf.multiline=false;
    tf.autoSize="left";
    tf.border=true;
    addChild(tf);
    tf.x=a[1]+e.currentTarget.x;
    tf.y=a[2]+e.currentTarget.y;
    function removeToolTipF(e:MouseEvent):void{
    removeChild(buttonObj[e.currentTarget.name][3]);
    buttonObj[e.currentTarget.name].splice(3,1);

  • Need help with as3 for popup window

    I am nearing the end of the semester in my Flash Animation class. I have learned very simple AS3 things, code snippets etc. I am trying to find the actionscript for coding a very simple popup window, but have not found a clue.
    Here's what I want to do...I have a white box with some type on the stage. When a person clicks on the white box, I want a popup to open that is larger, that will contain the same type but larger. That box will have an x so it can be dismissed. I don't want to do this in html, only in Flash CS5. I don't want a browser window, I just want a bigger version of the smaller box. I know how to build both boxes, just don't know how to write the code. I know there will be an on-click mouse event listener, and then I am lost.
    Can anyone help with the code I might use? It would be most appreciated.

    It would be something along the lines of... (using instance names relative to your description)...
    popup.visible = false;
    whiteBox.addEventListener(MouseEvent.CLICK, showPopup);
    function showPopup(evt:MouseEvent):void {
         popup.visible = true;
    popup.popupX.addEventListener(MouseEvent.CLICK, hidePopup);
    function hidePopup(evt:MouseEvent):void {
         popup.visible = false;

  • AS3.0 Need to Store Radio Button Value  as SharedObject

    I am under a tight deadline. Friday Aug.22!!! I am trying to
    store the value of a radio button (in a group for yes/no) when a
    'Next" button is pressed. I have a nextBtn.addEventListener(...) to
    contain a function which holds code to store the value of each
    radio button on the page into its own SharedObject. As such:
    _so.data.DrugName1 = DrugName1.selected;
    I do not know the AS3.0 code to get the value of the selected
    radio button in a grouping and then to use that value and store it
    into the SharedObject _so.data I have been banging my head for
    days. I fear I keep trying to use AS2 code for an AS3 project.
    AAAAAhhhhhhhh!
    Can someone please help me determine the value or data of a
    radio button or radio button group. Is it "selected" or
    "selectedData" or "getValue()" or "value" or "data" or what ??????
    I don't know where else to turn. :(
    alexdove at comcast.net
    Please email direct if you can help. I'll be sure to re-post
    a solution once I get it.
    Thank you in advance.
    Alex Dove

    FlashTastic, thanks for the reply. I entered the code but I
    cannot get the values to repopulate in the page when I return. I
    try to put the SharedObject data of the radio button back into the
    button on the page but it will not take. Here is my code:
    //*************code in page to load SharedObject value back
    into radio button when the page loads if a value
    exists*****************
    if((HumiraY_Row1.selected == false) &&
    (_so.data.HumiraY_Row1 != null)){HumiraY_Row1.selected = true;}
    if((HumiraN_Row1.selected == false) &&
    (_so.data.HumiraN_Row1 != null)){HumiraN_Row1.selected = true;}
    //******** Here is when the Next button is pushed to save the
    data***
    nextBtn2.addEventListener(MouseEvent.CLICK,
    mouseDownHandler2);
    function mouseDownHandler2(event:MouseEvent):void {
    if(HumiraY_Row1.selected == true){_so.data["HumiraY_Row1"] =
    HumiraY_Row1.selected;}
    if(HumiraN_Row1.selected == true){_so.data["HumiraN_Row1"] =
    HumiraN_Row1.selected;}
    Still stuck. Look forward to another post. :)
    Alex

  • Compiling an existing as3 packag with flex sdk (for a flash/flex/as beginner)

    Hi
    I am new to flash, flex, mxml, and actionscript (with a strong background in c, python, and scheme and some background in Java, VBA, and Javascript). I have a website for which I would like to develop some simple swf content. Basically, I would like to load esri shp files at runtime (and display a series of them as an animation) using these APIs.
    I have read through some flex getting started material, but I have found that there is no better way to learn a framework/language than to look at and modify existing code. Happily, I've found a sample that is both salient to my project and about the right level of complexity.
    I have the Flex SDK 3 and have created some simple movies. However, I haven't managed to compile the example as3 source code to a successful swf movie. I'd like to write mxml for layout/structure and as3 for functionality, and compile with mxmlc, period. Most examples I've found use of Flex Builder, Adobe Air plugins, other IDEs, etc and so they aren't very helpful.
    Here is a link to the content I'm interested in, and more importantly the as3 source packages (zip or browesable) that I'd like to compile. There are two: ManualCartogramTest.as and USStatesCartogramExample. I can use mxmlc to compile either one sucessfully, but the resulting swf file displays nothing. It seems that I should use the ManualCartogramTest class to create an instance of it, but none of my efforts have worked.
    Can anyone help out? How should I generate the swf movie given one of these packages? What key piece am I missing?
    Jeff
    For completeness, here is another example using the shp/dbf packages (from the creator) that I just can't figure out what to do with.

    1. Perhaps this wasn't the right forum.
    2. I had to use set -use-network=false to enter "local-with-filesystem" mode. Unfortunately, it took a while before I finally used a flash player that told me the problem instead of silently failing. The linux standalone or linux debugger from adobe was key! Gnash, swfdec, and my firefox plugin hid the problem.

  • Change HTML background color with AS3

    Hi all,
    I'm looking or a way to change my HTML background color trough Flash.
    The problem is it's not working any ideas? here is the code i'm using
    HTML HEAD
    <script language="JavaScript">
    function changeBgColor(newBgColor)
    if (window.document && window.document.bgColor)
            document.bgColor = newBgColor;
    </script>
    Flash document
    import flash.external.*;
    var jsCall:String;
    this.addEventListener(Event.ENTER_FRAME, bgChange)
    function bgChange(e:Event):void{
        jsCall = String(ExternalInterface.call("changeBgColor", "#FF0000"));
    best regards!!!

    Change your AS3 function code to be more like...
    function bgChange(e:Event):void{
        var result:Object = ExternalInterface.call("changeBgColor", "#FF0000");
    and I suggest you do not use...
    this.addEventListener(Event.ENTER_FRAME, bgChange)
    as that will continuously trigger the function call at the frame rate of the Flash file.  If the intention is to only trigger it once, then just use...
    bgChange();

  • Run AS3 script via html codetag?

    From what I know, it is possible to add <a href="....">
    or <a href="mailto:..."> in order to set dynamically a
    specific substring of a text to do either navigation to other page,
    or open to e-mail client. But is it possible to do much more
    important things, by just calling an AS3-function?... I am talking
    about a hyperlink to AS3 script code, instead to email client /
    browser.
    I.e. I want to download dynamic text with the names of
    Authors of papers from a database, and parse them serial i.e.:
    Authors:
    Author1Name,
    Author2Name, ...,
    AuthorKName".
    When the user press on a name, to open a vector flash pop-up
    (MovieClip) as a data-card of the specific Author. This could be
    done if there was an Flash-HTML tag like <a
    fref="loadModule(1)">
    Author1Name</a>, which would run the
    loadModule(1) function of the parent MovieClip that contains
    the dynamic text.
    I know something like this doesn't exist (
    add it to wishlist for future versions! :) ), but is there
    any other way to do it, except from creating one Object per author
    with MouseEvent listeners and place them dynamically to correct x,y
    positions?...

    It's as you describe it, with one problem: the "button"
    position and size is dynamically text-depending and not known
    before the data parsed to screen.
    Example:
    Create a textField and add inside it a dynamic text like:
    "Bill Gates created Microsoft". If this text was static I could add
    2 transparency buttons (listening to: MouseEvent.CLICK), one over
    "Bill Gates" and one over "Microsoft", where the first would make
    visible a movieclip talking about Bill Gates, and the second would
    make visible one movieclip talking about Microsoft.
    But the text can come as: "Microsoft was created by Bill
    Gates", or "There is a company named Microsoft, which was created
    by Bill Gates", or "Windows is a software created by Microsoft.
    Bill Gates was the one that created Microsoft". Thus you can't have
    apriori knowledge on where to put the buttons. In more advanced
    examples, I might not know how many buttons I should place also
    (i.e. of authors - i don't know apriori how many authors a paper
    has).
    This is same as in case of hyperlink: We don't know where a
    hyperlink can be, thus we place a tag for every hyperlink into the
    text that defines that hyperlink position and action.
    The only way to overcome this problem (just though of it) is
    to create my own tag, and before parse the text to check for that
    tag. For every tag to find the starting coordinates of it's inside
    text on the parent movieclip (x,y) and the ending coordinates - and
    providing that they have the same y-coordinate (no line change), to
    create a transparent button at the specific area over the text.
    If this is the only way to do it (thus making my own
    pseudo-html tag inside flash),
    I must know if it is possible to take (x,y) coordinates (in
    pixels) of a letter (upperleft corner) in a dynamic textbox.
    kglad, do you know if this is possible and how to do it?... (It may
    need to open new thread for this)...

  • AS3 URL Request file not found

    Hi
    I just learned last night from Ned Murphy how to code a btn in AS3.
    Trouble is, when testing the Dreamweaver frameset website, site name: URLRequest on the C drive with my default browser F12, I get a problem loading the page / file not found.
    Here is the btn AS3 code.
    btn1.addEventListener(MouseEvent.CLICK, btn1Click);
    function btn1Click(evt:MouseEvent):void {
       var url:String = "C:\WebSites\FrameSets\URLRequest\mainFrame1.html";
       var req:URLRequest = new URLRequest(url);
       navigateToURL(req);
    Just for comparison here is the AS3 btn code Ned copy pasted to my Thread last night.
    btn1.addEventListener(MouseEvent.CLICK, btn1Click);
    function btn1Click(evt:MouseEvent):void {
       var url:String = "http://www.awebsite.com/awebpage.html";
       var req:URLRequest = new URLRequest(url);
       navigateToURL(req);
    What is it that is stopping my browser from directing to "C:\WebSites\FrameSets\URLRequest\mainFrame1.html";
    Is it the var url:String?
    Thanks for reading
    Sabby76

    Re Kglad Thank you
    I copy pasted the URL into a browser and it junked to: file:///C:/WebSites/FrameSets/URLRequest,mainFrame1.html I don't know what is the correct name for file:/// probably just the O.S directories proxy? Using the file:///  in the btns function out-works perfectly. Now the rest of the websites frame set extensions directories will not pull up after the index for example: file:///C:/WebSites/FrameSets/URLRequest/index.html/mainFrame2.html I think a re-thread in the DW forum will be the next step, any clues?
    Cheers
    Sabby76

  • Air QR code generator/reader

    Anyone have any current recommendations for Air QR code generator and reader (ANE, lib)?
    I need a solution that will:
    1) Generate a text/string QR code in Air desktop
    2) Generate a text/string QR code in Air cross-platform mobile app (android or iOS).  Same code base as #1.
    3) Scan the QR code on cross-platform mobile device (android, iOS) from within my Air app.
    I see a lot of search results for various ways, but so far nothing cross-platform.
    Thanks!
    Don

    Hi Sbhave.
    Thanks for your response.
    I still need to read the post but it certainly looks interesting.
    I think it explains how I can make a QR Code having contact details.
    I got your AS3 Qr Code reader to work and it reads a QR Code BEAUTIFULLY, even a VCard. Now your code simply reads the QR Code and outputs the read to a window. Your code doesnt tell the mobile device what to do with the output. Now it is easy enough to add some code which, if the data is a web address, will go to that webaddress. However if I have used your QR Reader (in AS3) to read a vcard how do I code the Reader so that it knows that it must add the contact info to my mobile devices contacts list  and can actually do this ? I have some commercial QR Code readers which use the Zing Library and recognise that its a Vcard and give the choice to save to the contacts list.
    Thanks
    Paul

  • Converting a 12 year old animation to AS3

    I have a Flash animation I did in 2001. Since then I've done a lot a Flash generally (mostly in AS2) but not much animation.
    This old file has several actions (like the one below) on the main timeline's frames; these get movieclip sequences to repeat several times before the main timeline moves on:
    ScratchCount = Number(ScratchCount)+1;
    if (Number(ScratchCount)<9) {
        gotoAndPlay("Scene 1", 167);
    } else if (Number(ScratchCount) == 9) {
        gotoAndPlay("Scene 1", 181);
    As a learning experience, I'm attempting to update the animation (in Flash CS4 on Mac OSX v10.6.8), using Actionscript 3, where this code doesn't work.
    I have tried experiments with TimelineWatcher by refunk and several other external .as package codings, which load and control swfs made of  MC sequences. But nothing has worked -- albeit possibly because of "pilot error."
    Ideally, if possible, I'd like to control the main timeline with AS3 coding, perhaps referencing frame labels.
    Thanks.

    Hi, again, Ned! Thanks again for your prompt reply.
    Here is a link to the 2001 animation; it's 26 seconds long. http://willsoper.net/HaikuCat2001.html
    The animation's first movieclip is a 25-frame sequence of the hand stroking the cat's back. (See attachment.) The clip runs once, for 25 frames on the main timeline, and then the code makes it run twice more before allowing the main timeline to continue on.
    I would like to know the AS3 equivalent code, so when I do similar animations now, I can get MCs on the main timeline to repeat a set number of times before allowing the main timeline to continue on. I'd prefer to avoid externals; but I was intrigued by refunk's TimeLineWatcher, which, alas, I could not get to work!
    Thanks again!

  • As2 actions scripts to as3

    can any one help me for getting as3 actions which are simmilar to as2? such as
    1.'Loadmovie' on different level. Level 0, level 1 etc etc.
    2.On click 'loadmovie'
    3.fscommand like, Quite, full screen, allow scale.
    4.On release go to and play
    5.On release play and stop.
    6.playing contents in side the movie clip with on release.

    1. AS3 does not have level0, level1, etc.  To load an external swf you can use the Loader class
    2. AS2 has no such command - use the Loader to load an external file.  If you want to have a click initiate it then use an event listener for a CLICK MouseEvent.
    3.  Search Google for AS3 fscommand
    4. AS3 uses the same gotoAndPlay command as AS2 except the arguments for scene/frame are reversed to frame/scene - again, to have it happen on a click use an event listener for a CLICK MouseEvent
    5. AS2 has no command to play and stop, they are opposing commands, nor does AS3.  If you mean gotoAndStop it is the same in both except, again, for the order of the arguments
    6. This would be the same as AS2 where you target the movieclip using dot notation and tell it to play() - again, using an event listener for a CLICK MouseEvent.
    Explaining AS3 Button Code
    Let's say you create a button symbol.  Since it is a button, it is already a self animating object that will react to mouse interactions, but only visually at this stage.  The first thing you need to do to make it useful code-wise is to assign it a unique instance name.  So you drag a copy of it out to the stage from the library, and while it's still selected, you enter that unique instance name for it in the Properties panel... let's say you name it "btn1"
    In AS3, to make a button work with code, you need to add an event listener and event handler function for it.  You might need to add a few (for different events, like rollover, rollout, clicking it, but for now we'll just say you want to be able to click it to get a web page to open.  In the timeline that holds that button, in a separate actions layer that you create, in a frame numbered the same as where that button exists, you would add the event listener:
    btn1.addEventListener(MouseEvent.CLICK, btn1Click);
    The name of the unique function for processing the clicking of that button is specified at the end of the event listener assignment, so now you just have to write that function out:
    function btn1Click(evt:MouseEvent):void {
       var url:String = "http://www.awebsite.com/awebpage.html";
       var req:URLRequest = new URLRequest(url);
       navigateToURL(req);
    Here's some of what's involved there:
    evt:MouseEvent - the event listeners throws an argument automatically which the function must be set up to receive.  In this case I have given that argument a variable name of evt, though I could have chosen anything.
    :void - this defines the class of the value that the function will return.  In this case, the function does not return anything, so "void" is used.  If it did return a value, you would see a line containing "return xyz"; in the function (where xyz is not literal, it simply represents the variable or value being returned)
    The normal code to open a web page contains three distinct elements, the url, the request, and the command to get the page, so I have shown them as three separate lines.  Many people will combine them into one line.
    In AS3, in strict mode, it is necessary to identify the types/classes of the variables being created, which is why you see :String, :MouseEvent, etc... showing up everywhere.
    I know that's probably clear as mud in the explanation, but hopefully it will shed some light on what you're working with.
    Now, to create another button with a unique function for it, you could just drag another copy of it from the library, give it a unique name, say btn2, copy/paste the code from btn1 and replace "btn1" with "btn2" in that copied code, adding a new url for the page that button will open.

Maybe you are looking for