Conversion of HTTPService in AS3

One of the things I don't like Flex is to have make switch between xmxl and .so files that I work through the logic of my code. As a result, I want to convert all my tags HTTPService AS3. I don't see any point in writing the HTTPService in mxml, as there is no visual element that itself. So my question is this: can I simply use a loadVars object to manage my calls and returns to and from php (it even exists in AS3?), or should I use the HTTPService in AS3. If I should use the HTTPService in AS3, how I would write what follows?

Thank you very much for looking.

Hi SiHoop,

In the next page of the documentation, please see the section "setting explicit way with HTTPService components:
http://livedocs.Adobe.com/Flex/3/HTML/data_access_5.html

Basically, there are 3 ways to pass the params to the server via HTTPService:
1) links (in the link above, see section "Binding of parameter with HTTPService components"). This option applies mainly during instantiation through MXML HTTPService (i.e. ), not with the instantiation through ActionScript (as you do).
2) in position send() compared to how defined on the method Server (for example myService.send (myText.text, myText2.text)
3) in send() via the object with the properties that are defined on serverside method of param names, (for example
var params: Object = new Object();
myText.text = params.param1;
params.param2 = myText2.text;
myService.send (params);

For option 3 above, please note that in page doc I had referenced my first answer, where their "parameters: the object" was being imposed on the signing of the definition of the useHttpService(parameters:Object) method, the parameters of the object were built in the calling code. Unfortunately, the latest version of this documentation does not call any code. (Just before I said last night, Amy had enough posted that he was "a kind of example of crap".) So, according to your requirement, you can create the object elsewhere and put it in, or you can build the object immediately before execution of send (params).

BTW, here is a "quick start guide Flex for PHP developers" complete with the sample files. It does not cover the HTTPService via ActionScript execution. However, if you have not yet taken so, maybe he can help you with some examples of work to work with PHP backends for Flex.

Please post back on so the above answers your question, and if you find it useful :-)

Best regards

g

Tags: Flex

