Converting small amount of AS2 to AS3

Hi All,
I’m struggling to convert this block of AS2 code into AS3. It is a Netstream video component and I have made the scrubber able to be dragged anywhere inside the player. (Vertical and Horizontal). The scrubber is also coded so that it controls the frame position of the player (I have links that appear at certain points to load in other videos)
Here is the as2 version; http://websites.danielnwilliams.co.uk/crankmedia/
Im just trying to convert this as2 code to as3;
MovieClip.prototype.scrubbb2 = function (x)
    var f2:Number = Math.round (this._totalframes * x);
    this.gotoAndStop (f2);
var isPlaying2:Boolean = true;
var scrubInterval2;
function scrubit2() {
    ns2.seek(Math.floor((scrubmain.scrubbuttonmain._x/760) * duration2));
scrubmain.scrubbuttonmain.onPress = function() {
    ns2.pause();
     if (isPlaying2) {
             ns2.pause(true);
              scrubmain.scrubbuttonmain.cog_pausemain._visible = true;
            scrubmain.scrubbuttonmain.cog_playmain._visible = false;
            trace("paused");
              isPlaying2 = false;
   } else {
              ns2.pause(false);
             scrubmain.scrubbuttonmain.cog_pausemain._visible = false;
            scrubmain.scrubbuttonmain.cog_playmain._visible = true;
            trace("playing");
             isPlaying2 = true;
    clearInterval(videoInterval2);
    scrubInterval2 = setInterval(scrubit2,10);
    this.startDrag(false,0,-392,760,0);
    this.onMouseMove = function()
        var x:Number = this._x;
        scrubbb2 (x / 760);
scrubmain.scrubbuttonmain.onRelease = scrubmain.scrubbuttonmain.onReleaseOutside = function () {
    clearInterval(scrubInterval2);
    videoInterval2 = setInterval(videoStatus2,100);
        this.stopDrag();
Finding this chunk really hard to to so, so would really appreciate it if someone could help me out!
Much appreciated
Dan

It is unlikely that someone would be able/willing to attempt the full conversion. No only it is time consuming - there are some things in your AS2 version that are not straight forward.
Here is a link that may help you:
http://livedocs.adobe.com/flex/201/langref/index.html?migration.html&all-classes.html
Also, read about MouseEvent for this is how you enable buttons functionality.

Similar Messages

  • Convert simple code from as2 to as3

    Hello, i am looking for some help here for something simple (i think)
    var txt:String = link1;
    btn.onRelease = function():Void {
    if( sample_id )
    getURL("http://www.website.com/registration?partner_id=" + sample_id + "sampleURLCode", "_blank");
    else
    getURL("http://www.website.com/registration?sampleURLCode", "_blank");
    Is there a way to make this simple code into AS3?

    Hi, Apparantly that's because the 'link1' and 'sample_id' variables are not within the scope of the code you posted above, Perhaps you have defined them outside on a different frame or class. You can either define them with the same code like:
    var sample_id:Number=1234;  //Use your own variable type and value here
    var link1:String = "your string or link URL here";
    var txt:String = link1;
    btn.addEventListener(MouseEvent.CLICK, gotoURL);
    function gotoURL(e:MouseEvent)
    if( sample_id )
          navigateToURL(new URLRequest("http://www.website.com/registration?sample_id=" + sample_id + "sampleURLCode"),"_blank");
    else
          navigateToURL(new URLRequest("http://www.website.com/registration?sampleURLCode"),"_blank");
    Or you can put a direct reference to your existing variable like (If your variables are defined on root/frame 1) :
    var link1:String = "your string or link URL here";
    var txt:String = MovieClip(this.root).link1;
    btn.addEventListener(MouseEvent.CLICK, gotoURL);
    function gotoURL(e:MouseEvent)
    if( MovieClip(this.root).sample_id )
          navigateToURL(new URLRequest("http://www.website.com/registration?sample_id=" + sample_id + "sampleURLCode"),"_blank");
    else
          navigateToURL(new URLRequest("http://www.website.com/registration?sampleURLCode"),"_blank");
    try that, or you can share your .fla !
    cheers

  • 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

  • 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.

  • 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

  • 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.

  • Adobe Audition 3.0.1 - Saving/Converting WAV's to MP3 adds small amounts of time to my MP3 files !!?

    Hello.
    I am new to the Forum, but turning to the masses out there for help with a weird one!
    I have used Adobe Audition for YEARS. I do a lot of converting of my finished WAV files to Mp3 files. The finished WAV's have always been in 48000Hz, 16 bit Stereo, and are always mixed to the specified time (e.g. 15, 30 or 60 seconds duration). These are then converted to mp3 files, using the 'Save As' option, choosing the 'Save As Type' as mp3PRO (Fhg) (*.mp3) option.
    My conversion settings have always been:
    CBR, mp3, 320Kbps 48000Hz Stereo (4:8:1), Maximum bandwith = 24000Hz, CBR Rate = 320, Sample Rate = 48000Hz, Codec = Current - Best Quality, Allow mid-side joint stereo, allow intensity joint stereo, Set 'Private' Bit, ISO Padding, Write CRC Check Sums.
    ...Now, for some strange reason, ever since last night, whenever I do the above process - the resulting mp2 file seems to ADD ON little bits of time...from 0.048 of a second to around 0.168 of a second..!!??? So to further clarify: If I convert a 15 second WAV file to mp3 - the resulting mp3 file ends up being slightly longer in duration at: 15.168 seconds..???
    This has never happened before. And, a solution has got me beat.
    I have tried different conversion settings, different configurations - even saving the initial WAV as a lower sample rate - but, no joy.
    I have an old version of Adobe Audition 2.0 on a different machine - and guess what?! Even IT does this same weird thing now too.
    It doesn't seem to matter if I REC and convert new files or convert old files - same problem.
    Even opening up mp3 files - that I KNOW were spot on for time - now also have these little bits of extra time added to them, once they are openned...??? What the...!!??
    I spent over half an hour on the phone with Adobe Tech support, earlier this afternoon. They got me to reset all of my user configuration files - but, didn't slove the issue!
    PLEASE:     Has anyone experienced this same conversion issue..? I would also be interested to know, if anyone else replicates these conversion settings, if they get the same problem..?
    Could this be one of those good old Windows update things..?
    Does anyone know if there are updates available for Auditions built-in mp3PRO encoder / decoder..?
    PLEASE HELP !!!
    Thank you, in advance.
    John.

    Well I don't know how you've missed this before, but it's always done it. It's a throwback to Syntrillium days, when it was discovered that some MP3 players managed to cut off the starts and finishes of MP3 files. The developers got around this by adding a small amount of silence when coding an MP3. Originally, Audition's loop files were MP3-based as well, but these didn't have the added silence, because obviously that would screw up the looping a treat. But as far as I'm aware, even though players are better now (aren't they???), the additional silence remains.
    I'm not surprised that the help desk doesn't know about this - it's a bit subtle. And with the best will in the world, they only have the crib sheets they're given, and they certainly don't cover everything that happens.

  • Pls. help on AS2 to AS3 convertion for #initclip and Object.registerClass

    Hi Friends,
    I have converted most of the as2 code to as3 but I am stuck with the below kind of codes where the code looks like #initclip and some number next to it and inside it Object.registerClass("some reference", some reference); and ending with #endinitclip
    Below is an example of what I am talking about.
    #initclip 45
    Object.registerClass("Border", mx.skins.Border);
    #endinitclip
    Thanks in advance.
    With Regards,
    Sagar S. Ranpise

    SOLVED:
    Hey Friends,
    I was able to solve the issue. Since no one was able to give me answer, I think most of you might not be knowing the solution.
    Hence posting it below. All I have done is Added Event listener to instance name of movieclip and in the function I have imported the class the object.registerclass was refering and below import I created a new scrollbar instance and added that to my movieclip which solved the issue.
    Let me know what you think?
    boundingBox_mc.addEventListener(Event.ADDED_TO_STAGE, scrollbarFunction);
    function scrollbarFunction(e:Event):void
         // Import the class.
          import mx.controls.UIScrollBar;
          // Create the scrollbar
          var scroller:UIScrollBar = new UIScrollBar();
           boundingBox_mc.addChild(scroller);
    //Object.registerClass("UIScrollBar", mx.controls.UIScrollBar);

  • Help Converting AS2 to AS3 Drag and Drop Event

    Hi All,
    This is the second post on help for converting AS2 to AS3. This code is used in Captivate to allow a drag and drop action between two areas (User presses down, drags, and releases in a second area - They are not dragging any object). If anyone can help me convert this please let me know.
    Source for Drag and Drop: (Note: Single MovieClip)
    // pause the Captivate movie
    _root.rdcmndPause = 1;
    // when the user's mouse is let go check if there was a successful drop
    _root.onMouseUp = function(){
              // If the source area's center coordinate is nearby the destination area's center coordinate then advance the slide
              if ( Math.abs(_root.sourceX + _root.sourceWidth  / 2 + _root.sourceParentX - (_root.destX + _root.destWidth  / 2)) < (_root.destWidth  / 2) &&
                         Math.abs(_root.sourceY + _root.sourceHeight / 2 + _root.sourceParentY - (_root.destY + _root.destHeight / 2)) < (_root.destHeight / 2) )
                        _root.rdcmndNextSlide = 1;
              } else {
                        // show error movie clip for 2 seconds (60 frames at 30 frames per second)
                        _root.showErrorMessage = 60;
      mc.onEnterFrame = function(){
              // continuously update the source area's coordinates and size
              _root.sourceX = mc._x;
              _root.sourceY = mc._y;
              _root.sourceWidth = mc._width;
              _root.sourceHeight = mc._height;
              _root.sourceParentX = _parent._x;
              _root.sourceParentY = _parent._y;
    mc.onPress = function(){
              // Uncomment following line to have control click capabilities
              //if(key.isDown(Key.CONTROL))
              // when user clicks on the source area click start the drag
                        startDrag(this);
    mc.onRelease = function(){
              // stop drag when user releases the source area
              stopDrag();
    Source for Destination Area (Single MovieClip named destArea)
    // Set a root variable to control when the error message is displayed
    _root.showErrorMessage = -1;
    // Use setCoords variable so we only set the destination coordinates once
    var setCoords = 0;
    destArea.onEnterFrame = function(){
              if (setCoords == 0){
                        // set the destination x, y, width, and height
                        _root.destX = _parent._x;
                        _root.destY = _parent._y;
                        _root.destWidth = _parent._width;
                        _root.destHeight = _parent._height;
              // destination coordinates have been set, change setCoords so it doesn't get set again
              setCoords = 1;
    Code for the Error Message (Single MovieClip named errorMessage)
    // Don't display the error message initially
    errorMessage._alpha = 0;
    errorMessage.onEnterFrame = function (){
              // If the drag and drop method detects a missed drop
              // then show this error message by setting _alpha to 100
              if (_root.showErrorMessage > 0){
                        errorMessage._alpha = 100;
                        // decrementing this variable controls the time the
                        // error message will be displayed
                        _root.showErrorMessage--;
              } else {
                        // Don't display the error message
                        errorMessage._alpha = 0;

    use:
    MovieClip(parent.parent.parent).rdcmndPause=1;
    this.addEventListener(KeyboardEvent.KEY_DOWN,keydownF);
    function keydownF(e:KeyboardEvent):void{
    fscommand("KEYPRESSED", e.keyCode);
    if(e.keyCode==32){
    MovieClip(parent.parent.parent).rdcmndNextSlide=1;

  • 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 !

  • Preloader (from as2 to as3)

    Hey ladies and gentlemen
    I'm currently converting one of my project to as3 and I hit a
    wall with this preloader problem.
    Before, with as2, I was using getBytesLoaded() and
    getBytesTotal() in a frame loop to display a progress bar and know
    when the loading was finished. I can't seem to find how to do this
    in as3.
    I read as3 language reference and some examples but they all
    deal with loading an external swf or file.
    I would think that the main swf would trigger progress events
    as it gets loaded so I made this little piece of code, which
    doesn't work.
    function ProgressHandler(theEvent:ProgressEvent)
    trace("bytes Loaded: " + theEvent.bytesLoaded + "
    bytesTotal: " + theEvent.bytesTotal);
    addEventListener(ProgressEvent.PROGRESS, ProgressHandler);
    stop();
    Can anyone point me back in the right direction?
    Thanks

    I just wanna make it clear that I'm trying to preload the
    main swf itself, I still can't find anything on the net about that.
    Anyone?
    Thanks!

  • Declare new color from AS2 to AS3

    Hi All,
    Could you let me know how to "convert" the following code from AS2 to AS3:
    var distracterBkgdColor = new Color(this.distracterBkgd_mc);
    Thanks!

    var ct:ColorTransform = this.distracterBkgd_mc.transform.colorTransform;ct.color = 0xrrbbgg;
    this.distracterBkgd_mc.transform.colorTransform=ct;

  • Break apart a small amount of text, or embed font?

    Hi
    I have a small amount of text (20 words) that use a hand written type font.
    This is for a mobile app, so should I embed the font, or break apart twice to convert it to shapes?
    Cheers

    If it is not dynamic text, use static textfields and you should not have to worry about embedding... "should" being a significant word.  If you find that it is not displaying properly as static text then I'd go with the conversion to shapes just to put it to bed.

  • 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?

Maybe you are looking for