A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: quick as3 conversion question

  1. #1
    ...dishing dimes on an .fla! pointguard's Avatar
    Join Date
    Dec 2001
    Location
    Cambridgeshire, England
    Posts
    1,017

    quick as3 conversion question

    Hi everyone...

    I'm trying to update my preloader code to AS3 from AS2, and am having a little bit of trouble. the preloader consists of 2 movie clips, nested inside another. Inside the first nested clip is this code...
    code:

    onMouseMove = function () {
    percText._x = _xmouse;
    percText._y = _ymouse;
    };
    onEnterFrame = function () {
    var per = _parent._parent.getBytesLoaded()/_parent._parent.getBytesTotal();
    percText.text = Math.ceil(per*100);
    };
    stop();


    Inside the other nested clip is this code...
    code:

    var i = 0;
    var dep = 1;
    onMouseMove = function () {
    var p = this.attachMovie("SmokeParticle", "SmokeParticleMC"+i++, this.dep);
    dep++;
    p._x = _xmouse+55;
    p._y = _ymouse+10;
    p._xscale = p._yscale=Math.random()*100+50;
    };
    stop();


    I've tried a few things but keep getting error messages, so have gone right back to the start with my as2 code above, and am hoping someone can help me convert the 2 segments of code...

    please?

    thanks in advance
    Jeff

  2. #2
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    Actually the best thing here would be you attaching your source FLA. I have a feeling this would be easier converted putting all the code on the main timeline.

  3. #3
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Here are the two lines that are giving you trouble:

    PHP Code:
    var per root.loaderInfo.bytesLoaded root.loaderInfo.bytesTotal
    PHP Code:
    var addChild( new SmokeParticle() ); 
    Everything else should be a straight conversion.

  4. #4
    Teacosy is coming ranoka's Avatar
    Join Date
    Jun 2003
    Location
    UK
    Posts
    123
    You need to change stuff like _x to x and _parent to (parent as MovieClip) and _xscale to scaleX. The bugs in the output window should help you, they normally tag stuff like this as migration issues.

    Also note that stuff like scaleX is 0 - 1 now instead of 0 - 100, so you'll need to alter some of your calculations a bit.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center