Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Strings; How Can I Determine The Number



How can I determine the number between commas to find out if the pattern is 2, 3 or 4 characters between each comma.
var str:String1 = 01,03,12
var str:String2 = 001,003,012

String1 = 2;
String2 = 3;

Looking at the Help within Flash I see it may be the 'Index of" method or Substr method.


Thanks,
P.



FlashKit > Flash Help > Flash ActionScript
Posted on: 03-03-2008, 10:45 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Can You Determine Number Of Clicks In A Button?
Hello,

How do you disable the second click of the mouse so the event works on a single click? Or how do you program it so it works on both single & double?

Seems that when users double click on a button to launch a video in my movie, the second click cancels the command, and the movie doesn't play. But the video plays with one click only.

Can you disable the second click from registering somehow?

Thanks!

Simple Question How Would U Determine If A Number Is Even Or Not Using Code?
This is a fairly simple operation in other codes but how to do it in ActionScript is allouding me

apprecate the help

Determine Movie Clips By Number Of Variables
I am going to be setting up an html form for a user to select up to three options. After the form is submitted it will take the user to a flash file where it will display up to three MC's. The flash file will pull in the variables from the previous form and display the corresponding MC's.

How do I set up the flash file to know how many variables are being pulled in and in turn display the corresponding amount of MC's?

Flashvars -- How To Determine Number Of Parameters Passed?
Hello,

I would like to know how many parameters were passed via Flashvars? Can someone explain?

Thanks,

Nilang

Using An Array To Determine The Number Of Files In Folder
I'm trying to build an array in actionscript that will be able to look at a folder and add its contents to an array. after the array is built, I want to be able to determine how many items are in there. I can't find a way for an array to do this dynamically. has anyone ever been able to pull this off?

I'd love to hear suggestions

Determine Number Of Lines In A Textfield Before 'maxscroll' Has Changed ?
Hi there,

I'm trying to determine the number of lines of text in the (dynamic)textfield before the 'maxscroll' value has changed or the textfield is full.
Normaly you would determine the lines of text by adding up the 'maxscroll' value with the number of ('possible') lines in the textfield, right?
But how to determine the number of lines any time? Character width is variable so... Any suggestions?

ThanX, cYa.

Determine An Exact Frame Number For Use Inside A Movie Clip
Hi,

I am creating a big movie that has multiple scenes. However, I want a navigational bar on the side, so I used a single movie movie clip that I placed inside each scene. However, I can't get the root movie to go to the correct frame by using this code inside that movie clip:


Code:
_root.gotoAndPlay("Scene Name",1);


It will only take a number like this:


Code:
_root.gotoAndPlay(435);


I have been getting the exact frame number from the size report, however this is time consuming. Is there a way for my player to get calculate this exact frame number and store it to a variable that I can use inside this movie clip?

This would make my life a whole lot easier.

Jeff

COuld Someone Please Show Me How To Determine An External Loaded Movies Frame Number?
HI,

I would be most greatful if someone could assist me with my problem here, my project cannot progress until i have resolved it - and i have been searching and searching for an answer.

To most, this question will seem basic probs, but to me... i havent grased the ideas yet.

I am using a loader component, instance named 'loader' to load in an external swf, called 'mc_1'.
I can load it in fine, and even have a progress bar - but my plight is two fold.

Firstly, and the most important - i want another event to trigger at the end of when the loaded movie has 'played' - and i do not know how to determine when the loaded movie has reached the ends of its internal timeline. PLease could someone assist me. I tried using the currentframe command attached to the 'loader', i.e. loader.currentframe - but when i do a trace it keeps saying that the frame is '1'. My logic is telling me, thats because in affect, the loader component im using does only have 1 frame - its actually the loaded in movie that contains the frames. So how do i actually access the frame number of the movie loaded into the loader component (man.. sorry if i repeated myself there a bit - im finding this quite difficult to explain)

Also... when a movie has loaded in using the loader component, how do i only get it to play when i require

I would be most greatful if someone could spend a little time here and help me

Thanks
Steve

