A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: convert Flash 5 code into Flash 8

  1. #1
    Junior Member
    Join Date
    Jul 2007
    Posts
    11

    convert Flash 5 code into Flash 8

    I have a snippet of code written for Flash 5 and I would like to use it for Flash player 8. When i switch to Flash 8 in the IDE it no longer works. I dont have the skills to basically convert it myself but perhaps there is someone out there who could help me out here. It is not a whole lot of code.

    In the file there is two snippets of code. On the first frame and on the ball itself.

    Would really appreciate if someone could take a look at it.
    www.kanzeon.se/external/ball.fla

    Thanks

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    change the x and y variables so they don't conflict
    with the x (Point.x property) and y (Point.y property)
    PHP Code:
     // code on main timeline -
        
    PZ={xx:0,yy:0};

    function 
    hit(){
        
    _root.ball.initZspeed =18;
        
    _root.ball.gravity 9;
        
    _root.ball.initSpeed = -200;
        
    zoomZ 100;
        
    shiftX 0;
        
    shiftY =0;
        
    z0=100;    
        
    PZ = {xx:shiftX*(-1)+mcPeg._xyy:mcPeg._y};
    }
    function 
    f3dscale (z) {
        var 
    scale zoomZ*z0/(z0+z);
        return 
    scale;
    }
    function 
    f3dPoint (xxyyz) {
        var 
    x3d = (xx+shiftX)*f3dscale(z)/100+PZ.xx;
        var 
    y3d = (yy+shiftY)*f3dscale(z)/100+PZ.yy;
        var 
    pt = {xx:x3dyy:y3d};
        return 
    pt;
    }
    function 
    update3dObject (clipxxyyz) {
        var 
    pt2 f3dPoint(xxyyyz);
        
    clip._xscale _root.f3dScale(z);
        
    clip._yscale _root.f3dScale(z);
        
    clip._x pt2.xx;
        
    clip._y pt2.yy;

    PHP Code:
    // code on movieclip
    onClipEvent (load) {
        function 
    init () {
            
    this.xx 0;
            
    this.yy = -1;
            
    this.0;
            
    _root.update3dObject(thisxxyyz);
            
    initSpeed = -40;
            
    initZspeed 5;
            
    gravity 1.5;
            
    count 0;
            
    animate=false;
            
    _root.update3dObject(thisxxyyz);
            
    _root.update3dObject(_root.shadowxx40z);
        }
        
    init();
    }

    onClipEvent (enterFrame) {
        if (
    animate == false) { return; }
        
    count++;
        
    += initZspeed;
        
    xx+=0;
        
    yy += initSpeed+(gravity*count)+14;
        if (
    yy>=0) {    
            
    initSpeed=0-(initSpeed+(gravity*Count));
            
    yy+=2*(initSpeed) ;count=0;
            if(
    yy>=0){animate=false;}    
        }    
        
    _root.update3dObject(thisxxyyz);
        
    _root.update3dObject(_root.shadowxx40z);

    hth

  3. #3
    Junior Member
    Join Date
    Jul 2007
    Posts
    11

    not working

    Thanks for the feedback but unfortunately it does'nt work. The ball is supposed to make several bounces just as it does if you switch to Flashplayer 5. The ball is also supposed to scale to simulate real physics.

    When using your corrected code with Flash player 8 the ball is only doing one bounce and no scaling occurs. Would be very happy if you could help me solving this one.

    Did it work for you after swithcing to FLash player 8 in the Flash IDE?


    Thank you.

  4. #4
    Junior Member
    Join Date
    Jul 2007
    Posts
    11

    It works thanks!

    After converting your code in CS3 it all works.

    Thanks alot!

  5. #5
    Junior Member
    Join Date
    Jul 2007
    Posts
    11

    Flash 5 code to Flash 8

    I have a snippet of code written for Flash 5 and I would like to use it for Flash player 8. When i switch to Flash 8 in the IDE it no longer works. The ball is supposed to bounce several times and scale as it does when choosing Flash player 5.

    I previously got som tips and help here:
    http://board.flashkit.com/board/showthread.php?t=742711
    but it still doesn't work so I'll try again.

    I don't have the skills to basically convert it myself but perhaps there is someone out there who could help me out here. It is not a whole lot of code.

    In the file there is two snippets of code. On the first frame and on the ball itself.

    Would really appreciate if someone could take a look at it.
    www.kanzeon.se/external/ball.fla

    Thanks

  6. #6
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    yesterday 10:25 - It works thanks!

    Today, 08:13 - wtf ??

    Flash 8 file attached
    Last edited by a_modified_dog; 11-30-2007 at 10:43 AM.

  7. #7
    Junior Member
    Join Date
    Jul 2007
    Posts
    11
    Thanks for your good work. I guess It's me that can't explain what I'm after.

    I want to be able to use all the features and classes that comes with Flash 8 and actionscript 2.0 and still I want the ball code to work.

    My problem is when i select flash player 8.0 in the Flash publish settings and compile the code no longer works. The ball is only doing one bounce without scaling when my goal is that it should behave just like it does when Flash player 5 is selected in the publish settings.

    Sorry for not describing this in the first place. I thought I did.

  8. #8
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    hmm .. failed to notice that the file was Publishing for Flash 5
    changed to Flash 8 and it fails

    i tried declaring all variables with strict-typing, ie
    var xx:Number;
    var yy:Number;
    var z:Number;
    var animate:Boolean; and so on, without luck

    List Variables shows 2 variables returning - NaN (Not a Number)
    Variable _level0.ball.yy = NaN
    Variable _level0.ball.initSpeed = NaN

    can only suggest you plaster traces all over the file
    to find where the logic is falling down

  9. #9
    Junior Member
    Join Date
    Jul 2007
    Posts
    11
    Ok, thanks for trying

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