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




AS2.0 Count Number Of Children In A Movie Clip



I recently made a post similar to this one with little response so maybe someone can tell me this:

How do you count number of children in a movie clip?

i would like to be able to target each child but if you could at least tell me how to find the total number of children, that would be one step closer

thanks



FlashKit > Flash Help > Flash ActionScript
Posted on: 11-11-2008, 04:51 PM


View Complete Forum Thread with Replies

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

AS2.0 Count Number Of Children In A Movie Clip
I've seen plenty of articles on AS3 for doing this, but is there _any_ way of doing this in AS2? I've need to loop through every child mc within several other mc's and change their colour... but cannot find any way of doing it (or anything confirming it can't be done!).

Count The Total Number Of Children
I recently made a post similar to this one with little response or help so maybe someone can tell me this:

How do you count number of children in a AS2.0 movie clip?

in AS3 ==> var totalChildren = mc.numChildren;

i would like to be able to target each child but if you could at least tell me how to find the total number of children, that would be one step closer

thanks

Count The Total Number Of Children At The Root Level
Can anyone please help me find the total number of children in an AS2.0 movie clip?

I don't know the instance names of the children b/c i will not have access to the swf i am loading (user uploaded)

So i need to be able to loop through all mcs at the root level and poll each for totalframe property

any help would be so awesome!
thanking you

How To Count Children?
I'm getting a little confused here!

I am loading a picture on a frame, and then fading it in, here is the code:
Code:

import fl.transitions.Tween;
import fl.transitions.easing.*;

var fadeIn:Tween;
var mainPicArea:MovieClip = new MovieClip();
var mainLoader:Loader = new Loader();
var mainRequest:URLRequest = new URLRequest("picture.jpg");

addChild(mainPicArea);

mainLoader.load(mainRequest);
mainLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, mainLoaded);

function mainLoaded(event:Event):void
{
   mainPicArea.x = mainPicPlacementX;
   mainPicArea.y = mainPicPlacementY;
   fadeIn = new Tween(mainPicArea, "alpha", None.easeOut, 0, 1,12, false);
   mainPicArea.addChild(mainLoader);   
   
}



The problem I'm having now is, I want to do a test if the picture is loaded, because if I try to remove a child if there is no child - I get an error. I tried finding the number of children by tracing "mainPicArea.numChildren" but I keep getting zero?

Target All Movie Clip Children?
Hi....

I need to target all children of a movie clip for removal...is there any way to do this?

Obviously movieclip.length doesn't return anything...isn't there anything like "childNodes" for an XML file to find the children?

Alternatively if there were something similar to wildcards in the referencing system.... something like movieclip["clip"+ *] ... or along those lines...

Any ideas?
Thanks

Removing Multiple Children From A Movie Clip
Hi,
First off thanks for reading , am having a problem. I'm making a gallery which uses a bit of XML to place three images into a movie clip in the centre of the stage. On the stage i have 4 buttons which tell the following code to load a different XML file and add three different images to the clip (called 'container1').


ActionScript Code:
//--XML IMAGE LOADER--//
function xmlLoaded(event:Event):void {
    xml = XML(event.target.data);
    xmlList = xml.children();

    for (var i:int = 0; i < xmlList.length(); i++) {
        imageLoader = new Loader();
        imageLoader.load(newURLRequest(xmlList[i].attribute("source")));
        imageLoader.x = i * 141
        container1.addChild(imageLoader)
    }
fadeTween = new Tween(container1, "alpha", None.easeNone, 0.2, 1, 0.7, true)
}

The problem comes when it fades (want to do this to avoid the jerking due to loading time) into the new images as the old ones are still there and you can see them with the reduced alpha. Is there a way to get the old images out of the clip when i press any gallery button? or perhaps there is a way to only display the movie clip when a gallery button is pressed after a timer delay set long enough for all of the new images to fully load over the old?
Have searched for a while to find a solution but cant seem to, any help greatly appreciated!!!

Movie Clip Loses Children After GotoAndStop()
Hello,