[F8] Need Script Assist: Variable To Determine Frame Number MC Stops On...
Fellas,

I want to use a variable set at root to determine the frame that a movie clip stops on.

variable='langue'
values of 'langue'= 0,1,2,3,4,5,6,7,8,9 &10 etc (numerical)
frame labels correspond to values

so: tell the movie clip 'x' using onLoad to go to the frame no. corresponding with the value of 'langue'.

Any takers?

Yours faithfully,
A.Designer

Strings To Number Cast
I'm having a brain fart and I can't think of a way to change a string "6" that I loaded off XML into a number that I can process. Can someone throw me a line, while I go get some caffeine?

Array + Number In Strings In Function
Hi again!

This time I want to use ONE function with different inputs, but. Take a look at the two code examples below. testA does NOT work though testZ and testX does work.

Here is what I got from tracing the values from inside testA. All pretty obvious exept the bottom one.


Code:
trace(aCirclePic);//Circle00,Circle01
trace(nCirclePic);//0
trace(aCirclePic[nCirclePic]);//Circle00
trace(sArrayPic);//aCirclePic
trace(sNumberPic);//nCirclePic
trace(sArrayPic[sNumberPic]);//undefined
What variables am I suppose to use to get it to work with just one function. Obviously this is a very simplified example…


Code:
var aCirclePic:Array = new Array("Circle00", "Circle01");
var nCirclePic:Number = 0;
var aBoxPic:Array = new Array("Box00", "Box01");
var nBoxPic:Number = 0;


testA("aCirclePic", "nCirclePic");
//testA("aBoxPic", "nBoxPic");

function testA(sArrayPic:String, sNumberPic:String):Void {
this.attachMovie(sArrayPic[sNumberPic], sArrayPic[sNumberPic], this.getNextHighestDepth(), {_x:10, _y:10});
}


//testZ();
//testX();

function testX():Void {
this.attachMovie(aCirclePic[nCirclePic], aCirclePic[nCirclePic], this.getNextHighestDepth(), {_x:10, _y:10});
}

function testZ():Void {
this.attachMovie(aBoxPic[nBoxPic], aBoxPic[nBoxPic], this.getNextHighestDepth(), {_x:10, _y:10});
}

Storing A Large Number Of Strings
Hello,

What is the best way to store a large number of strings in Flash for use in
a quiz? I want to create a quiz of about 100 questions, but select these
questions from several hundred during runtime. I was thinking of storing
the strings in an offscreen text object, but didn't know if this was the
best approach. I also thought of a database, but don't think it is
necessary. Any ideas? The Flash movie will be used as a sprite inside of
Director, but I don't want to pass the strings through a function call.

Thanks in advance,

Brian

Prob With Comparing Utf-8 Enc Loaded Strings With Other Strings
I load a bunch of strings from a MySQL database. Those strings have been utf-8 encoded before being put there. When I load one of the strings and compare with a string defined inside flash it works great as long as the string doesnt have more than one word. Two words or more doesnt work.

So loaded string "Oil and vinegar" isn't equal to the internally set string "Oil in vinegar" according to flash, although it is utf-8 encoded in the database...

blablabla load string "Oil and vinegar" from db into var words

if (words == "Oil and vinegar") { blablabla }
but this condition never evaluates as true....

What am I doing wrong?

Shared Object To Store A Unique Id Number Var And Frame Number Var
Hi, I am a complete novice to action script when it comes to objects. I know what I want to do is done with the shared object. Basically I want to create a tutorial that stores a cookie on the users’ machine with a unique id variable telling flash what frame the user was at last. When the user revisits it would prompt "continue where left off or start the tutorial over. I read the action script dictionary regarding the shared object, but being a designer I really need to visualize it before I can comprehend this.

Thanks,

Justin

Limmiting A Number To A Certian Number Of Decimal Places
Ok for a currency i have

gold.silver which is the same as say 1.35g with 'g' being gold

When I calculate with tax it often goes to 10 decimal places. How do I limmit the amount of decimal places that it can access?

Random Number Then Delete Number Till Reset
Last edited by pixcels : 2006-10-18 at 22:41.
























