-
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
-
Senior Member
Test if any of the variables are undefined.
- The right of the People to create Flash movies shall not be infringed. -
-
Do you get any error messges or does nothing happen at all.
-
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 :*(
-
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!!
-
Senior Member
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. -
-
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
-
Senior Member
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. -
-
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
-
Senior Member
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. -
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|