I have a .SWF that I load with multiple scenes. The first scene has a button on it called "start".

When I first start the app, I can call mMovieClip.start.visible = false;

But if I then call gotoAndStop(1, "scene2") then go back gotoAndStop(1, "scene1"), I can no longer access mMovieClip.start because it is now NULL.

Any ideas why? Workarounds?

[AS3] How Do I Load External Images Into A Movie Clip Then Add Children?
This is what I used in AS2:

Code:
importImgs(40);
function importImgs(fNum:Number):Void {
for (var i = 1; i<=40; i++) {
this.createEmptyMovieClip("mHolder"+i,fNum);
eval("mHolder"+i).createEmptyMovieClip("m"+i,eval("mHolder"+i).fNum);
var mLoader:MovieClipLoader = new MovieClipLoader();
mLoader.loadClip("img_"+i+".jpg",eval("mHolder"+i));
fNum--;

}

}
This just added each image to the stage, one on top of each other.
I would then fade the first image out, revealing the one below; creating a simple slide show of sorts.

I quickly realized having all the clips visible and on screen at once wasn't the most efficient method.

I've since switched to AS3 and need help achieving the same affect.

I've read of adding "children" to a container.
This seems to be what I need. Unfortunately the examples I've found only deal with 1 container and one child. I'm not sure how to add children so that I may loop through them later.

The desired affect I'm looking for:

An img loading function which will load 3 images at a time until all files are loaded. (essentially preloading)

Adding each image as a child to the main container and set its visibility to false so they are not all visible at once.

I could then make visible two of the images, and fade out the one on top revealing the 2nd image. I would then do this throughout the images in a cycle.

The end affect will look more like a movie than a slide show, as I have to cycle through about 40 sequential images to simulate motion.

I hope this makes sense.

I believe I have the fading technique covered,. I just need help figuring out how to get the elements loaded so i can loop through them.


Thanks in advance

Steven

How Can I Know The Number Of Children Under A XMLNode?
Is there any method to know the number of children under a particular XMLNode?

Total Number Of Children
Can anyone please help me find the total number of children in an AS2.0 movie clip?

I can do this in AS3.0 like so:

Code:
for(var i:uint=0;i<mc.numChildren;i++){
trace("instance: " + i + " named " + mc.getChildAt(i).name );
trace("instance: " + i + " total frames" + mc.getChildAt(i).totalFrames );
}
I don't know the instance names of the children b/c i will not have access to the swf i am loading (user uploaded)

So i need to be able to loop through all mcs at the root level and poll each for totalframe property

any help would be so awesome!
thanking you

NumChildren Returns Incorrect Number Of Children
I have this


HTML Code:
<mx:HBox id="test">
<checkboxes:ConditionCheckBox mouseDownEffect="{checkSound}" uncheckedID="T16" id="T20" styleName="Blue" width="26" height="24" /><mx:Label styleName="CheckLabel" id="CheckLabelTest" paddingTop="2" text="Carrying food/prey item" />
</mx:HBox>
and if i do this


Code:
public function bindSiblingLabel():void {
var me:ConditionCheckBox = this as ConditionCheckBox;
var parent:HBox = me.parent as HBox;
var index:int = parent.getChildIndex(this);
trace(parent.id);
trace(index);
trace(parent.numChildren);
if(index != parent.numChildren - 1){
trace("here");
var siblingLabel:DisplayObject = parent.getChildAt(index + 1);
siblingLabel.addEventListener(MouseEvent.CLICK,function(event:Event):void{
trace(this);
//me.selected = true;
});
}

}

i would expect the Hbox num of children to come back with 2, the checkbox and the label. am i missing something?

