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 !

Similar Messages

  • Convert simple animation code from as2 to as3

    Hi everyone,
    I have a simple animation that is controlled by the y movement of the mouse. The code for the animation is put in frame 1 and is as follows:
    var animationDirection:Boolean = false;
    var prevMousePosition:Boolean = false;
    var mouseListener = new Object();
    mouseListener.onMouseMove = function () {
    var curMousePosition = _ymouse;
    if(curMousePosition > prevMousePosition) {
    animationDirection = false;
    }else if(curMousePosition < prevMousePosition) {
    animationDirection = true;
    prevMousePosition = curMousePosition;
    Mouse.addListener(mouseListener);
    function onEnterFrame() {
    if(animationDirection && _currentframe < _totalframes) {
    nextFrame();
    }else if(!animationDirection && _currentframe > 1) {
    prevFrame();
    Is it possible to use this code in as3 or do I need to convert it? I am grateful for any help. Best wishes

    Yes, you need to convert the code. Here is what looks like a similar logic in AS3:
    import flash.events.Event;
    import flash.events.MouseEvent;
    var animationDirection:Boolean = false;
    var prevMousePosition:Boolean = false;
    addEventListener(Event.ENTER_FRAME, onEnterFrame);
    addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
    function onMouseMove(e:MouseEvent):void {
        var curMousePosition = mouseX;
        if (curMousePosition > prevMousePosition)
            animationDirection = false;
        else if (curMousePosition < prevMousePosition)
            animationDirection = true;
        prevMousePosition = curMousePosition;
    function onEnterFrame(e:Event):void
        if (animationDirection && _currentframe < _totalframes)
            nextFrame();
        else if (!animationDirection && _currentframe > 1)
            prevFrame();

  • How to use this example code in Flash AS3?

    Hi,
    How can I use this AS3 code in my Flash CS4 document? The following code is in the below link:
    http://pv3d.org/2009/12/18/tweenmax-tweening-a-timeline-advanced-tweening/#
    Please help.
    Thanks.

    Hi,
    It is working quite nice. I want to use the same code but instead of as "Document Class" I want to put that code in a first key frame of my project. I tried the following but gets an error:
    The error is : 1131: Classes must not be nested.
    And the following code  I tried is:
        import com.greensock.TimelineMax;
        import com.greensock.TweenMax;
        import com.greensock.easing.Linear;
        import com.greensock.easing.Quart;
        import flash.display.Sprite;
         * @author John Lindquist
        [SWF(width="900", height="480", frameRate="31")]
        class EasingATimeline extends Sprite
            private var square:Sprite;
            private static const STEP_DURATION:Number = 1;
            public function EasingATimeline()
                square = new Sprite();
                square.graphics.beginFill(0xcc0000);
                square.graphics.drawRect(0, 0, 50, 50);
                square.graphics.endFill();
                square.x = 100;
                square.y = 50;
                addChild(square);
                //set all the eases of your steps to Linear.easeNone
                var step1:TweenMax = TweenMax.to(square, STEP_DURATION, {x: 700, y: 50, ease: Linear.easeNone});
                var step2:TweenMax = TweenMax.to(square, STEP_DURATION, {x: 700, y: 350, ease: Linear.easeNone});
                var step3:TweenMax = TweenMax.to(square, STEP_DURATION, {x: 100, y: 350, ease: Linear.easeNone});
                var step4:TweenMax = TweenMax.to(square, STEP_DURATION, {x: 100, y: 50, ease: Linear.easeNone});
                var timeline:TimelineMax = new TimelineMax();
                timeline.append(step1);
                timeline.append(step2);
                timeline.append(step3);
                timeline.append(step4);
                //pause your timeline
                timeline.pause();
                //tween your timeline with whatever ease you want
                TweenMax.to(timeline, timeline.totalDuration, {currentTime: timeline.totalDuration, ease: Quart.easeInOut, repeat: -1});
    Please help me to solve this problem.
    Thanks.

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

  • As2 to as3 the class or interface 'MouseEvent' could not be loaded

    im using as2 but the scripts are supposed to be in as3
    here's the code in as3:
    for (var i:int=0; i<10; i++){
              var newFood:mcFood=new mcFood();
              newFood.buttonMode=true;
              newFood.x = (Math.random()*510);
              newFood.y = (Math.random()*310);
              if(newFood.x>550){
                        newFood.x -=530;
              if(newFood.y>550){
                        newFood.y -=530;
              addChild(newFood);
              newFood.addEventListener(MouseEvent.MOUSE_DOWN, mousePressed);
              newFood.addEventListener(MouseEvent.MOUSE_UP, mouseReleased);
    function mousePressed(myVar:MouseEvent):void{
              myVar.target.startDrag();
    function mouseReleased(myVar:MouseEvent):void{
              myVar.target.stopDrag();
              if(myVar.target.hitTestObject(star)){
                        myVar.target.x = -300;
                        myVar.target.y = -30;
    could anyone transform this into as2?

    Basically Sir I do not have any background in using the as2. Since I started using the as3.
    Hmm actually the code up there works fine, but when I add the character to the as3 and try to run it, it says that the the button will be ignored.
    https://www.dropbox.com/s/l88ztx7o9qipbbw/asasasa.fla

  • What is mean this words in as3

    i am new to as3 please help me about this words and how can i use it
    _root
    Math.atan2
    onEnterFrame
    Math.sqrt
    and the word " this " in as3
    *and what is the difference between this words ?
    _x and x
    _xmouse and mouseX
    _rotation and rotation

    _root (as2) = MovieClip(root)  (as3)
    Math.atan2 (as2) = Math.atan2 (as3)
    onEnterFrame (as2) = addEventListener(Event.ENTER_FRAME,somefunction);
    Math.sqrt (as2) = Math.sqrt (as3)
    this (as2) = this (as3)
    _x (as2) =  x (as3)
    _xmouse (as2) =  mouseX (as3)
    _rotation (as2) =  rotation (as3)

  • Translating AS2 to AS3

    Hi.
    Below I have a bit of code that determines the bandwidth that a user has.  It is written in ActionScript 2.  The problem is that I am unfamiliar with AS2, and I wanted to use this in conjunction with a live streaming video player built in AS3.  I was wondering if anyone could give me the equivalent code in AS3, or if there's any way to tell flash that a portion of the code will be written in AS2.
    Thank You,
    Ari Amiri
    nc = new NetConnection();
    nc.onStatus = function(info) {
        trace("Level: "+info.level+" Code: "+info.code);
        if (info.code == "NetConnection.Connect.Success") {
            trace("--- connected to: " + this.uri);
    nc.onBWDone = function(kbitDown, deltaDown, deltaTime, latency) {
        trace("onBWDone: kbitDown:"+kbitDown+" deltaDown:"+deltaDown+" deltaTime:"+deltaTime+" latency:"+latency);
        // app logic based on the bandwidth detected follows here
        detected_bw = kbitDown;
        // close the Netconnection to bwcheck
        this.close();
    nc.onBWCheck = function() {
        trace("onBWCheck");
        return ++counter; // Serverside, just ignore any return value, For now return the call count
    nc.connect("rtmp://216.18.231.42/bwcheck", true);
    stop();

    Thanks kglad. However, my preloader doesn't seem to work
    quite properly. The graphic that I want to fill up as the movie
    loads does not appear for a while, then suddenly fills up and just
    sits there for a while until the movie is displayed. Do you know
    why this might be?

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

  • Anyone: as2 vs as3?

    was looking at summerLongSince's post, basic as3, and it
    occurred to me that the as3 version of what had been previously
    done using as2 was more complicated and involved (see script
    below). i am still relatively new to actionscripting and am
    currently using/learning as2, so i am ignorant to the benefits as3
    has to offer at this point. could anyone tell me what benefits the
    as3 code below has over the as2 that precedes it? they both seem to
    accomplish the same goal, only as3 seems to take more time and code
    to do so. also, is moving to as3 worth the hassles that come with
    learning an entirely new scripting language? i haven't even
    mastered as2 and the thought of losing all the work i have put in
    thus far is somewhat sickening. lastly, couldn't as3's benefits
    have been implemented into flash without restructuring the entire
    programming language?
    thanks in advance,
    _name

    AS 3.0 comes with great features and 10 time faster than AS
    2.0. you may find some link on adobe.com site.
    for your current code. see this.

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

  • AS2 or AS3

    Hello, i'm somewhat decent in flash. I know AS2, i started
    learning AS3 today and find it to be more complicated and has so
    many extra steps in coding. Number one thing i hate is having to do
    all the code on the timeline, it will get so full of code if i have
    several buttons/movieclips that need code, no way to do code when
    you click on the button/movieclip in AS3 unlike 2.
    Would it be dumb for me to continue to use AS2 and learn more
    of it, or should i keep trying to learn AS3..... I don't do super
    complex stuff, mostly timeline navigation and animations.
    I also feel like there is way more room to make errors in 3
    because you have to type everything unlike AS2 where i was able to
    use the actions frame (use that plus tool that had the drop down
    menu).

    I'm in the same position, just starting to move from
    intermediate comfort with AS2 to a fresh beginning with AS3...not
    so easy for a guy who has so little logical thinking that I failed
    algebra in high school! I too am a bit annoyed by all the extra
    steps involved, such as having to add EventListeners for mouse
    events, when these really ought to be simplified and there by
    default, like in AS2. For example, why can't onMouseDown remain as
    a built-in behavior rather than having to take up 2 lines of code
    to insert it each and every time now?
    On the other hand, I am delighted at the way a lot of the
    inconsistencies in AS2 have been gotten rid of. No more having to
    remember when to put .x and when ._x, and so on. And now that I'm
    finally starting to learn how to use external classes, I see the
    beauty in it, and AS3 is custom-made for this. It seems that if you
    ever want to really advance in ActionScript programming, you need
    to start working with creating your own classes, and as long as
    you're going to learn those from scratch, may as well learn it in
    AS3.
    Putting AS on buttons was outdated practice years ago. It
    makes much greater sense to place all script on the timeline, with
    comments to separate it. Try programming the simplest game where
    objects are moving around and colliding, all controlled by script,
    and then a couple coded buttons control them. Bugs are inevitable,
    and debugging script when it's partly on the timeline, some is
    attached to main movie buttons, and some attached to movie clips
    inside movie clips, is a nightmare. Once you do scripting on the
    timeline, you'll never want to go back to the crude practice of
    attaching script to objects.
    Overall, it's a steeper climb than I'd have liked, to upgrade
    my knowledge from AS2 to AS3. But ultimately I think it's the best
    idea.

  • Translation from AS2 to AS3

    Hi.
    Below I have a bit of code that determines the bandwidth that a user has.  It is written in ActionScript 2.  The problem is that I am unfamiliar with AS2, and I wanted to use this in conjunction with a live streaming video player built in AS3.  I was wondering if anyone could give me the equivalent code in AS3, or if there's any way to tell flash that a portion of the code will be written in AS2.
    Thank You,
    Ari Amiri
    nc = new NetConnection();
    nc.onStatus = function(info) {
        trace("Level: "+info.level+" Code: "+info.code);
        if (info.code == "NetConnection.Connect.Success") {
            trace("--- connected to: " + this.uri);
    nc.onBWDone = function(kbitDown, deltaDown, deltaTime, latency) {
        trace("onBWDone: kbitDown:"+kbitDown+" deltaDown:"+deltaDown+" deltaTime:"+deltaTime+" latency:"+latency);
        // app logic based on the bandwidth detected follows here
        detected_bw = kbitDown;
        // close the Netconnection to bwcheck
        this.close();
    nc.onBWCheck = function() {
        trace("onBWCheck");
        return ++counter; // Serverside, just ignore any return value, For now return the call count
    nc.connect("rtmp://localhost/bwcheck", true);
    stop();

    Yah very important point from NetDragon. As of version 3.0
    the netconnection " class was dynamic in ActionScript 2.0 but is
    now sealed. " so you can't just do something like:
    netconnection.client.somefunction = function() {...}
    The default netconnection.client = this, so you need to
    extend it with a custom class or an object to be able to add
    callback functions
    But be careful, I wrote an entire app that worked with the
    AS2.0 technique ...without an error from the compiler.....(flex
    2.0).

  • Director - Flash AS2 - Flash AS3 via localconnection?

    I have a Director MX2004 app that I would like to use to control a Flash swf written in AS3.  I know I can't embed that kind of SWF file in Director, so I thought I would try to use this method:
    Embed an AS2 swf in director and communicate with that.
    Have that swf use the localconnection to communicate with the AS3 swf running in Air.
    I can verify that the 2 swfs communicate when running in Flash and Air
    I can verify that Director can communicate with the AS2 swf embedded in it.
    But I can't link it all together.  Send a command to the AS2 swf from Director doesn't continue down the chain to talk to the AS3 swf.
    Is this something that could possibly work, or am I beating a dead horse?

    Hi,
    Did you have any luck with this method?
    I am using Dir 12 now and Flash CS6.
    Thanks,
    Jim

  • 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

  • SFTP to AS2(non-seeburger): How to get sender Filename to be used in AS2 Receiver Channel

    Hi Experts,
    I have this scenario,
    SFTP > Process Orchestration > AS2(non-seeburger)
    My interface is not using Message Mapping and I want to use the source Filename as my Receiver Filename.
    Sender
    orders_1234 - source filename
    Receiver
    orders_1234 - target filename
    How to do it in Process Orchestration without Seeburger.
    Thanks and Best Regards,
               Orlan

    Hi Orlan - So are you using SAP AS2 adapter?
    If you so i think you can make use of dynamic configuration bean.
    Unknown use case of DynamicConfigurationBean: Store file name to JMS header without mapping
    Enable adapter specific attributes in sender SFTP channel and in the receiver AS2 channel use the above module to swap the dynamic attributes.
    Dynamic attributes
    http://sap.com/xi/XI/System/SFTP ,FileName 
    http://sap.com/xi/XI/AS2/AS2:  AS2Filename

Maybe you are looking for