A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: Flash MX code : no longer works in Flash 8! :(

  1. #1
    Senior Member
    Join Date
    Nov 2001
    Posts
    174

    Flash MX code : no longer works in Flash 8! :(

    Hi,

    I have some code, which made a textfield scroll up and down, it worked fine in Flash MX, but I upgraded to Flash 8 and it stopped working.

    Here is the code.
    onClipEvent (enterFrame) {
    Y = (getProperty("_root.Scroller", _y)-(_global.top))*(_global.factor);
    newY = oldY-(Y+oldY)/(_global.ease);
    setProperty("_root.TextContainer.TextField", _y, newY);
    oldY = newY;
    }
    Can anybody give me a clue as to how to rework this in Flash 8??

    Cheerz,
    Dwayne

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Test if any of the variables are undefined.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Junior Member
    Join Date
    Aug 2006
    Posts
    12
    Do you get any error messges or does nothing happen at all.

  4. #4
    Senior Member
    Join Date
    Nov 2001
    Posts
    174
    Quote Originally Posted by -thanatos-
    Do you get any error messges or does nothing happen at all.
    Nothing happens at all, it just doesnt work. It was working in MX, and the code hasnt changed :*(

  5. #5
    Senior Member
    Join Date
    Nov 2001
    Posts
    174
    Quote Originally Posted by cancerinform
    Test if any of the variables are undefined.
    Yeah, i stuck a couple traces in.
    Trace(newY), Trace(oldY).

    Didnt get undefined, got NaN (not a number)!

    ARGH!

    Undefined would be GOOD in this case, NaN is bad!!

  6. #6
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Some of the properties within the equation are probably strings. Check which one they are and then do casting. From your little script it is impossible to guess that. You need to do something like below before putting it in the big equation.

    var a:Number = Number(b);
    - The right of the People to create Flash movies shall not be infringed. -

  7. #7
    Senior Member
    Join Date
    Nov 2001
    Posts
    174
    Im mystified as to why it works in MX and not Flash 8 though.

    Is Flash 8 more stringent on type casting??

    There is 2 more piece's of code.
    1) the global variables are declared
    2) startDrag() for the _root.Scroller object.

    The scroller object is still draggable, as before, constrained by its global variables, _global.top, global.bottom, global.left, global.right.

    All that is working fine, hasnt broken.

    Its just that tiny bit of code that has gone caput.... so strange.

    Cheerz,
    Dwayne

  8. #8
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    What you can do is define oldY once

    onClipEvent (load) {
    oldY=0;
    }

    There is no value for oldY in the script unless it is defined somwhere else. May be that is the problem. In Flash 6 it doesn' matter if a value is undefined.
    - The right of the People to create Flash movies shall not be infringed. -

  9. #9
    Senior Member
    Join Date
    Nov 2001
    Posts
    174
    yeah, it is definately not defined anywhere else.

    onClipEvent (load) {

    Hadnt thought of that, good idea, initiates the variables in the clip level scope, but only once, I expect it will work a treat

    But shouldnt I put

    onClipEvent (load) {
    oldY:Number = 0
    }

    :P

    If Flash 8 is going to be more pedantic, i better move with the times.

    Cheerz,
    Dwayne

  10. #10
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    You don't have to, since all the other variables are also not written in that way. If you do it, do it correctly.

    onClipEvent (load)
    {
    var oldY:Number;
    oldY = 0;
    }
    - The right of the People to create Flash movies shall not be infringed. -

  11. #11
    Senior Member
    Join Date
    Nov 2001
    Posts
    174
    oooo, touche!

    Thanx for the help dood

    Cheerz,
    Dwayne

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