I am trying to create a type of quiz thing. It is a stand alone move and can not have anything loaded into it.

Problem:
I need a random item from an array, then after the item is displayed I need it to delete itself so that it will not show again. After the array is down to the last item it calls in the array again and starts all over.

Below is code that I have found but it does not delete the array item after it has been show from the array, or restart.


Code:
Array.prototype.shuffle = function() {
var shuffledArray = [];
var copyArray = this.slice(0);
for (var j = 0; j<this.length; j++) {
randomNo = Math.floor(Math.random()*copyArray.length);
shuffledArray[j] = copyArray[randomNo];
copyArray.splice(randomNo, 1);
}
return shuffledArray;
};
testArray = ["1", "2", "3", "4", "5", "6", "7"];
newArray = testArray.shuffle();
//Text area component
theText.text = "newArray = "+newArray
//Button component
theBtn.onRelease = function(){
newArray = testArray.shuffle();
var tempArray = Math.floor(Math.random()*testArray.length)
var totalArray = Math.floor(tempArray+=newArray[0])
var slicedArrary = tempArray.splice(0)
theText.text = "newArray = "+newArray[0]
}

AS2 - Image Set Number Of Rows/dynamic Colum Number
I have a simple image gallery that is loading images in, creating movieclips, and then lining them up into 3 columns and rows. This woks fine as long as there is only 9 images, but I have more then that. If I have it pull more then the 9 it adds in more rows I need it to add in more columns no more rows.

Here is the function that creates the gallery:
title_array is the array of images.

Code:
function createGallery() {
nbrColumns =2;
leftMargin = 7;
topMargin = 5;
cellWidth = 165;
cellHeight = 165;
//thumbnails.setMask(albumHolder.albumHolderMask);
for (i=0; i<title_array.length; i++) {
thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
var cellX = i % nbrColumns;
var cellY = Math.floor(i / nbrColumns);
thumbHolder._x = leftMargin + cellX * cellWidth;
thumbHolder._y = topMargin + cellY * cellHeight;
thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 0);
thumbLoader.loadMovie(title_array[i]);
}
}

Script To Change Number To Formated Number
Hi, is there a free script to change a number to formated number (u know with dots and commas)
I know I probably can make my own.. but.. i'm in a hurry
thanks

Round Number To Next Number That Has Only Zeros Behind It (ie: 20, 100, 3000)
I want to make a graph and I want the highest number in the graph to be a solid figured number.

so if the highest part that needs to be graphed is 12,000 I want the graph to go up to 20,000 ( the next highest number with only zeros behind it.)


for instance I want to round:
11 to 20
253.3454 to 300
4500001 to 5000000


I am sure I neet to use Math.Ceil() in combination with something else but I am unsure how?

any suggestions?

THANKS!

