PDA

View Full Version : Help with input boxes please.


anarhistu
10-10-2005, 08:38 AM
I have a flash movie to be used on a cd.
I have a number variable in it, and I want to reset an input box to the number if the value inputted is bigger than the number.
Please help me, I have no idea what I am doing wrong(maybe more things, ;) i'm new to this ).

The source can be found :
eee.fla (http://www.ubbcluj.org/files/eee.fla)

So, the first input box is the one that doesn't work.I need it to work like the second one, without hardcoding the number there, using variable numar.

All the other files can be found at www.ubbcluj.org/files

Thank you,
Matei

Paerez
10-10-2005, 06:08 PM
I couldn't open the file, I got "Unexpected File Format" :(

But here is how to do it, in general:

anarhistu
10-12-2005, 01:51 PM
Yup, your method works, I was using an 'older " one , but I still got the same problem.

The box won't reset as needed.
i am reading a number from a file.And i want it to reset if the value its biggeer than the number.

What it does it's this:

It checks if the input is bigger in a "string-ish letter by letter mode"
Like: 7 >16 but 154374632746237463782<16 , cheks character by character.

Please check out the flash file in the first link, I saved it in flash mx format.
Thanks.

Paerez
10-12-2005, 02:31 PM
Do you want it to evaluate in the Stringy way or the Numbery way?

anarhistu
10-13-2005, 02:22 PM
I want it to evaluate as a number, it will be the number of pics available.

Thanks for the reply

ovydiu
10-13-2005, 02:33 PM
it's simple, just use the Number function, like this:
trace(Number("154374632746237463782")<Number("16"));
trace("154374632746237463782"<"16");
the output will be

false
true

Paerez
10-13-2005, 02:59 PM
Ohh, I didnt know about that. Cool. I thought the only way was to strict type them. Thanks

anarhistu
10-13-2005, 06:14 PM
Ovi, I tried that before and it doesn't work.
The exact code atm is:


//initialize variables and properties
square._alpha = 0;
//starting picture
var whichPic:Number = 1;//with or without the type, the same...
//var numar = new Number; /...no effect
var numar:Number=_root.myData.nr;//taken from a file.
trace(numar);

var myListener = new Object();
myListener.change = function(event) {
if(event.target.text > numar) { //14>135452342534256 and 14<2 hmm....
event.target.text = numar;
}
}
input.addEventListener("change", myListener); //listener works...
input.restrict = "0-9";//restricted, works well

//initiate change to new image when buttons are clicked
next.onPress = function() {
if (whichPic<12 && !fadeIn && !fadeOut) {
fadeOut = true;
whichPic++;
input.text = whichPic;
}
};

//
back.onPress = function() {
if (whichPic>1 && !fadeIn && !fadeOut) {
fadeOut = true;
whichpic--;
input.text = whichPic;
}
};

_root.onEnterFrame = function() {
// when a new Photo is selected, fade out, load new image, and fade in
if (square._alpha>10 && fadeOut) {
square._alpha -= 10;
}
if (square._alpha<10) {
loadMovie("/Wallpaper/image"+whichPic+".jpg", "square");
fadeOut = false;
fadeIn = true;
//input.text=whichPic;
}
//
if (square._alpha<100 && fadeIn && !fadeOut) {
square._alpha += 10;
} else {
fadeIn = false;
}

//change image when Enter key is pressed
if (Key.isDown(Key.ENTER)) {
fadeOut = true;
whichPic = input.text;
}
};
// if a number is entered in the input field but Enter is not pressed, change
// back to current Photo number when clicking anywhere else
inputField.onKillFocus = function() {
input.text = whichPic;
};
stop();

Any other ideas?You can also find the code in www.ubbcluj.org/files, it's named eee.fla

Paerez
10-13-2005, 08:18 PM
if(Number(event.target.text) > Number(numar)) { //14>135452342534256 and 14<2 hmm....
event.target.text = numar;
}

Thats what he meant. You just implemented it wrong.

Also, its not:
numar = new Number;

its:
numar = new Number(numar);

anarhistu
10-14-2005, 01:40 PM
Thanks, I did it at last.The variable declaration was wrong, I am in computers college and I am working in 5 or 6 programming languages atm,and I got kinda confused .Also, I started the project with 0 knowledge of as.

Thanks.