Number Count Down.
well hi and thanx 4 taken the time 2 read this post
i am new 2 flash and well i know the basic`s so i though it was time 2 move on with action script.

right i have looked and cant seem 2 find a tut on a scrip that will @ the beggining have numbers counting down from random 9-0 and when it has finished with all 9 digits add a letter so @ the end of the count down it will have a word

thanx again hope some 1 can help me out as i would like 2 go a little further in action script but as i said im a new-b flasher will no knowladge @ all of action script

=)

How To Count Number Of Clicks?
Is there any way to count or detect how many times a button was clicked?

Desperate to know..
Tnx in advance
Zoo-Mann

Count To A Number For A Set Time
I need to have something count from 0-500 in 2 seconds. How would I be able to do this? I have been changing the number for each frame but it takes to long to do that. Any help would be appreciated

Count The Number Of Btn Have Been Click
hi, how to count how many times the btn have been click. After counted the number of btn been click , according to the number , load the sound that match with the number of the btn been click.

anyone who know how to do it , plz reply me.thanks.

At the first frame :
[code]
Sound = new Sound();
Sound.attachSound("firstSound01.wav","secondSound0 2.wav");

At the btn's action:
[code]
on (release) {
count++;
trace(count);
if (count == 1) {
_root.Sound.start();
_root.Sound.firstSound01.start();
}
if (count == 2) {
_root.Sound.start();
_root.Sound.secondSound02.start();
}
//if (count == 3) {
//_root.Sound.start();
//_root.Sound.thirdSound03.start();
//}
//if (count ==4){
//_root.Sound.start();
//_root.Sound.forthSound04.start();
//count=""
//}
}

b'cos of the file is too big i can't attach here,so i post the code here.With using these code, the sound come out when i click the btn is firstSound01.wav,the second time i click the btn the sound come out still firstSound01.wav.How to make it come out secondSound02.wav when i click the btn after first sound finish.

Count Number Of People On Web
I want to count number of people on web, I don't know what it's wrong. It don't count.
Please help!!

Count Number Up To 1000
hello, i s there an actionscript that count from 0 to 1000 and back to 0 again? thanks

Count Number Up To 1000
Greetings,


Anyone know how to create a count up number? cause i like to create anumber which start from 0 to 1000?


Thanks,
eli

Count Number Of Lines In Textfield?
Is it possible to count the number of lines in a textfield? This because I want to change the border I made around the textfield and give it the same height (1 line -> graphic of 20px, 2 lines, graphic of 40px )

Possible To Count Number Of Created Clips?
Hi,

Is is possible to do the equivelant of Array.length on a Parent Movie clip, to get how many children clips it has?, how can you count the number children clips a parent clip has?

thanks

phil.

Count Number Of Lines In A Text Box
Hi, i have a tet boxy dynamically populated from an xml file with html
I need to know how many lines of text there are so that i can make the text box resize to fit all in

Thanks

Best Way To Count The Number Of Lines In A TextField
I have a TextField being created and populated at runtime. How can I go about getting the number of lines of text it contains? I have wrapping turned off if that helps.

AS3 - How Do I Get A Count Of The Number Of Files In A Subfolder?
I'm a newbie - so forgive me if this is a stupid question.

in AC3 - how do I get a count of the number of files in a subfolder?

I want my SWF file to generate the correct number of buttons to correspond with the number of JPG files in a subfolder.

What is the correct way to get this count-number?

Is there a simple way to do this?

Count Number Of Specified Characters In A String
hiii,

for instance if i had the string, "til,is,amazing" and i had another string "til,is,even,more,amazing" how would I count the number of commas in each string? i need to find out which is the longer one....

what i have tried is splitting the string into an array, then tried checking the 4th value to see if it exists....


PHP Code:



if (til[3]=="") {
trace("shorter one!") } else {
trace("longer one!") }





that doesnt work though
thanks

How To Count The Number Of Specific Character?
what is the AS tag that counts the number of specific characters.

for example.

im creating a form validation script.
If we want to check if this email below is valid or not;

1) user@yahoo.com // VALID EMAIL
2) what if user enters user@@@yahoo.com // NOT A VALID EMAIL

there are too many "@" signs in the second example. How do we make sure that user only enters only one "@" sign?

Count Number Of Characters In Input Field
Hi,

How can I count the number of characters in an input field and show the number in a dynamic field...

-sam-

Count Number Of Lines And Break Up Text?
Hi FK friends

I'm working on a new site. Check this link to see the result so far:
Website

I want to break up the text if it's too long and show the rest of the text after clicking a button. As you can see it's working in the most simple way but as you can see it's not working really well.

I'm counting the amount of characters but that gives 2 problems.
* I've got no control of the height of the text, because on one page the characters are more concentrated then on the other page.
* It breaks up words halfway instead of at the end where a whitespace is.

I know mono fonts give more control, but it's just to ugly to use, ecpecially with this kinda style of site.

This is my script:


Code:
System.useCodepage = true;
textLength = 760;
n = 0;
index = n + 1;

homeText.html = true;
homeText.multiline = true;
homeText.wordWrap = true;
homeText.condenseWhite = true;

myData = new LoadVars();
myData.onLoad = function(success) {
if (success) {
tarray = new Array();
for (i=0; i<(this.homeText.length/textLength); i++) {
splitvar = this.homeText.substr((i*textLength), textLength);
tarray.push(splitvar);
}
homeText.htmlText = tarray[n];
} else {
homeText.htmlText = "error loading";
}
};

myData.load("mansanText.html");

btLeesMeer.onRelease = function():Void {
homeText.htmlText = tarray[index++];
}


My question is: Is it possible to count the number of lines instead of the number of characters?

If anyone has suggestions or any tips/help it would be much appreciated!

Thanx in advance

Number Count Up (like Slot Machine Jackpot)
I am needing to create a counter that will count up. It will need to start out like this. It will not need commas or anything like that

000000
then
000001
000002
000003
and so on

Can anyone tell me the actionscript to do this. it will need to count up some what fast.

It will need to be something like a slot machine jackpot counter

Keeping Count Of The Number Of Buttons Checked
i have an application that im trying to develop which involves the user choosing a number of brochures to be sent to their address.

The user can only choose three brochures out of a total of 15. the original idea is to warn or inform the user once they make more than three choices they cannot submit the form.

I know this involves keeping count of the number of buttons that are checked out of the 15.

So far ive been able to code the status of a button being enabled using a counter(i.e if checked counter= counter+1 if unchecked counter=counter-1)


Code:
onClipEvent (load){
var _count:Number=0;
}



on(press){
if (this._currentframe==1){
pressed = true;
this.gotoAndStop(2);
_count=_count+1;
trace (_count);

}

else if (this._currentframe==2) {
pressed = false;
this.gotoAndStop(1);
_count=_count-1;
trace (_count);

}
}

Each of the 15 buttons are an instance of one button_mc.

can i somewhat get a variable that stores the total number of buttons clicked? and if more than 3, it does the appropriate function.

Count Number Of Lines In Dynamic Text?
Is there a way to count number of text lines in a dynamic text field?

Count Number How Many Times Button Have Been Click
hi, how to count how many times the btn have been click. After counted the number of btn been click , according to the number , load the sound that match with the number of the btn been click.

i upload the fla zip file to here.anyone who know how to do it , plz reply me.thanks.

At the first frame :[code]
Sound = new Sound();
Sound.attachSound("firstSound01.wav","secondSound0 2.wav");

At the btn's action:[code]
on (release) {
count++;
trace(count);
if (count == 1) {
_root.Sound.start();
_root.Sound.firstSound01.start();
}
if (count == 2) {
_root.Sound.start();
_root.Sound.secondSound02.start();
}
//if (count == 3) {
// _root.Sound.start();
// _root.Sound.thirdSound03.start();
//}
//if (count ==4){
// _root.Sound.start();
// _root.Sound.forthSound04.start();
// count=""
//}
}

b'cos of the file is too big i can't attach here,so i post the code here.With using these code, the sound come out when i click the btn is firstSound01.wav,the second time i click the btn the sound come out still firstSound01.wav.How to make it come out secondSound02.wav when i click the btn after first sound finish.

How To Count The Number Of Image Files In A Folder
Hi all, does anyone knows how to count the number of image files in a folder?

The swf is gonna be launched locally, not on a server... so i guess php is not gonna work... The photos are gonna be named according to the person in the photo, so i can't count using the naming method ( 1.jpg, 2.jpg ) also....

Help Pls!!!!!!

Count Number How Many Times Button Have Been Click
hi, how to count how many times the btn have been click. After counted the number of btn been click , according to the number , load the sound that match with the number of the btn been click.

i upload the fla zip file to here.anyone who know how to do it , plz reply me.thanks.

At the first frame :[code]
Sound = new Sound();
Sound.attachSound("firstSound01.wav","secondSound0 2.wav");

At the btn's action:[code]
on (release) {
count++;
trace(count);
if (count == 1) {
_root.Sound.start();
_root.Sound.firstSound01.start();
}
if (count == 2) {
_root.Sound.start();
_root.Sound.secondSound02.start();
}
//if (count == 3) {
// _root.Sound.start();
// _root.Sound.thirdSound03.start();
//}
//if (count ==4){
// _root.Sound.start();
// _root.Sound.forthSound04.start();
// count=""
//}
}

b'cos of the file is too big i can't attach here,so i post the code here.With using these code, the sound come out when i click the btn is firstSound01.wav,the second time i click the btn the sound come out still firstSound01.wav.How to make it come out secondSound02.wav when i click the btn after first sound finish.

Need To Visually Make A Number Increase (count Up)
Hi everyone,

I'm working on a Flash animated graph that will be showing 3 bars raising gradually, but I want to show a number counting up for each bar, and that's where I need your help.

The first bar needs to show a pretty quick number count-up going from 0 to 3 (0.01 increments)

The second bar is a number that quickly goes from 0 to 450 (increments of 1)

The 3rd bar is a number that quickly goes from 0 to 200 (increments of 1)

Each of those 3 statistics have to reach their highest value almost at the same time as much as possible...

Oh and I would need to be able to chose the font and color for those, not just plain text.

I looked it up and couldn't find what I needed.

Any suggestions, tutorials, actionscripts would be very appreciated

Thanks

Can Flash Automatically Count The Number Of Files In A Folder Somehow
here's the situation. I am making a viewer for a series of flash movies that I will be creating in the future. I want the movies to load externally and so far I have been successful with automating everything about the viewer exept one detail. When the user reaches the final movie and hits the next movie button, the viewer attempts to load a movie that doesn't exist.

I need a bit of code that will all me to find out the number of movies available to load, so that I can put an "if n = numberofmovies, n = n. else n = n+1" on the next movie button.

I know that I can just hard code that number into the flash movie, but I would really like to automate it as I will be creating alot of these movies for a long time. Anyway if you know the code I would be most grateful.

Count The Number Of Times A Bag Of Flour Hits A Cart
Hi im trying to count the number of times a bag of flour hits a cart for a game im making.

the problem im having is that when one bag is dragged to cart, it counts far too mant times, constantly counting up. when i want it to only count once for each bag. There are 5 bags in total, so when a 5th bag has hit the cart it stops the game and takes you to the last page.

This is the code ive put in so far...


first start up frame:

_global.count=0;
trace (count);
stop();

second frame (game):

if (_root.count==5)
{
_root.gotoAndStop(5);
}

else {

grain.onMouseDown = function() {
grain.startDrag("");
};

..... continue with game

frame 3 (game):

if (_root.flour.hitTest(_root.cart) &&_root.cart._currentframe==1) {
count++;
trace(count);


}


please help!! nikki

Count Number Of Files In Directory // Or // Check If File Exists
Hi,

Im working on a banner rotator.
It loads movies, wich ar called 0.swf, 1.swf etc.
I got this counter that inceases on each rotation, which need to be resetted to 0 when it just showed the last banner. So i could do this by checking if the number after the last file exists, or check if the variable equals the number of banners in the directory.

Well, i am a PHP-minded person, so this is my approach, anyway, i got no clue how to achieve any of these 2 ...

Could someone help me out?

Getting Number Of Frames From A Movie Clip
I have a movie clip displayed. I want to grab the number of frames in the movie clip when it loads, and save it to a variable.

How can I get a count of the number of frames in the clip?

Thanks
MCM

Movie Clip Frame Number
Is there a way of returung the frame number of a MC based on instance name?

Count The Number Of Characters In An Input Field For A Return In Dynamic Textbox
hi again everyone. this should be simple actionScript, but i cant find others with similar question.

i have two input fields. variable names are "name1" and "name2".
but when the input is returned in a dynamic text box, if the users names are too long (say "raskolnakov" and "penelope-sue"), there is no auto break in the final dynamic textbox ("both_names") and it is clipped by the frame of the movie.

so i think what i want to do is somehow count the characters in the input fields like

if the sum of the characters is more than 50,
then _root.both_names = name1 + " and " + "
" + name2;

that would return in two lines:
Raskolnakov and
Penelope-Sue

else if the sum of the characters is less than 50,
then _root.both_names = name1 + " and " name2;

that would return in one line:
Sam and Becky


thanks.

Movie Clip After A Predefined Number Of Seconds
I was wondering if it is possible to display a movie clip after a predefined numbe of seconds, when the mouse has not clicked on anything. I want it to act like a pop up help thingy, that pops up when the users mouse has not clicked anything for a number of seconds.

Thank you for your help,
Darren

How To Play A Movie Clip X Number Of Times
Hi all,
I have a mc animation called "anim", and want to play it on the main timeline 3 times and then stop.

I know I would attach an action to the instance of the mc called "animloop", but can't seem to figure out the code to make it stop after it plays x number of times.

Does anyone have code I can cut and paste to make it loop only 3 times? I've spent 2 hours in the Flash help, and am more confused than ever!!

Thanks in advance!

Random Number Then Empty Movie Clip
Hi all,

I need some script which will generate a empty movie clip at a random place on the X axis, then fill it with an instance of a movie clip symbol. I have tried and experimented with different peices of code but nothing seems to work.


Any help would be greatly appreciated,
jellyrools

Stopping Movie Clip After A Specified Number Of Seconds
Hi all,

I am not good at actionscript. I use FlashMX and made a basic flash movie with one movie clip. (movie clip contains frame by frame animation using images rendered at AE) How can I make the movie clip stop after a specified number of seconds? Client wants to be able to change the seconds when needed. So a text file along with swf file including number of seconds...?

Thanks a lot in advance..

[MX 2004] Get Number Of Frames In Movie Clip
Is it in any way possible to create a variable that represents the number of frames in a movie clip? I thought maybe something like var = getProperty(my_mc, frames); might work, but it doesn't. I'm trying to make a "last" button for a template that goes to the last frame in a movie clip, and as we'll be updating and changing the number of frames in the movie clip quite often, I'd rather just have it find the last frame rather than have to update the actionscript every time.

Thanks. Any help would be appreciated.

Stopping Movie Clip After A Specified Number Of Seconds
Hi all,

I am not good at actionscript. I use FlashMX and made a basic flash movie with one movie clip. (movie clip contains frame by frame animation using images rendered at AE) How can I make the movie clip stop after a specified number of seconds? Client wants to be able to change the seconds when needed. So a text file along with swf file including number of seconds...?

Thanks a lot in advance..

Limiting The Number Of Times A Movie Clip Will Play
limiting the number of times a movie clip will play
say 3 times and stop

GoTo And Play Frame Number Of Movie Clip - How To?
Just wondering how I can make a button goto and play a frame of a movie clip. Basically the first frame is blank and when the button is clicked the movie clip will go to frame 2 and play. I'm also going to have some other buttons make it go to other frames.

Let me know... this would be very very helpful!

Finding Total Number Of Frames In A Movie Clip
im loading random movieclips from an external folder into an emptymc,
i need a way to get flash to tell me the number of frames in the random clip that has been loaded.

this is what i'm trying to use now to give me a random #, within the # of frames loaded
Code:

Code:
var rNum = Math.round(Math.random(emptymc1,_totalframes))
the clips im using have 90-100 frames, but the number im getting is either 1 or 0

does anyone have any idea what's wrong?

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