AS1/AS2 to AS3 onClipEvent(load),onClipEvent(enterFrame)

onClipEvent (load) {
     total = _root.getBytesTotal();
onClipEvent (enterFrame) {
     loaded = _root.getBytesLoaded();
     percent = int(loaded/total*100);
     text = percent+"%";
     gotoAndStop(percent);
     if (loaded == total) {
          _root.gotoAndPlay(2);
Dear all,
I found a sample code that is writen in AS1/AS2 to see if the load is finished, If finish loading, it will go to the next frame. How do I convent this into AS3? This is my first time looking at AS1/AS2 code, especially onClipEvent (load), _root.getBytesTotal(), onClipEvent (enterFrame), _root.getBytesLoaded(),_root.gotoAndPlay(2).
Can someone help me out with this?
Thanks,
-Zainuu

Hi, Thanks for the reply
stop();
this.addEventListener(Event.ENTER_FRAME, loading);
function loading(e:Event):void{
    var total:Number = this.stage.loaderInfo.bytesTotal;
    var loaded:Number = this.stage.loaderInfo.bytesLoaded;
     trace(total);
     trace(loaded);
    if (total == loaded){
        play();
        mc_Loader.visible=false;
        this.removeEventListener(Event.ENTER_FRAME, loading);
I tried to trace the total bytes and loaded bytes, it returns me
total = 405668
loaded = 405668
Is there a way to show the loaded bytes starting from 1 till 405668? I'm trying to find out if it is really loading the thing. Otherwise is there any other ways to slow down the loading for a bit because it only shows my loading bar for 0.5secs, not really sure if its really loading it...

Similar Messages

  • Translating AS2 into AS3

    Hi, I am trying to create a scrollbar for a movie using a
    tutorial I found online (
    http://www.flashkit.com/tutorials/Interactivity/Scrollin-Jake_Gel-683/index.php).
    My problem is that I am new and am having issues translating the
    AS2 script into AS3. Is there anyone who could help me translate
    this:
    onClipEvent (load) {
    diff_y = bound_box._height-scroller._height;
    bounds = bound_box.getBounds(this);
    top = bounds.yMin+(scroller._height/2);
    bottom = bounds.yMax-(scroller._height/2);
    function updateScrollbar () {
    content._y =
    -(((scroller._y-top)/diff_y)*(content._height-bound_box._height));
    onClipEvent (mouseDown) {
    if (scroller.hitTest(_root._xmouse, _root._ymouse)) {
    startDrag ("scroller", false, scroller._x, top, scroller._x,
    bottom);
    scrolling = true;
    // here we stop the drag and set scrolling to false
    onClipEvent (mouseUp) {
    stopDrag ();
    scrolling = false;
    onClipEvent (enterFrame) {
    if (scrolling) {
    updateScrollbar();

    you have a 4 enterframe loops running continually when they
    only need to run after a menu item has been clicked and can stop
    after all menu items have reached their final positions.
    and you need to compute the final positions for each menu
    item after one of them is clicked.
    you might do better to check for an as3 tutorial for an
    accordian menu. it's a bit more involved than you're thinking.

  • Converting short code from as2 to as3

    Some of these functions wont work in as3, and i would like it to be using gestures instead of mouse clicks.. Any help please?
        _root.attachMovie("brush","brush",10)
        _root.brush.onEnterFrame=function()
              Mouse.hide()
              startDrag(this,true)
              new Color (this.brushColor).setRGB(_root.brushColor)
        on(press)
              new Color(this).setRGB(_root.brushColor)
        onClipEvent (load) {
              myColor = 0x0000CC
              new Color(this).setRGB(myColor);
        on (release) {
              _root.brushColor= myColor;

    no code should be attached to objects.
    most of that looks like it's useless or worse than useless.   in particular, everything in the enterframe loop looks like it serves no purpose and repeatedly does useless things.  if it is doing something useful, it doesn't need to be done in a loop.
    and setting the rgb of a color instance does nothing useful.
    the only thing useful is setting brushColor when that brush movieclip is clicked.
    so, if you have a movieclip with class = "brush" in your library, you can use:
    var brushColor:uint;
    var blackBrush:brush=new brush();
    blackBrush.col = 0x000000;
    addChild(blackBrush);
    blackBrush.addEventListener(MouseEvent.CLICK,clickF);
    function clickF(e:MouseEvent):void{
    brushColor = MovieClip(e.currentTarget).col

  • Use this As2 in As3

    Hello,
    i have this code
    var url = _level0.video;
    player.contentPath = url;
    this catch a url and load on flash player.
    this works fine in As2, but in As3 dont work.
    i use a converter As2 to As3 but the result is it:
    package  {
        var url = _level0.video;
        player.contentPath = url;
    i not a As programmer i only use video function on flash,
    my question is, how to use my code on ActionScript 3 ??
    Thank you !!

    Thanks for reply,
    the variable video i get from html and php.
    example:
    player.swf?video=<?php echo $_GET["video"]; ?>
    and the variable video i get from html
    <a href="index.php?video=video.flv"></a>
    ok, i discard a converter !!
    to use a contentPatch source of flash ?
    but i can load a external videos ??
    without ActionScript ?
    Thank you !

  • Trying to convert as1 code to as3

    Hi,
    I have to convert a as1 site to as3.
    The only part of the whole thing that i'm not sure of is this:
              on(release){
                        loadvariables ("save.aspx?cmd=addemail&adresse=" add string(adresse.text),this)    
                        Object.prototype.alert = function (message) {
                              getURL("javascript:alert('"+message+"')");
                   alert("We received your email, thank you.");
                   adresse.text="";
    It's basically a newsletter subscription box done in as1.
    Will the same code work if I only include it in a as3 MouseEvent.CLICK like this:
    function btn_click(event:MouseEvent):void {
              loadvariables ("save.aspx?cmd=addemail&adresse=" add string(adresse.text),this)    
              Object.prototype.alert = function (message) {
                    getURL("javascript:alert('"+message+"')");
         alert("We received your email, thank you.");
         adresse.text="";
    Thanks

    Thanks Ned for guiding me.
    I looked into both (URLLoader / ExternalInterface) and I came up converting the original As1 code:
    on(release){
    loadvariables ("save.aspx?cmd=addemail&adresse=" add string(Adresse.text),this)    
    Object.prototype.alert = function (message) {
    getURL("javascript:alert('"+message+"')");
    alert("We received your email, thank you.");
    Adresse.text="";
    into this As3 code:
    lbl.text = "ExternalInterface.available: " + ExternalInterface.available;
    var myLoader:URLLoader;
    var myVars:URLVariables;
    var Response:String = "We received your email, thank you.";
    //////////////////////////////////////////////////////////////////////////////This is my button
    button.enabled = ExternalInterface.available;
    button.addEventListener(MouseEvent.CLICK, sendEmail);
    /////////////////////////////////////////////////////////////////////This is Onclick
    function sendEmail(e:MouseEvent):void
        myLoader = new URLLoader();
        myVars = new URLVariables();
        myLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
        myVars.email = Adresse.text; // Text from textfield
        myLoader.data = myVars;
        myLoader.addEventListener(Event.COMPLETE, messageSent, false, 0, true);
        myLoader.load(new URLRequest("save.aspx?cmd=addemail&adresse="+myVars.email));
    ///////////////////////////////////////////////////////////////This is the response
    function messageSent(e:Event):void
        ExternalInterface.call("alert", Response);
        Adresse.text="";
    The thing is that I don't have access to the server and aspx file and i'd just like to make sure i'm heading in the right direction so far.

  • Major gaming system Migration from AS2 to AS3

    I have a major project entirely in AS2. It is made of a
    Multimedia Application, which provides access to functions needed
    to load games, save information, insert *.jpg files... The 50+
    games each have their own graphic.swf and engine.swf, where the
    graphics deal with gameplay and the engine communicates with the
    Multimedia Application.
    If the Multimedia Application is migrated to AS3 but the game
    swf files remain the same, will the functions still be able to
    communicate (call functions and send references to objects)?

    No, AS2 and AS3 are absolutely different animals. There are
    some techniques (search for as2 as3 bridge in the net) that create
    a bridge which are cumbersome in my view.

  • As2 and As3 on same Flash Player

    If i set AS2 codes to play in Flash Player 9, is it possible
    that this swf can load an As3 swf at the same Flash Player using
    As2 codes???
    These swfs both play in same virtual machine which is player
    version 9 but the other is coded with As2 and the other is coded
    with As3. How can an AS2 load a swf coded in AS3 on same Flash
    player?
    Is this possible?
    If yes, how? if no, why not?

    AS2 and AS3 swfs cannot exist in the same Flash Player
    virtual machine - each Flash Player instance (version 9 and
    greater) create different address spaces/virtual machines because
    the requirements of AS3 and AS2 are so different.

  • AS2 with AS3 integration

    Hi.
    I have loads of games in AS2 but a freelancer is developping games in AS3. Can I use a container movie in AS3 and load both AS2 and AS3 games in. Otherwise I would have to update all games into AS3. Would all games have to be published to the same flashplayer? ie: FS7 etc...

    you can use an as3 swf to load as2 swfs.  if you need to communicate between the two swfs, use the localconnection class.

  • AS2 to AS3 Streaming Video Player

    Ok so Im trying to convert a video play that i made in AS2 to
    AS3 (I had a problem with nested movie clips and the control bar
    and i want to learn AS3) and i am having troblem even connecting to
    my rtmp server. With the player i made in AS2 i was able to connect
    and stream video no problem. But with AS3 I am not even able to
    connect to the rtmp server. Here is the AS2 code and the AS3 code:
    AS3:
    var video:Video = new Video(853,480);
    addChild(video);
    var nc:NetConnection = new NetConnection();
    nc.connect("rtmp://[ip of server]/sumone4life/videos");
    var ns:NetStream = new NetStream(nc);
    ns.addEventListener(NetStatusEvent.NET_STATUS,
    onStatusEvent);
    function onStatusEvent(stat:Object):void
    trace(stat.info.code);
    var meta:Object = new Object();
    meta.onMetaData = function(meta:Object)
    trace(meta.duration);
    video.attachNetStream(ns);
    ns.play("AdobeBand_640");
    And I get the error:
    ArgumentError: Error #2126: NetConnection object must be
    connected.
    at flash.net::NetStream/construct()
    at flash.net::NetStream()
    at videoPlayer_fla::MainTimeline/frame1()
    Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095:
    flash.net.NetConnection was unable to invoke callback onBWDone.
    error=ReferenceError: Error #1069: Property onBWDone not found on
    flash.net.NetConnection and there is no default value.
    at videoPlayer_fla::MainTimeline/frame1()
    Flash media server 3 Administrative Panel also shows that I
    am infact connected to the server but there is nothing being
    streamed from the server.
    AS2 Works:
    //Video Loading Controls
    var fileName:String = "AdobeBand_640";
    var nc:NetConnection = new NetConnection();
    var ns:NetStream;
    nc.onStatus = function(info){
    trace(info.code);
    if(info.code == "NetConnection.Connect.Success"){
    playVideo();
    function playVideo(){
    ns = new NetStream(nc);
    ns.onMetaData = onMetaDataHandler;
    videoObject.attachVideo(ns);
    _root.createEmptyMovieClip("vSound",
    _root.getNextHighestDepth());
    vSound.attachAudio(ns);
    ns.setBufferTime(5);
    ns.onStatus = function(info){
    trace(info.code);
    if(info.code == "NetStream.Buffer.Full"){
    bufferClip._visible = false;
    if(info.code == "NetStream.Buffer.Empty"){
    bufferClip._visible = true;
    if(info.code == "NetStream.Play.Stop"){
    ns.seek(0);
    ns.play(filename);
    //connects the stream
    nc.connect("rtmp://[ip of server]/sumone4life/videos");
    Can anyone offer any insite as to why it would be workin in
    AS2 and not in AS3? Or what i am doing wrong...

    I have a similar problem. Did you get your to work?

  • Please help 'Translate' These codes from AS2 to AS3 for me

    Hi, i need help 'translating' these codes from Action Script 2 to Action Script 3. Please Do it for me:
    toc    loadText = new LoadVars();
        loadText.load("Curie.txt");
        loadText.onLoad = function(success) {
            if (success) {
                // trace(success);
                Curie.html = true;
                Curie.htmlText = this.Curie;
    Please translate it for me, i need it ASAP thanks
    Kenneth

    Thank you for helping me
    Kenneth
    Date: Thu, 15 Oct 2009 05:49:14 -0600
    From: [email protected]
    To: [email protected]
    Subject: Please help 'Translate' These codes from AS2 to AS3 for me
    Take a look at that:
    http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/migration.html
    There is a LoadVars section on that.
    There is also a tutorial here:
    http://www.republicofcode.com/tutorials/flash/as3externaltext/
    Cheers,
    CaioToOn!
    >

  • Looking for a copy of Patrick Mineault's AS2 to AS3 converter.

    Anybody have a copy of Patrick Mineault's AS2 to AS3 converter sitting around?  His website closed down in May and he changed careers.
    Thanks!

    See if this is it:
    http://download.info.apple.com/Apple_Support_Area/Manuals/powerbooks/0301677CPBU G.PDF

  • Convert code AS2  to  AS3

    Plz any one convert this code from AS2 to AS3???????reoly me on [email protected]
    #initclip
    function Dot() {
        this.color = new Color(this);
        this.color.setRGB(16775372);
        this._rotation = 150;                        /////////////////rotate of object////////////////
        this._width = 30;                        /////////////////width of object////////////////
        this._height = 30;                            /////////////height of object//////////////
        this._x = 300+Math.random();//*8-0(X vibration type effect)            /////////////X position of object//////////
        this._y = 250+Math.random();//*8-0(Y vibration type effect)            /////////////Y posotion of object///////////   
    Dot.prototype = new MovieClip();
    Object.registerClass("myfirst", Dot);
    Dot.prototype.onEnterFrame = move;
    function move() {
        this.age++;
        this.relage=this.age/12;
        R=255<<16;
        G=(255-(this.relage*126)); if (G<0) G=0; G=G<<8;
        B=(255-(this.relage*1024)); if (B<0) B=0;
        this.color.setRGB(R+G+B);
        this._x -= Math.random()*-2-1.25;
        this._y -=Math.random()*+1.75;
        this._alpha -= 3;
        this._xscale -= 2;
        if (this._alpha<5) {
            this.removeMovieClip();
    #endinitclip

    Just remove #initclip and #endinitclip from the code and remove all underscores, example : this._x will be this.x
    Hope this helps!

  • Convert AS2 To AS3

    So I made this basic game a few years ago which was in AS2 and Flash 6.  Now I want to convert this game from AS2 to AS3 but I have no idea where to start.  The code is approximalty 4k lines long and I don't know what to change to make it work in AS3.  What do you guys suggest?

    Are you using external .as files and classes or are you using frame scripts directly in the timeline? Are you used to any other object oriented programming languages? Knowing more about other languages you might know would help a lot.
    AS2 very informal and specialized to Flash. It relates to pretty much no other language out there, like JavaScript seldom relates. They're c-esque but only in a very distant 3rd cousin style.
    AS3 is much more OOP oriented and typed versus the less formal, error-prone loose dynamic nature of AS2. While your game would benefit greatly from the speed increases and error reduction, I think you're really swinging for the fence on this one. While some classes may resemble their AS2 counterpart and the core global functions work the same, everything else is different. Starting off trying to convert 4,000 lines of code is a little steep.
    As mentioned, the resources to learn AS3 are excessive and plentiful from video training to tutorials to the API reference itself. Google has it all.
    I think you really should lower your target and just try some really simple, basic things. Draw a shape, add a listener, do something basic when clicked, etc. You'll get a good idea of how different things are with the new display list rather than tearing your hair out converting your as2 game.

  • HTML Link -AS2 fine, AS3 weird behaviour

    Hi Guys, I'm working on a project at the moment, and am
    seeing weird behaviour with the way my swf handles html links
    inside dynamic textboxes. When rendered as a AS2 file, the link
    works on a release as expected. When its inside a AS3 file the link
    will only work if the user right click and chooses 'open in new
    window' was there a change in behaviour how AS3 handles these
    links, or is there now an declaration needed to be made to allow
    these link to have the old behaviour?
    The project calls for xml data and embedded in that is a html
    link. Originally I thought it might have been the way I'd formed
    the xml so I tried with a hardcoded version instead (dynamic
    textbox, add text -> highlight -> add link through properties
    tab). But I still see the same behaviour between the as2 and as3
    versions.
    Any help would be greatly appreciated.
    Cheers.

    Actually, the ''href'' attribute is supposed to direct the browser to a new URL, etc., not run a script. Instead, use the ''onclick'' event attribute:
    ''<a onclick = “$('.div-feedback').fadeIn();”></a>''.
    Happy coding!

  • Issues converting scroll bar components from AS2 to AS3

    I am working on editing a document that has scroll bar components that I would like to convert from AS2 to AS3 since everytime I try to open the document it shows a WARNING and won't convert them and when I publish and look at the final document the scroll bar seems to act unusally since it is obviously still on AS2.
    Here are two of the scripts I finally was able to find within it. Should I fix it and how so? This first is for the "Creative Scroll Area" and the second is for the "Creative Scrollbar"
    package  {
              import flash.display.MovieClip;
              public class Creative Scroll Area extends MovieClip {
                        public function Creative Scroll Area() {
                                  // constructor code
    package  {
              import flash.display.MovieClip;
              public class Creative Scrollbar extends MovieClip {
                        public function Creative Scrollbar() {
                                  // constructor code

    Okay, well I know the code is making a scroll bar and a scroll area and under the "type" it says they are "compiled..." which is unusual since most of the other components I've worked with have been movie clips or bitmaps. Do I need to look up what AS3 components I need to replace the script from above? Because when I looked for that I couldn't specifically find what I needed or really understood if I was looking at the right information.
    Here is something I found when trying to "debug" it:
    WARNING: The component 'UIScrollBar' requires ActionScript 2.0, which is not supported in this version of Flash Professional.
    WARNING: The component 'Creative Scrollbar' requires ActionScript 2.0, which is not supported in this version of Flash Professional.
    WARNING: The component 'Creative Scroll Area' requires ActionScript 2.0, which is not supported in this version of Flash Professional.

Maybe you are looking for