Similar Questions

  • Conversion function XML AS2 AS3

    Hi guys, how are you?

    Once again I m here to ask for your help.

    I m trying to convert an AS2 AS3 script, but I m not good in AS3 síntax yet. I Don t know how to create this structure. Please, could someone help me?

    xml:
    
    <resources>
    
             <levelTitle1>Iniciante</levelTitle1>
              <levelTitle5>Aprendiz</levelTitle5>
              <levelTitle10>Aspirante</levelTitle10>
              <levelTitle15>Recruta</levelTitle15>
              <levelTitle20>Experiente</levelTitle20>
              <levelTitle30>Profissional</levelTitle30>
              <levelTitle50>Star</levelTitle50>
              <levelTitle70>Ás</levelTitle70>
              <levelTitle90>Campeão</levelTitle90>
              <levelTitle120>Lenda</levelTitle120>
    
    </resources>
    
    
    AS2 Function:
    
    public static function getLanguage(tag:String):String
    {
               if (languageObject[tag].data){
    
    
                        return slanguageObject.resources[tag].data;
               }
                 return "Error";
     }
    

    I can´t find a way to work in as3 without the parameter 'data '.

    I want to call this as2 function, pass "levelTitle30" to the "tag" parameter and return by the return of the function of the content of "levelTitle30" of the xml tag.

    Kind regards

    is your code xml in an external file?

    If so, (for example, resources.xml), you would use:

    var xml

    var urlLoader:URLLoader = new URLLoader();

    urlLoader.addEventListener (Event.COMPLETE, completeF);

    urlLoader.load (new URLRequest ("resources.xml"));

    function completeF(e:Event):void {}

    XML = e.Target.Data;

    }

    public static function getLanguage(tag:String):String{
    if(xml[tag]){
    return xml[tag];

    } else {
    return "Error";
    }
    }

  • HTTPService in as3

    Hello

    I'm relatively new to AS and I have some problems using the VO HHTPService, I created.

    Here is my code:

    package ValueObjects

    {

    Import mx.rpc.events.ResultEvent;

    Import mx.rpc.http.HTTPService;

    [Bindable]

    public class indicator

    {

    protected var service: HTTPService;

    public void indicator (id int, name String, group_id:int, alias: String)

    {

    }

    public function getfields (): void

    {

    This.service = new HTTPService();

    service.url = " " http://localhost/autoTradePHP/indicators/getIndicatorFields/ "+ this.indicatorID; "

    trace (service. (URL);

    service.addEventListener (ResultEvent.RESULT, createFields);

    service. Send();

    }

    public void createFields(event:ResultEvent):void

    {

    trace ("got here");

    service.removeEventListener (ResultEvent.RESULT, createFields);

    }

    }

    }

    My problem is that for some reason that I do not get the result. not getting do not track "got here" - it seems that the createFields function is not invoked.

    Anyone has any idea why?

    Thanks in advance

    Ravid

    Never mind.

    Apparently, the problem was on the side server.

    There was a guy in the generated XML and Flex "event.fault.faultDetail" was not undefined for this purpose I have no error.

    Use "event.fault.faultString" fault string.

  • Script conversion link external as2 as3

    Hello.

    I used this script I found online to create an accessible Flash file a text file external full of hyperlinks via the buttons in the Flash animation. The code is as2. I had to update the Flash AS3 file and now the script does not work. I can't understand how to do the same thing as this script in AS3. Can someone help me?

    Here is the AS2 script:

    text file = new LoadVars()
    textFile.onLoad = function() {}
    buttonlink1 is this. BlackBooklink;
    buttonlink2 is this. Ashtraylink;
    buttonlink3 = this.bedroomlink;
    buttonlink4 = this.tvlink;
    buttonlink5 = this.spiderlink;
    buttonlink6 is this. Mirrorlink;
    buttonlink7 is this. Boomboxlink;
    buttonlink8 is this. Suitlink;
    buttonlink9 = this.cashlink;
    buttonlink10 = this.fastfoodlink;
    buttonlink11 is this. Idolatrylink;
    buttonlink12 is this. Trashlink;
    }

    textFile.load ("LeftHouseLinks.txt");

    -buttons
    BlackBook.onRelease = function() {}
    getURL (buttonlink1, "_self");
    };

    Ashtray.onRelease = function() {}
    getURL (buttonlink2, "_self");
    };

    bedroom.onRelease = function() {}
    getURL (buttonlink3, "_self");
    };

    tv.onRelease = function() {}
    getURL (buttonlink4, "_self");
    };

    spider.onRelease = function() {}
    getURL (buttonlink5, "_self");
    };

    Mirror.onRelease = function() {}
    getURL (buttonlink6, "_self");
    };

    Boombox.onRelease = function() {}
    getURL (buttonlink7, "_self");
    };

    Suit.onRelease = function() {}
    getURL (buttonlink8, "_self");
    };

    cash.onRelease = function() {}
    getURL (buttonlink9, "_self");
    };

    fastfood.onRelease = function() {}
    getURL (buttonlink10, "_self");
    };

    idolatry.onRelease = function() {}
    getURL (buttonlink11, "_self");
    };

    trashtalk.onRelease = function() {}
    getURL (buttonlink11,"_s)

    It is the content of the external txt file.

    & BlackBooklink = http://www.Yahoo.com
    & Ashtraylink = http://www.Google.com
    & bedroomlink = http://www.Yahoo.com
    & tvlink = http://www.Google.com
    & spiderlink = http://www.Yahoo.com
    & Mirrorlink = http://www.Google.com
    & Boomboxlink = http://www.Yahoo.com
    & Suitlink = http://www.Google.com
    & cashlink = http://www.Yahoo.com
    & fastfoodlink = http://www.Google.com
    & Idolatrylink = http://www.Yahoo.com

    I know not how to run the AS3 button, I do not know the code so that when I click the button, it accesses the external file and goes on the hyperlink specified by the button.

    Any help would be appreciated.

    -Shawn

    It is probably not a question of buttonlink1 is not found, it is more likely a problem with buttonlink1 do not have a defined value entrusted to him.  If you go to the section of the tutorial I mentioned who is called "Loading Variables from a text file" you will see how values can be traced.  You want to do is to assign your buttonlink values in this function using these values... something like the following inside the function...

    buttonlink1 = e.target.data.BlackBooklink;

    What you have now will assign nothing to them because it will run until the file is loaded (that is outside the service of FULL charge).  And you must declare variables at the beginning of your code.  The way you have it now, you run the risk of the variable exist not until you try to use it.

  • AS3 to the conversion of JS: future and preparation

    Hey guys!

    Then, new work here and great responsibility. I have a HUGE project in my hands and my mission is to implement with Flash and AS3, but later I have to migrate ALL HTML5 + JS. Well, I know there are things like the EasyJS and other things, but this isn't quite what I'm looking for. I need to know with certainty whether, in the near future, we will be able to convert the entire flash JS projects. Adobe is working on it, but just did not have the time? Should I do it myself somehow? How should I prepare my code isn't near ready when this conversion is possible?

    My first thought was on the agenda for AS3 pretending I do in JS... I would create in the AS3 classes with the same name and signature of EaseJS those so I can use the same code in Flash and JS. You guys don't think it's a good idea? This way of coding would make the terribly ugly flash project = |

    I really need help here, I hope that someone from Adobe can give me some piece of advice and answer the questions about the future.

    Thank you!

    MB

    Adobe cross compile AS3 in the ARM, I think they can handle AS3 (ECMAScript compatible) JS scripts. The problem is probably the fact that JS is still prototype and conversion oriented code prototype OOP is not easy or even possible. THERE are literally almost be redone by hand. But it's actually the easiest part of the "hard" part

    Difficult the thing is there are tons of times when some things need to be done on canvas and others using simply built in the rendered HTML. Sometimes the combination of the two is not possible. You can have an animation with text behind it. They would choose to cross compile alternating animation in the canvas but always choose using normal text no matter where you use normal text. The text is now at the top of the canvas instead of appear behind your animation unless they knew of zindex. Or, they would need to know the text is behind and blit the text in the drawing area. Etc etc... Situations you would enter in and in efficient and respectful of the appliance converting you a project to another is surprisingly varied and pretty nearly impossible.

    Even if they make a pretty good implementation half of some small parts of ACE-> JS, I don't ever expect there to be a 'Export to HTML5' perfect option that will make 100% of your work. They do not provide 100% of all conversions aims capabilities either currently. LOOK for iOS does not support almost all obj-c/cocoa can do. AIR for Android even almost does not all + Java SDK can do. They have just converted 'enough' to make a usable product. Even their native extensions have serious limitations.

    Right now, I don't expect magic bullets. Maybe help, nothing automatic.

    At best, if it's really a complex project, I would like to start writing them both at the same time. You can find something that you are trying to do in one is impossible in the other. He made choices for you.

  • AS1 to AS3 conversion help please

    Hello

    Would someone kindly help me with this conversion please?

    I am completely new to Flash and functional on convert my AS1 site developed in AS3. I think I understand the concept now that we add listeners to what we want him to do when the event occurs. So I have this I understand patiently. From what I understand, I have buttons across the way will listen if they are clicked and if they are clicked it performs a test that says: "if I'm not on this page then go ahead.

    I'm a script kiddy that I admit I then copy paste and go with what works. My compiler errors have been reduced considerably with the release of AS3. I like to learn so if you post code, please explain what he does.

    The final product is www.blackelementpmc.com

    Thanks for the help!

    Symbol 'work' AS1 script
    My attempt at AS3
    Section 2:_root. Link = 1;
    _root.pressed_link = 1;
    var $link = 1;
    var $pressed_link = 1;
    BT3 (button next to the logo LCorp)on {(overview)
    gotoAndPlay ("s1");

    }
    on (deployment, releaseOutside) {}
    gotoAndPlay ("s2");

    }
    on (release) {}
    If {(_root.link <> 4)}
    _root. Link = 4;
    _root. Play();
    _level1.gotoAndPlay ("diss");
    _root.pressed_link = 4;

    }
    }
    function rollHandler(e:MouseEvent):void {}
    If ($link! = 1) myClip.gotoAndPlay ("s1");
    }

    function rollOutHandler(e:MouseEvent):void {}
    If ($link! = 1) myClip.gotoAndPlay ("s2");
    }

    function clickHandler(e:MouseEvent):void {}
    trace ("clicked");
    }

    myClip.addEventListener (MouseEvent.ROLL_OVER, rollOverHandler);
    myClip.addEventListener (MouseEvent.ROLL_OUT, rollOutHandler);
    myClip.addEventListener (MouseEvent.CLICK, clickHandler);

    function clickHandler(e:MouseEvent): void {}
    If ($link! <>4) {}
    $link! = 4 ;
    $link! myclip.gotoAndPlay ();
    myclip.gotoAndPlay ("diss");
    $pressed_link = 4;

    }
    }
    Plot of 95loadMovieNum ("page1.swf", 1);looking for a method
    ControlonClipEvent (load)
    {
    _root.soundstatus = "on";
    _root.mySound = new Sound (_level0);
    _root.mySound2 = new Sound (_level1);
    _root.mySound3 = new Sound (_level2);
    _root.mySound4 = new Sound (_level3);
    _root.mySound5 = new Sound (_level4);
    MaxVolume = 100;
    minvolume = 0;
    }

    onClipEvent (enterFrame)
    {
    if(_root.soundstatus=="on") {stage = 5}

    if(_root.soundstatus=="OFF") {stage =-5}

    MaxVolume += step;

    If (maxvolume > 100) {= ;} 100 maxvolume
    If (maxvolume < 0) {maxvolume = 0 ;}

    _root.mySound.setVolume (MaxVolume);
    _root.mySound2.setVolume (MaxVolume);
    _root.mySound3.setVolume (MaxVolume);
    _root.mySound4.setVolume (MaxVolume);
    _root.mySound5.setVolume (MaxVolume);
    }
    Don't know even how to start with this...

    You can apply unload() to your charger in as3.

    and you use the class loader again to that code preloader.

  • Problem of data Conversion HTTPService

    I have a REST-style web service that returns an HTML document that looks like this:

    < a >
    < b >
    < c > 2.0 / < c >
    < b >
    < b >
    < c >/< c > 3.2
    < b >
    < /a >

    I can use the browser to view this document, and it looks as expected. However, when I use a Flex HTTPService to get the document and display its values, all numbers ending by ".". 0' are rounded/truncated. For example, the first element < c > above appears as '2' instead of '2.0 '.

    Why numbers are converted? Shouldn't they have considered all other text in an XML element?

    That's what I call service:

    < mx:HTTPService id = "myService" url = "itsurl" method = "GET" useProxy = "false" / >

    And it is an example that shows a number being trucated/rounding:

    < mx:Label text="{myService.lastResult.a.b[0].c}"/ >

    Thank you

    Mike

    The default value for HTTPService is resultFormat = "object", which causes Flex convert your xml file into a tree of dynamic objects. It is rarely what you want. Among other things, he's trying to type conversions.

    Instead, the value resultFormat = "e4x". This will give you your xml code that the United Nations has changed. It also gives you access to the e4x which is very powerful API. It includes features of course, search and always.

    In addition, for another thing what a banal or demonstration app, do not directly bind to the lastResult. Use a function instead of the result handler. Here is an example, untested:


    (in the script)
    Import mx.rpc.ResultEvent;
    [Bindable] private var _xmlResult:XML; var instance to store the data
    private void onResult(event:ResultEvent):void {}
    _xmlResult = XML (event.result);
    trace (_xmlResult.ToXmlString ()); to see exactly what you
    ....
    }

    Note your example of XML is not valid, so I can't show you an example of an e4x expression.

    Tracy

  • Conversion of AS3 in HTML

    I use Adobe Flash Pro CC, and nothing will load in the canvas, I know its my charger, but do not know what I did wrong:

    this.stop(); this.addEventListener(Event.ENTER_FRAME, this.loading);  private function loading():{ var total:Number = this.stage.loaderInfo.bytesTotal; var loaded:Number = this.stage.loaderInfo.bytesLoaded;  if (total == loaded){ this.removeEventListener(Event.ENTER_FRAME, this.loading); this.gotoAndPlay(3); }

    }

    It's the AS3

    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;  if (total == loaded){ this.removeEventListener(Event.ENTER_FRAME, loading); this.gotoAndPlay(3); }  }

    The canvas is not empty when she spotted in the browser.  You can remove completely the first two good frames, and then you must change the code to look like this:

    ce. textmc.mouseEnabled = false;

    this.theButton.addEventListener ("click", clickHandler link(this));

    function clickHandler()

    {

    ce. planeflightmc.gotoAndPlay ("end");

    ce. cloudmc.gotoAndStop (1);

    this.gotoAndStop (3);

    }

    Who gets the button works correctly.

  • Links to external .AS files after the conversion to AS3 canvas

    After you convert an AS3 project in canvas, objects that were previously linked to a file external .AS, containing their class to the library as always appear related to this class, as follows:

    2.JPG
    but I get no choice but in the environment of the AS3 to 'Change the class' and implement these for editing external .AS files, as you can see here:

    Capture.JPG

    Can I still retain the binding object in Javascript and how do I do in the environment Adobe animate CC, please?

    In the library, you can double-click on the column link to any element and give it a name of link. Later, it is used like this:

    var something = new lib. Thingy();

    But there is no file class in HTML5 Canvas. If you want external CODE to participate you must convert it into Javascript and put it in the first picture inside the movieclip.

  • Need help with AS3 to Java conversion

    Hi to all who can help. I learned finally action script 3 and now the company wants course eLearning flash for flash for the Web, and found out that AS3 does not work. It is a code button which is a simple click to continue.

    Here is my AS3 code for red buttons:

    import flash.events.MouseEvent;

    Stop();

    Red_btn.addEventListener (MouseEvent.CLICK, Red_btn_onMouseClick);

    function Red_btn_onMouseClick(e:MouseEvent):void

    {

    Play();

    you mean javascript, not java.

    var tl = this;

    TL. Stop();

    TL. Red_btn.addEventListener ('click', Red_btn_onMouseClick);

    function Red_btn_onMouseClick (e) {}

    TL. Play();

    }

  • AS2 AS3 conversion please!

    Hi guys.

    I had a major problem when trying to convert an old AS2 AS3 code.

    It would be great if you guys can help in anyway you can.

    onClipEvent (enterFrame)

    {

    This;

    If (_x > 520)

    {

    setProperty (this, _x,-20);

    } / / end if

    This;

    If (_x <-20)

    {

    setProperty (this, _x, 520);

    } / / end if

    setProperty (this, _x, _x + (1.250000E + 000) Number);

    }

    In the chronology of the object in question, try:

    addEventListener (Event.ENTER_FRAME, moveX);

    function moveX(evt:Event):void {}

    If (x > 520) {}

    x = - 20;

    }

    If (x<>

    x = 520;

    }

    x += 1.25;

    }

  • Conversion of AS2 AS3

    I have a button with the following ActionScript code:

    function blurbOut (blurb) {}

    Blurb._x = 1600;

    }

    function stagetitle (blurb, box) {}

    Blurb._x = box._x + 180;

    Blurb._y = box._y + 1;

    }

    and

    on (release) {}

    _level0.stagetitle (_level0.info1, this);

    }

    on {(deployment)

    _level0.blurbOut (_level0.info1);

    }

    This works like a ToolTip. I want to convert these scripts in AS3... So that when I include the Captivate 6 animation, it works. Can someone help me.

    function blurbOut(blurb:DisplayObject) {}

    Blurb.x = 1600;

    }

    function stagetitle (blurb: DisplayObject, box: DisplayObject) {}

    Blurb.x = Box.x + 180;

    Blurb.y = Box.y + 1;

    }

    and

    this.addEventListener (MouseEvent.CLICK, clickHandler);

    this.addEventListener (MouseEvent.ROLL_OUT, outHandler);

    function clickHandler(e:MouseEvent):void {}

    MovieClip (root) .stagetitle (MovieClip .info1 (root), this);

    }

    function outHandler(e:MouseEvent):void {}

    MovieClip (root) .blurbOut (MovieClip (root) .info1);

    }

  • Simple conversion of AS2 AS3.

    Hi all

    Can someone help me convert this script in AS3, I tried it, but I'm not very good.

    import flash.filters.DisplacementMapFilter;

    import flash.display.BitmapData;

    to import flash.geom.Point;

    this.createEmptyMovieClip ("waterHold", this.getNextHighestDepth ());

    waterHold._visible = false;

    var numOfRipples:Number = 65;

    var speed: number = 18;

    for (var i: Number = 0; i < numOfRipples; i ++) {}

    undulation of the var: MovieClip = waterHold.attachMovie ("wave",

    "wave" + waterHold.getNextHighestDepth (), waterHold.getNextHighestDepth (), "."

    {_x:random (Stage.width), _y:random(Stage.height)}) ;

    ripple.gotoAndPlay (random (65));

    }

    onEnterFrame = function () {}

    var bm:BitmapData = new BitmapData (waterHold._width + 65, + 65 waterHold._height, true,

    50000000 (0 x);

    BM. Draw (waterHold);

    photo_mc.filters = [new DisplacementMapFilter (bm, new Point (0, 0)-1, 1, 1, speed)];

    };



    It would be a great help for me...
    Thanks in advance!

    import flash.filters.DisplacementMapFilter;

    import flash.display.BitmapData;

    to import flash.geom.Point;

    import flash.sampler.NewObjectSample;

    import flash.display.MovieClip;

    import flash.events.Event;

    var waterHold:MovieClip = new MovieClip();

    addChildAt (waterHold, numChildren);

    waterHold.visible = false;

    var numOfRipples:Number = 65;

    var speed: number = 18;

    for (var i: Number = 0; i

    var w: wave = new wave();

    undulation of the var: MovieClip = waterHold.addChildAt (w, waterHold.numChildren);

    Ripple.x = Math.random () * stage.stageWidth;

    Ripple.y = Math.random () * stage.stageHeight;

    ripple.gotoAndPlay (1 + int (Math.random () * 64));

    }

    addEventListener (Event.ENTER_FRAME, onEnterFrameF);

    function onEnterFrameF(e:Event):void {}

    var bmd:BitmapData = new BitmapData (waterHold.width + 65, + 65 waterHold.height, true, 0 x 50000000);

    var bm:Bitmap = new Bitmap(bmd,PixelSnapping.AUTO,true);

    BM. Draw (waterHold);

    photo_mc.filters = [new DisplacementMapFilter (bm, new Point (0, 0)-1, 1, 1, speed)];

    }

  • AS2 AS3 helps conversion

    I have three base type of navigation and buttons in a movie. Using action script 2, but I would like to pass to the action script 3. Can anyone suggest how convert or rewrite these lines (below) for AS3?

    I've been away from Flash for a while and try to get the acknowledgement of receipt. I'm not a programmer, and won't any programmer lingo if thrown out there. Any help would be appreciated until I have the time to learn more. Thanks in advance for any help. Yes I am reading and trying to figure out as you read this. Just under pressure. :-)

    ___________________________________

    I use it to simply navigate a calendar:

    btn_back_main.onRelease = function() {}

    _root.gotoAndPlay ("main");

    };

    ___________________________________

    I use it to open the PDF files:

    This.sec_01_btn_01.onRelease = function() {}

    getURL("pdf/sec_01_pdf_01.pdf");

    };

    ___________________________________

    I use it to load external SWF in a particular place:

    This.btn_video.onRelease = function() {}

    (" load_targ.loadMovie("loads/sec_01.swf ");

    };

    ___________________________________

    Fun with AS3.

    Please mark this as answered.

  • Need help with as2 as3 conversion. Please, I beg you.

    Could someone help me to convert as2 as3, please?

    Source code:

    _root.magnet = 500;
    _root.magic = 10;

    and

    onClipEvent (load)
    {
        homex = this._x;
        homey = this._y;
        forcex = 1;
        forcey = 1;
    }
    onClipEvent (enterFrame)
    {
        x0 = this._x;
        y0 = this._y;
        x1 = this._xmouse;
        y1 = this._ymouse;
        distancex = x1 - x0;
        distancey = y1 - y0;
        distance = Math.sqrt(distancex * distancex + distancey * distancey);
        powerx = this._x - distancex / distance * _root.magnet / distance;
        powery = this._y - distancey / distance * _root.magnet / distance;
        forcex = (forcex + (homex - x0) / 2) / _root.magic;
        forcey = (forcey + (homey - y0) / 2) / _root.magic;
        this._x = powerx + forcex;
        this._y = powery + forcey;
    }

    I am a newbie in flash so if anyone can help with this would be great.

    I really need to be done please help me.

    MovieClip(root).magnet = 500;MovieClip(root).magic = 10;
    

    and

    var homex:Number = yourmc.x;var homey:Number = yourmc.y;var forcex:Number = 1;var forcey:Number = 1;
    
    yourmc.addEventListener(Event.ENTER_FRAME, loopF);
    
    function loopF(e:Event){    var x0:Number = e.currentTarget.x;    var y0:Number = e.currentTarget.y;    var x1:Number = e.currentTarget.mouseX;    var y1:Number = e.currentTarget.mouseY;    var distancex:Number = x1 - x0;    var distancey:Number = y1 - y0;    var distance:Number = Math.sqrt(distancex * distancex + distancey * distancey);    var powerx:Number = e.currentTarget.x - distancex / distance * MovieClip(root).magnet/distance;    var powery:Number = e.currentTarget.y - distancey / distance * MovieClip(root).magnet/distance;    forcex = (forcex + (homex - x0) / 2) /MovieClip(root).magic;    forcey = (forcey + (homey - y0) / 2) / MovieClip(root).magic;    e.currentTarget.x = powerx + forcex;    e.currentTarget.y = powery + forcey;}
    

Maybe you are looking for