Random Number Variable That's Different From Previous Number
I have this line of code in my game that works great. However it would work even better if when it the code was executed the next random number was not the same as the one before it. For example if "speech" is on frame 6 when the code is executed I would like the random number to be between 2 and 12 but not 6. (I don't want the same frame to come up as it confuses the kindergarteners and preschoolers using the program.) Here's the code that's working for me now.


ActionScript Code:
speech.gotoAndStop(Math.floor(Math.random()*11)+2);

Need Urgent Help How To Check If The Generated Number Is A Whole Number
Hi,
I have a simple issue but I need some assistance. I am calculating a number and the result number sometimes a whole number but in some cases decimals are present. Decimals do not need change but whole numbers need to change. So for example if the end result is "6" I need it to show it as "6.0" in a field beacuse that is the way the calculator should display it according to request.
How can I check that the result number is a whole number and then add ".0" to it?
I just included a simple script below.

if (outputnumber == ?) {
resultNum = Number(String(outputnumber+".0"));
} else {
resultNum = outputnumber;
}

Thanks,
Attila

Method To Check If A Number Is A Decimal Number?
i was wondering if there is any method to check if a number is a decimal number or not? i searched in the help-panel, but didn't found something...please help!

TextField - Number Of Lines, Number Of Characters
Hello,

I'm trying to get some insight on the textField object in flash.

I know how to get the textfield length and number of characters. But I need to know more.

Is there a way to get the number of characters on a line in a multiline textfield?

Thank you in advance.

How To Determine The End Of A Loaded SWF
I am loading an SWF into an empty movie clip in scene 1.
Scene 1 has only one frame. I would like to advance to the second scene after the loaded SWF finishes its animation.

How can I determine the end of the SWF so that I can move on to the second scene?

Thanks in advance for anyone with ideas.

Variables To Determine The URL... How?
I am creating a Bible Research site that will allow people to compare different versions of the Bible side by side with other versions of the Bible.

Here is my problem...

In the flash I have 3 things that the user inputs...
Version (version of Bible, NIV, KJV)
Book (Genesis, Exodus)
Chapter (1,2)

Now there is also a button that activates the search and gets the page. It is titled "research"

Now when you click research it needs to get a URL. The URL is supposed to be this...

/(Version)/(book)/(Chapter).html

or here is an example

/NIV/Genesis/1.html

Now how do I make the Get URL command to read all 3 variables to determine the URL?

Any help woudl be appreciated... thanks

How Can I Determine An MC's W/ DuplicateMovieClip()?
If I'm duplicating an MC, how do I get half the duplicated clips to show up in white (for example) & the other half to show up red ?

How Does One Determine What Size
I am just starting to think about my first Flash web site. Flash has a default of 400 x 550. For the web to be viewable nicely on a web page, what is a good size to set the stage?

Thanks!

Determine Bandwidth?
I'm trying to figure out how to determine the bandwidth of a visitor so that I can route them to an appropriate file for their bandwidth from WITHIN the flash file.

Anyone know a site where I can learn this?

Load .swf - How Determine Which Swf Is Above Which?
Hello again,

it seems i've found what i was surching for... the answer of my earlier thread concerning loading and uploading was:

loadMovieNum ("something.swf", 1);

This allows me to load a swf into a main swf! Up to here great! But what are the levels - the "1" in the script here above. In fact my second swf loads above the main but should be under. What can i do?

Determine SWF Played Once
I am looking for a script that can be used to determine if an SWF file has been played or not.

We want it to be played once on the first visit to the site and when a user returns on the same day it would either load another file or have a 'Play Again' button in the swf file...

Going to update the swf every few days or even daily on a basis.

Any suggestions?

How To Determine Maxscroll?
I am using Flash MX (on Mac OS 10.3 if that makes any difference).
How do i get teh maxscroll value of my dynamic text boxes?
Each time i use the trace method i ALWAYS get a return value of 1.
I am stuck
Please unstick me

Thanks

Determine When .jpg Loaded
Hi there,

I have used the function LoadMovie to load an external .JPG to a target movie clip instance in my flash.

Is there any way that I can determine when the external .jpg has finsihed loading into flash before I contine to the next frame?

Thanks!

(using MX2004)

1st MC Able To Determine Position Of 2nd MC
I've searched all over the forum but I couldnt' seem to find the answer.

What's the variable for one Movie Clip to find the position of another Movie Clip?

Such as
If (_root.hero x position < enemy)) {
do this ()

I'm using flash mx btw.


Thanks in advance

Determine Source FLA Of SWF?
More legacy code woes...

I have a number of SWFs, and multiple FLAs (from various SourceSafe versioning branches) which may have created them. I need to know which particular FLA "version" built which particular currently-used SWF. The previous team was out of control so it's not unusual to have 5 or 6 FLAs that all claim they built a certain SWF. (I particularly like "player_john.fla" and "player_bob.fla", both in the same folder, both pointing to the same SWF file, both with similar save dates, and both with same functions, but radically different code. Welcome to my wonderful world! )

Short of publishing every single FLA and doing a byte compare on the results (and even that's not accurate) does anybody know of an easy way to determine which particular FLA actually built the SWF I'm currently using?

The best idea I've come up with so far is loading the swf into an empty movie, and running a debug to get all the objects and functions, and then openeing up each FLA and comparing them. Tedious, and not always guaranteed.

I know the FLAs tend to store physical pathnames of where they were when they were built, so I'm hoping maybe there's some kind of identifer that also get compiled into the SWF???

Determine Path To Swf
Hello,

Is there a way to determine if the swf file is playing back from a local file:/// or server http:// location in AS3??

Happy Thanksgiving!

cheers,

frank grimes

How To Determine Type Of FLV
I am working on a project where I am receiving FLV files from a client to integrate into a Flash application.

The FLV files should have transparency but they do not. I am guessing that the client encoded them (exported from After Effects) with the codec set to Sorenson Spark, rather than On2 VP6 -- which is what we need. So I want to verify this and see if that is the problem.

However, I haven't seen any tool in Flash that will report the codec of the existing FLV. Can someone tell me how this can be done, either in Flash or with a 3rd-party tool?

thanks,
BR

Can Flash Determine The Url, Like PHP?
I want my swf to be able to dynamically determine which URL iT is being displayed on, and send the info to me.

Like using the following in PHP:
$_SERVER['PHP_SELF']

How To Determine TotalTime
hi

How to determine totalTime of the FLV file,if there is no MetaData in that file?


Please Help
thanks

Determine If One Clip Is Between Two Others?
Hey,

I need to find a way to determine if one movie clip is between two others, spatially speaking.

Details: I have a movieclip that the player controls with 'WASD'. I want to be able to click on another movieclip (the enemy), and perform actions, BUT only if there is not a wall between the two. How can I determine this?

I've tried using the .lineTo function, drawing from the player to the mouse that would presumably be on the enemy upon clicking, but then how do I hitTest that line to see if there is a wall between the two?

I have spent soo much time looking for a way to make this work, with no success. Any suggestions?

Determine The Instance
hi there.
i am doing a searching algorithm, so let's say the path is from A to B to C and finally D (A->B->C->D)
and it is represented in an array, such that path={"A", "B", "C", "D"};

how can i link these four elements to redim as instances on the desktop, such that i have four instances, named A, B, C, D, and also the line which connected to one of the each other, named AB, BC, CD.


for instance,
how to set the color line AB, BC, CD? (the array always can be in different set of answers.)

before that someone told me dont use the double quotation, but i think that's not working with my program, further more, i need to combine two elements, which represent the line connected to two ends.

Is there beter way?

Hope to get help ASAP.. thanks.

Determine Flash?
I am using a flash to keep and scroll a current list of new posted items for sale at a auction site , I have, it works great, but I cant figure out how to tell it that if users dont have flash to leave it blank, now Iam also using a perl script for the site but the section for the flash is in html. Below is a copy of what i insert in my html code. Some users dont want to be bothered with flash and never say yes, this would keep me covered both ways, any ideas?


PHP Code:



<p align="center"><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="$config{'tickerwidth'}" HEIGHT="$config{'tickerheight'}" id="ticker">
<param name="_cx" value="5080">
<param name="_cy" value="5080">
<param name="FlashVars" value="-1">
<param name="Movie" value="$config{'tickerswfurl'}?url=$config{'tickertxturl'}&speed=$config{'tickerspeed'}&font=$config{'tickerfont'}&color=$config{'tickerfontcolor'}&size=$config{'tickerfontsize'}&width=$config{'tickerapproximatewidth'}&heighttuning=$config{'tickerheighttuning'}">
<param name="Src" value="$config{'tickerswfurl'}?url=$config{'tickertxturl'}&speed=$config{'tickerspeed'}&font=$config{'tickerfont'}&color=$config{'tickerfontcolor'}&size=$config{'tickerfontsize'}&width=$config{'tickerapproximatewidth'}&heighttuning=$config{'tickerheighttuning'}">
<param name="WMode" value="Window">
<param name="Play" value="-1">
<param name="Loop" value="-1">
<param name="Quality" value="High">
<param name="SAlign" value>
<param name="Menu" value="0">
<param name="Base" value>
<param name="AllowScriptAccess" value="always">
<param name="Scale" value="ShowAll">
<param name="DeviceFont" value="0">
<param name="EmbedMovie" value="0">
<param name="BGColor" value>
<param name="SWRemote" value><embed src="$config{'tickerswfurl'}?url=$config{'tickertxturl'}&speed=$config{'tickerspeed'}&font=$config{'tickerfont'}&color=$config{'tickerfontcolor'}&size=$config{'tickerfontsize'}&width=$config{'tickerapproximatewidth'}&heighttuning=$config{'tickerheighttuning'}" quality="high" bgcolor="$config{'tickerbg'}" WIDTH="$config{'tickerwidth'}" HEIGHT="$config{'tickerheight'}" NAME="ticker" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
</OBJECT> 






Thanks

Determine Whether SWF Or EXE Is Running...
I'd like to publish an SWF and EXE from the same FLA project and be able to detect which one is running. Anybody know how to detect this?

I've been unable to find documentation on determining the current movie's file name or file type. Thanks for any help!

Determine The Width Of Characters
Is there a way to determine the width of a single character in a Flash5 text element? I want to split up text elements into single characters and position them one by one on the stage so that they appear as if they were one string with correct character spacing.
Unfortunatelly the _width property of normal text elements in flash is only the width of the box the text flows in, not the width of the content itself.

Determine Whether Music Is Playing Or Not
hey guys, if i can get this, i can get my sound toggle to work. all i need to know, is if there is a statement, to say whether the music is on or off.
something to fill in this blank...
musicOn = music1.______();

in the blank i need a function to determine whether the music is on or off. pls help. much appreciated

Determine Which Page Wil Open11111
I am currently making a site, and I need to know how to do this. I have one html page that is the Flash movie and another page that is just a gif. I have an index page that I want to determine if somebody has the Flash player or not. If they do it will take them to the flash html page, if not it will go to the gif html page. The index page cannot be viewed though, it just has to jump to the appropriate page without the user knowing.

Thank you

Determine Wheater A Url Exists
I, like a dummy, told my boss that I could write a program to check all of my jobs webs sites availablity status automatically. After checking weather it was up on, it would generate a report.

I thought I could do something like:

Open/Get the URL.
Select the Case .Status
Case 200 'No Problem'
Responce .Write "URL is valid and available"
Case 404 'Not Found'
Responce.Write "URL not found"
Case Else
Responce.Write "An unexpected Status Value was returned"
End Select

I hope someone can help me. Txs. Candy

Using Variables To Determine GotoAndPlay’s, Why Not?
OK, here’s the deal. A scene with 4 buttons that leads to 4 different pages. When a button is pressed (different from the one which page is showing) the page part animates into the page which button was pressed.

This would be possible if my variable theory would work, but for some reason it doesn’t.

When a button is pressed is that a variable is set and a gotoAndPlay so the current page animates out making room for the new one.

Design button:
on (press) {Desing=”true”; gotoAndPlay (2);}

Projects button:
on (press) {Projects=”true”; gotoAndPlay (2);}

At the end of the ‘animating out’ sequence I do a variable check to see where to jump according to which button was pressed.

if (Design=true){goAndPlay (21);} if (Projects=true){gotoAndPlay (31);}, and so on.

When the cursor arrives at the new page and stops, all the variables are set back to false awaiting the next button press.

Design = "false";
Projects = "false";
Stop O;


To me it sounds like it should work, but what happens is that the cursor jumps to the last of the 4 pages whichever button you pressed. It animates as it is supposed to, but it always ends up at the last page.

So, what is wrong with my theory? And is it any other way to do this?

Thank you for helping me.

Flash MX: Determine Colour
Hi!

Is there any way to determine the colour of a certain point (coordinate) on the flash stage (Flash MX)?

Thanx

cros

Determine The Length Of A Preloader Bar
i have a mc called bar which is a preloader bar that grow using this script 1st frame

this._xscale = ((_root.getBytesLoaded()/_root.getBytesTotal())*100)

goto and play 1 on the 2nd frame

the bar grow but i have no control

how do i fix or control the bars total length!!

cheers rat

Copyright © 2005-08 www.BigResource.com, All rights reserved