To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > Flash Help > Flash Newbies

Reply
 
Thread Tools Search this Thread Display Modes
Old 07-14-2004, 01:36 AM   #1
kellynoky
Junior Member
 
Join Date: Jul 2004
Posts: 5
string comparsion problem

Hello there,

I got here a string comparing problem (or I think it is). I try to random generate a number and, say I will drag that number over some other instances, when that number match a instance's name, it will shows "correct"
Now, I got a object instance called a07.

on (release) {
display = substring((Math.random()), 1, 3);
}

Occasionally, display will equal 0.7
Now, with the following coding,

hello = "0." + substring(this._droptarget, 4,1);
// where this.droptarget is the instance a07
if (hello == display) {
_root.green_box.gotoAndStop(2); //Let's say it do stuff A
} else {
_root.green_box.gotoAndStop(3); //Let's sat it do stuff B
_root.a07.gotoAndStop(3);
}

hello should equal 0.7 as well. However, everytime I drag the number over a07, it will do the else part rather than the if part. I must have misunderstand something about the string class...


Could anyone help me here? Thank you very much.

Kelly
kellynoky is offline   Reply With Quote
Old 07-14-2004, 02:48 AM   #2
Phlook
Run for your life!
 
Phlook's Avatar
 
Join Date: Jul 2003
Location: Vancouver, Canada
Posts: 679
try using some tracing, ex

code:

hello = "0." + substring(this._droptarget, 4,1);
trace(hello);
// where this.droptarget is the instance a07
if (hello == display) {
trace("yes it equals display");
_root.green_box.gotoAndStop(2); //Let's say it do stuff A
} else {
_root.green_box.gotoAndStop(3); //Let's sat it do stuff B
_root.a07.gotoAndStop(3);
trace("oh no, it doesnt equal display");
}



see if it's actually running that or if theres some problem
oh, and use the [/as] [as] tags for code (i put them in wrong order so they dont work
Phlook is offline   Reply With Quote
Old 07-14-2004, 06:32 PM   #3
kellynoky
Junior Member
 
Join Date: Jul 2004
Posts: 5
gobal variable???

Hello there,

Thanks for the advice. I tried the trace line, and it ends up the display has NOTHING in it...empty string..... but it appear on screen all right. I have look at my display variable, which is a single line dynamic text. I wonder if this is the problem, something like local variable which can't be use outside the function. I was looking at the ActionScript manual, whcih said you can use either setVariables action or (=) assignment to set a gobal variable, which I already did
code:
on (release) {
display = substring((Math.random()), 1, 3);
}



Am I doing something wrong?

Kelly
kellynoky is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > Flash Help > Flash Newbies

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:02 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.