Forum Topic: "any" function?

(98 views • 6 replies)

This topic is 1 page long.

<< < > >>
None

prut97

Reply To Post Reply & Quote

Posted at: 1/31/09 06:28 PM

prut97 LIGHT LEVEL 09

Sign-Up: 09/22/07

Posts: 174

I need something that defines "anything" so i can make like

if(var1 == "example"+ANY){
BLAH
}

So if it was "example4424" it would work or even "examplefas1233234sffs".

Understand what i mean?

thank you! :D


None

BillysProgrammer

Reply To Post Reply & Quote

Posted at: 1/31/09 06:32 PM

BillysProgrammer LIGHT LEVEL 16

Sign-Up: 09/17/08

Posts: 2,233

var i=Math.ceil(Math.random()*500);
if(testText == returnText+i) {
     //actions
}

That a example, but i could be anything.


None

Kenney

Reply To Post Reply & Quote

Posted at: 1/31/09 06:34 PM

Kenney NEUTRAL LEVEL 17

Sign-Up: 03/16/02

Posts: 2,354

Flash doesn't have wildcards so it's not easily possible.

Visit my website: Kenney.nl


None

BillysProgrammer

Reply To Post Reply & Quote

Posted at: 1/31/09 06:35 PM

BillysProgrammer LIGHT LEVEL 16

Sign-Up: 09/17/08

Posts: 2,233

Then I didnt understand what he meant :P


None

x33905

Reply To Post Reply & Quote

Posted at: 1/31/09 06:40 PM

x33905 NEUTRAL LEVEL 05

Sign-Up: 02/06/06

Posts: 211

I'm sure there's probably a better way and this is a bit clunky, but its the only thing that comes to mind.

var testWord1:String = "Test";
var testWord2:String = "TistTest";
var sameWord:Boolean = false;

for(var i:int = 0; i<testWord1.length; i++)
{
	if(testWord1.charAt(i)!=testWord2.charAt(i))
	{
		sameWord = false;
		break;
	}
	else
	{
		sameWord = true;
	}
}
if(sameWord == true)
	//Your actions here

None

Nano256

Reply To Post Reply & Quote

Posted at: 1/31/09 06:46 PM

Nano256 DARK LEVEL 13

Sign-Up: 02/12/05

Posts: 1,473

You could truncate everything after example by doing something like this:

var blah:String = "example12345FUCK YOU!!!! TEST SHIT";
trace(blah.substr(0,7));
//traces 'example'

http://help.adobe.com/en_US/AS2LCR/Flash _10.0/help.html?content=00001557.html

Move on to ActionScript 3.0 already!
The third post below this one is a lie.

BBS Signature

None

x33905

Reply To Post Reply & Quote

Posted at: 1/31/09 06:52 PM

x33905 NEUTRAL LEVEL 05

Sign-Up: 02/06/06

Posts: 211

Yeah, definitely a better way.

var test1:String = "test";
var test2:String = "test2";

if(test2.substr(0, test1.length) == test1)
	//Your code here

All times are Eastern Standard Time (GMT -5) | Current Time: 10:46 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!