Loops, Instances And Controlling For Newbies
Hi people! Can any of you help with what is, very likely, a really newbie question..
Is it possible to create multiple instances with a loop, and then control specific instances?
ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 11-20-2008, 12:55 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Accessing Instances With For Loops
I have a bunch of MovieClips and I want to access them using a for loop. There are 20 instances (named test_1, test_2, test_3, etc.) and i want to set a variable in each one with the for loop. How can I do this?
For Loops And Identifying Instances
I have 16 layers of movieclips (one in each layer), each has been given the instance name, "line1" through to "line 16". I'm trying to figure out how to hide all of them through actionscript, so far, my code is:
for(x=1; x<17; x++){
line[x]._visible = false;
}
but for some reason, it doesn't hide all the instances. I've tried typing it in seperatly, (line1._visible = false; , line2._visible = false; , etc...) and it works, but for some reason, when I use the for loop, it doesn't work...what am I doing wrong?
For Loops And Identifying Instances
I have 16 layers of movieclips (one in each layer), each has been given the instance name, "line1" through to "line 16". I'm trying to figure out how to hide all of them through actionscript, so far, my code is:
for(x=1; x<17; x++){
line[x]._visible = false;
}
but for some reason, it doesn't hide all the instances. I've tried typing it in seperatly, (line1._visible = false; , line2._visible = false; , etc...) and it works, but for some reason, when I use the for loop, it doesn't work...what am I doing wrong?
Controlling Amount Of Loops A Swf Does
I'm doing a banner ad and it has to loop 3 times.
So what I have is in my main timeline 3 movies: 1st movie loads some text say text1Mov . At the end of the text1Mov instance I have a go to the root and play the next frame which contains text2Mov and then to finalMov. What I want to do is have the main timeline go through the whole movie once and then load from text2Mov again and then finally load text2Mov again and from there play finalMov and stop at the end of that.
Here's the file so you can see what I'm trying to do:
http://www.rdesigncreative.com/temp
Any help appreciated thankyou.
Controlling 2 Audio Loops.
I'm making a Flash presentation for a window company, and what they want is an animation of a customer's original window that can go up and down (which is easy enough) but the audio loop in the background to go from normal volume, down to maybe 10% when closed (and of course up to 100% again when opened), to show that your original window won't block all sounds out.
But there will also be a second inner window (their product) which will be 0% volume when closed.
These windows need to be able to open and close alternately, and together, and I'm just having a bit of trouble getting the original window to fade out to 10%, when the new window is open, and not make any noise when the new window is closed.
Hopefully this isn't all that confusing, and that some kind soul will be able to send their audio expertise my way.
Happy new year, and all that hoohar. Thanx in advance.
Controlling 2 Audio Loops.
I'm making a Flash presentation for a window company, and what they want is an animation of a customer's original window that can go up and down (which is easy enough) but the audio loop in the background to go from normal volume, down to maybe 10% when closed (and of course up to 100% again when opened), to show that your original window won't block all sounds out.
But there will also be a second inner window (their product) which will be 0% volume when closed.
These windows need to be able to open and close alternately, and together, and I'm just having a bit of trouble getting the original window to fade out to 10%, when the new window is open, and not make any noise when the new window is closed.
Hopefully this isn't all that confusing, and that some kind soul will be able to send their audio expertise my way.
Happy new year, and all that hoohar. Thanx in advance.
Controlling All Instances
hi everyone im pretty new to flash and im wondering if there is any way to control all instances of a single symbol at once through actionscript?
Controlling The Speed Of LOOPs In The ActionScript
Hello
How are you people ?
I have a problem ..
I want to control a MC and move it from one place to another with action script , the problem is that when i use the Loops , the MC move very quickly that the user does not notice it is moving !!! I have tried using Motion Tween and controling it .. it worked fine , but when i want to reverse the movement , i get back to the main problem !
is the there away of controlling the speed of the loops ? or is there away for reversing the movement in the timeline ?
please help
Controlling The Timing Of Sound Loops
hi hi... pls help me
I'm making a kids drum machine and I'm trying to do 2 things that are very similar.
I want my 4 second (48 frame) sound clips to begin at the same time (that is, at the beginning of the 4 second cycle) and if a sound is stopped, I'd like to have it finish out its cycle first and then stop.
I think the key here may be with using onEnterFrame... but I don't know how to use onRelease and OnEnterFrame at the same time. (I've extended my timeline to 48 frames to acccomodate this)... there are probably some if/then conditions I could use too... but I'm so noobish... I'm lost...
Help?
Controlling Multiple Instances Of Mc
hi i have a map with a movie clip with an embeded button that basically flashes on and off when clicked, my problem is this, i want to use many instances of this movie, probably upto 50, and i want to tell the previoulsly selected instance to go to a frame that has a stop action in it, when the new instance has been selected. to indicate which button has been selected.
any help would be greatly appreciated.
Controlling Button Instances
I thought that one of the new things in scripting w MX was the ability to talk to button instances just as you do to Movie clip ones. For some reason I am having a hard time getting this to work.
I am trying to move the play head in a button instance to oh lets say the 6th frame
(obviously my button has 2 more frames with graphics in them that are after the 4 standard frames).
Normally if it was a Movie Clip I would use dot syntax to say something like:
_root.MovieClipInstanceName.gotoAndStop (6);
Can I do the same w/ a button instance?
like this:
_root.ButtonInstanceName.gotoAndStop (6);
So in an example I would have 2 buttons on the stage
the 1st button would make the 2nd buttons play head to go the 6th frame in that button.
HELP?
Controlling The Number Of MC Instances
Hi!
I created this code to attach a MovieClip to the same position as the mouse.
This works, but I don’t want to attach more than tree MC at the same time.
Shouldn’t this line be enough?
Quote:
for (var i = 0; i<numbBombs; i++) {
Quote:
var stageWidth:Number = Stage.width;
var stageHeight:Number = Stage.height;
var numbBombs:Number = 3;
var gravity:Number = 5;
var movieBomb:MovieClip;
//
_root.onEnterFrame = function() {
for (var i = 0; i<numbBombs; i++) {
movieBomb = _root.attachMovie("bomb", "bomb"+i, _root.getNextHighestDepth());
movieBomb._x = _xmouse;
movieBomb._y = _ymouse;
movieBomb.onEnterFrame = falling;
}
};
//
function falling() {
this._y += gravity;
if (this._y>stageHeight+10) {
delete this.onEnterFrame;
}
}
Controlling Multiple Sound Loops Through ActionScript - At My Wit's End.
Hi all - I've been searching all over for an answer, and I'm just not finding it. I feel like I'm missing some obvious solution, but I can't figure it out, likely because I'm a designer learning development, and thus still have knowledge gaps.
Anyway, I have 2 sound files that I want to use as a looping sountrack in my Flash movie. I want the first to play, then the 2nd to loop 4 times, and then repeat back to the first. Here's the code I'm using:
Code:
var soundReq1:URLRequest = new URLRequest("sound1.mp3");
var soundReq2:URLRequest = new URLRequest("sound2.mp3");
var sound1:Sound = new Sound();
var sound2:Sound = new Sound();
sound1.load(soundReq1);
sound1.addEventListener(Event.COMPLETE, s1);
sound2.load(soundReq2);
function s1(event:Event):void
{
sound1.play();
sound1.addEventListener(Event.SOUND_COMPLETE, onSwitch);
}
function onSwitch(event:Event):void
{
sound2.addEventListener(Event.COMPLETE, s2);
}
function s2(event:Event):void
{
sound2.play(0,4);
sound2.addEventListener(Event.SOUND_COMPLETE, s1);
}
When I load the movie, I don't get any errors. But, sound 1 plays and then...nothing. I'm sure I'm making an obvious error somewhere, just can't figure out what it is.
Thanks in advance!
Controlling The Amount Of Times A Movie Loops
Hi All,
Hey I simply want to control how many times a movie loops when it first loads on a web page. I have done this before long ago, but can't remember the exact syntax. Can someone please tell me what I am doing wrong? Thanks!
ActionScript Code:
for (i=0; i<2; i++) {
}
gotoAndPlay (1);
stop ();
Controlling Clips Created Dynamically With Loops
hello
i was wondering how to make a grid of squares with loops? also, how do i controle the clips that were dynamically created with the loop. like clip25 only?
Code:
total = 5;
i = 1;
while(i<total){
//create MovieClip with new name
mcName = this.createEmptyMovieClip("square_mc"+i, this.getNextHighestDepth());
//begin fill in each new MovieClip
mcName.beginFill(0xFF0000);
mcName.moveTo(10, 10);
mcName.lineTo(100, 10);
mcName.lineTo(100, 100);
mcName.lineTo(10, 100);
mcName.lineTo(10, 10);
mcName.endFill();
// how do i place the clips here? also how do i make certain clips
//move with action script?
mcName._x = mcName.width
mcName._y = mcName.height
//count
i++;
}
thanks so much for your help
Controlling How Many Times An Entire Movie Loops
I simply want to control how many times a movie loops. I know this should be fairly simple, but I am doing something wrong. Can anyone suggest the scripting I should use to accomplish this? Thanks!
Controlling Multiple Instances With One Telltarget
I have a movie clip that contains 8 instances of another clip all on the same frames. I need to make all of the 8 clips do something on a button press but only one responds. They are all the same clip with the same instance name. I tried giving them all different instance names and having several telltargets but stil just one of the clips responds. Any ideas?
[F8] Naming/controlling AttachMovie Instances
I'm having a problem naming and then refering to attachMovie instances on my stage. I want to put multiple instance of the same graphic on the stage, and then move around and resize any of these instances. I have got the adding part working;
PHP Code:
var i:Number = 0;
ghost_mc.onMouseMove = function() {
this._x = this._parent._xmouse;
this._y = this._parent._ymouse;
updateAfterEvent();
};
//draggable menu item which is the same size and shape of the instance item
origX = menu_glad_mc._x;
origY = menu_glad_mc._y;
menu_glad_mc.onPress = function () {
this.startDrag();
};
//draggable menu item creates an instance in the place where it was dropped
menu_glad_mc.onRelease = function() {
trace (origX);
this.stopDrag();
var xcord= _root.ghost_mc._x - this._xmouse;
var ycord= _root.ghost_mc._y - this._ymouse;
if (eval(this._droptarget) == stage_mc) {
i++;
_root.attachMovie("glad_b", "mc_glad_b"+i, i, {_x:xcord, _y:ycord});
_root.clipName = "mc_glad_b"+i;;
_root.onStage == true;
this._x = origX;
this._y = origY;
} else {
this._x = origX;
this._y = origY;
}
}
what I am trying to do is to be able to followup with some code like;
PHP Code:
_root.onEnterFrame = function() {
if (_root.onStage == true) {
_root.clipName.onPress = function () {
startDrag(this);
};
}
};
But for all this code to be on the first frame of the timeline, clipName has to correspond with whatever instance is on the stage (i.e. mc_glad_b1, mc_glad_b2).
it's going to work much like the code in this thread;
http://board.flashkit.com/board/show...ling+movieClip except that a user need to be able to move and then resize the onstage clips.
Controlling Instances In Parent Timeline
Hi Everyone
I've just recently started using Flash. I've got most of the very crude basics, but one thing I cannot figure out how to do (and I realise this is probably very simple, but it must be so simple that people don't think to write it down somewhere, because I certainly can't find it anywhere) is to select an instance of an mc from within another mc.
For example, I have two clips in the main timeline, mc_1 and mc_2. Within mc_1 is another mc (mc_3). Actionscript within mc_1 is mc_2.gotoAndStop(50) when I click mc_3. But it doesn't work, says that mc_2 doesn't exist.
Cheers
Controlling Movie Clip Instances
i've created new movie clip symbol and made some tweened animation in there and then i put this code to the first keyframe:
onClipEvent (load) {
stop();
}
than i dragged this movie clip to the scene.
everything seams to be ok, but i always have error:
Symbol=Symbol 1, Layer=Layer 1, Frame=1: Line 1: Clip events are permitted only for movie clip instances
onClipEvent (load) {
where's the mistake?
Controlling Sound Volume For Multiple Instances
I am creating a flash demo in which objects scroll across the screen in a loop. Each time an object enters the viewing area, I play a sound. I have created a layer that contains keyframes at each point in the timeline where an object enters the screen, and in each keyframe I have inserted an instance of this same sound. I want to let the user have the ability to click on a button that would toggle the sound on and off. I have tried various methods using setVolume(0) and setVolume(100), but I am a newbie and can't seem to get it right. I'm not even sure if I should have put all the sound instances on one layer. What I need is some direction on how to design this feature correctly.
Controlling Multiple Instances Of A Child Movie Clip
Hello,
I have a parent movie clip (instance name is Dandelion) that contains hundreds of instances (unnamed) of a child movie clip called Seedling. (so seedlings floating away from a dandelion at different points within the parent movie clip)
On the main timeline I have a 'stop' and 'play' button that control the main timeline and parent movie clip just fine. But the buttons have no effect on the child movie clips which just continue to play independently.
It would be too much work to go back and name every instance of the child movie clip and then code it into the button
_root.Dandelion.seedling1.stop();......
There must be a quicker and more efficient way! Is there a way to go into the child movie clip and code it to respond to the stop and play buttons in the main timeline? Or to have it stop when the parent movie clip stops?
Attention All Newbies. I Repeat, Attention All Newbies.
I have found that there has been a lot of demanding in this section lately. "URGENT!!!" "HELP ME!" "PLEASE HELP!!"
All these are a great thing to put in your subject line, if you don't want anyone to answer.
I good way to get your question answered is to put something that has to do with your question. It's common curtisy. I like to help out with buttons, sound, and movie clips, but hate to help out with pre-loaders (I admit it.).
So If I go into a thread titled "Please, URGENT" (at least he said please) and find out it's about pre-loaders, I am going to get angry because I could of spent that time helping out about things I know about.
So please, if you're going to post, put a helpful Subject.
Controlling Instances In Movie Clips From Other Clips
I am trying to get a button on my level 2 in my main movie to point to a frame inside a movie that has been loaded in on level 3 on the main movie. I have tried all different kinds of combinations and no success. I even tried putting the level 3 movie in an empty movie clip on the root, and naming the instance "music", and then writing in the button _root.music.GotoAndPlay(3); I need it to target frame 3 in my level 3 movie. Should I put the level 3 movie in its own empty movie clip? I was able to get the button to unload movie3, but I don't want it to dissapear, I just want it to go to frame 3 in the movie clip to turn off the music.. You can see what I mean at the address below. I have my audio player in the bottom right with an on/off that works fine, but when I go to the link in my site "Music" there are some downloadble MP3's, and when you click on one I want the "equalizer bars" you see in the audio in the lower right corner to stop, and it means I need it to go to frame "3" of tha movie clip for that to happen, just like it does when you click on "off" in the audio movie. Anyway, sorry this is long winded, but wanted to make sure it was clear as to what I am trying to do..
Thanks in advance,... Here is the link
http://www.incogneato.tv/stales
Mike
3D For Newbies
ok what's wrong with me? how do you incorporate 3D stuff into flash...using swift 3d or max? sure you can generate a SWF, but how do you get them into your FLA to them truely interactive
Hey Newbies - Want Help?
To all us newbies that have tired the tutorials, dissected the movies and posted here at FlashKit but are still stuck. Whispers has created a new forum on Yahoo with online help and online tutorial sessions. He does a great job explaining the reasons for code and why you put items into movie clips and so much more.
It does not replace the need for flashkit and all its wonderful tools but complements it.
Go to http://www.groups.yahoo.com/new2flash
Join the group and particpate in tutorials on Wednesday nights 8:30 p.m central/9:30 p.m. Eastern.
Thanks to Whispers for setting up this forum and to Flash_noob for helping to monitor.
Tazmania
Hi Newbies...
I was wondering if the whole point ofyou making a site via flash etc is to make money or just out of enjoyment??
let me know
Newbies
hello, i have several swf. files and i want to load them into one movie, my question goes like this,
once i load a movie/swf.file, how do i load an other movie automaticaly once the last frame of the first movie is reached.
i.e suppose i load a movie named mov1, and there is a continuation of the movie which is named mov2, how do i load mov2 automatically once the last frame of mov1 is reached.
basically i'm doing a flash presentation.
thanks in advance
ravi
Newbies
If this is for Newbies I am pretty bad... I can only understand half of what these people are asking for!
Best For Newbies
Hi ... ! I want to start out learning flash but I`m not sure which one is best for a beginner (i.e.: me ). Should i start with dreamwaver or with flash mx?
A Question From The Newbies
Is it possible to control the actions of a swf from another swf ? More clarity ; control the frame actions or any other action of an swf from another swf ? I thought it sounded like a good answer to post. We pretty much think this task is impossible, but wanted to spring it over in action scripts.
The monkey speaks
Newbies - Read Here
I am looking to form a group of webmasters, who specialize in Band websites, we can share i deas and stuff
any interests email me subarticmunkey@hotmail.com
SUGGESTIONS TO ALL NEWBIES
OK...I suggest that ALL newbies get books on Flash 5. You can pick one up for little money like:
1. How to Do Everything in Macromedia Flash 5 by Bonnie Blake (the one I have! so far most of your questions are answered here)
2. Flash 5 Bible (above book is rated better but this is bigger)
Next, before you post anything SEARCH THE TUTORIALS!!! We find ourselves giving you tutorials all the time! If you don't know how or were not listening, do this:
1. Hit yourselves
2. Go to the Tutorials Section of FlashKit
3. Then under the yellow bar there is a search field. Type in your search! e.g. Preloaders, Scroll, Cube, etc.
I'm not mad, just letting you guys know and it will save time for you and make this website a lil faster. :-))
Great For Newbies
hey all,
trying to find a way to teach Flash to my students...
this helped!
http://www.skillspider.com
Quick Tip For Newbies....
You can import .WMF's into your movie, and when it imports, as it's composed of groups of vector shapes, you can edit it, in flash! Yes, that's in flash! I know that sounds a silly thing to say, using clip art (as most .WMF's are used for) in a flash movie is a good tip. However if you have any clipart, on CD or if you have Microsoft Office 97 or above, your hard drive will be cluttered with it!
Hope someone finds this useful....
XML + Newbies = Disaster: HELP
Hi everyone.
I've foolishly decided to try a bit of xml and now I'm stuck. I'm sure the answer is an easy one, but we will see
I've got a flash file that use xml to create a tree menu thingy (sorry, I really am out of my depth here!). I want to be able to load a .swf file in a place in the scene of my choiceof my choice when I click on the button that is created. The .swf loads up, but I don't know how to tell it where to go (I'd use target in Flash, and an empty movie clip).
Here's the xml:
<folder name="Movies">
<object name="Movie1" type="movie" file="dummy.swf"/>
</folder>
</server>
I'm sure that I need to put something after the file="dummy.swf" but I'm not sure what.
Can you help me?
Newbies First Time
Hi everyone
this is my first time so go easy on me
I have been asked to produce a promotional CD that my client can send to potential customers - basically it will contain images, movie files and sound files.
So I have a couple of questions :
What I need to know is what is the best size to make the stage?
If I have my CD so that its on auto run can it identify which type of computer its on and run (mac or pc)?
Do I have to publish a version for macs and a version for pc?
This is an ongoing project so I have plenty of time to learn and experiment (so you'll probably see alot more questions from me !! ha ha)
Any advise will be greatly appreciated
Thanks
Newbies Questions
Hey guys where i can find a simple example of how to get the sum of 2 input
Like :
When i click on a button i get the sum of input1 + input2.
Thank you
I'm Even New To The Newbies, With So Many Questions
Hello everyone!
(I apologize inadvance for the length of this message).
a very new user here. this is my first morning on this site as a full-fledged "user," previously downloading a few sound fxs for other animation packages.
I will try and make my way through the tutorials, for use with Flash 4, but I thought a few general questions would lead me quicker to the answers.
I use 3D software to create animations, and am giving a good darn shot at trying to generate some interest in a cartoon, but thought a website would be useful also, obvoiusly.
1) Are there tutorials somewhere in this site for people who have the animation footage, or rendered scenes that they want to incorporate into a website?
2)or more specifically, tutorials that walk a person through webpage setup, the variables invovled, the tips to think about if viewing animated shorts online is the ultimate goal?
This could be as simple as, "look newbie, just because you rendered your animation at 29.97 fps, doesn't mean that that will be your frame rate for your flash movie." OR, "look newbie, so you have 9000 frames of 720x486 jpegs clogging up your HD, but you won't be importing each frame, instead you will need to rerender the short as "this type of movie file" because Flash can only use these types of movie clips on a webpage." OR, "and by the way, your sound file should be sepreate from your movie file, or yes newbie, rerender the movie file with the sound embedded." OR, "yes flash can make use of a MPEG-2 file, because it's smaller and almost lossless.
Thanks for the help...
I Thought This Was For Newbies
I thought this site was for newbies.
Well, I guess I am a few levels below that because all I am looking for is a tutorial for Flash 5 that is more than 1 page long and that does not focus on some obscure subject whose title I don't even recognize. I have already done the tutorials in the program, but need much more. Any hand-holding beginners course out there? Thanks. I promise to grow up soon.
Note To Newbies
I just wanted to metion to the newbies to remember to put all their code between [code] tags. I'm not trying to picky but its kind of annoying somtimes. Thanx guys.
Best Program For Newbies
i need to know the best programs out there. Could you please help me. I need to know the easiest to use, the cheapest, the most powerful. I need opinons on the best programs
Newbies First Animation, And A Thank You
Hey I just wanted to thank everyone on this site for their replies to my dumb flash questions over the last few weeks and invite you to take a peak at my first Flash animation. I started learning Flash about 4 weeks ago and with the help of the users here and a few books I feel i'm off to a decent start. Thanks and Enjoy!
http://www.newgrounds.com/portal/view/188951
How Many Newbies Does It Take To Ask The Same Question?
Yeah, I bet you've all heard it before.
How do you get started??
There's so many things! I know how to make a very very simple movie (I think), but now I really want to make a website! ^_^ With programming involved, is it all done with just Macromedia Flash, or do you have to use the other software like Dreamweaver?
@_@;; Oi, does anyone know a decent site on how to get started on making flash websites?
Or could anyone describe the basic stuff of this site:
http://www.ranflash.8m.com/
That...is...the...coolest flash I've visited thus far... O_o;;
I'm Sure This Is Too Basic Even For Newbies...
Got issues with calling functions.
Created a main class (Example.as) within a package and the constructor method of the main class just "addChild" and puts an object on the screen.
Then created another public class (DragTheObject.as) and a function that just puts an object on the screen that can be dragged around.
I set the Document Class in the Properties Tab of Flash CS3 to Example and in Example tried to call the function I created in DragTheObject but didn't work....
With that limited info anyone got any ideas what I could be doing wrong...
Thanks
AS2 Newbies Seeking Help
I'm attempting to write my first application in AS2, and reading Moock's EAS as I go, but I'm stuck. I'm trying to create a clip that loads a full size jpg into a thumbnail size clip (scales down), creates a tint over that jpg, and then draw a border around the jpg. Then when someone mouses-over the jpg, I want the tint to change the alpha to 0 so the jpg shows with no tint. Am I missing some trick for triggering events onMouseOver or onRelease? I've tried all kinds of functions all kinds of ways with no luck. I can set the alpha of the tint in the fla, so I know that property is getting passed, I just can't change it. Right now, this is the function I'm trying to use (in the as class);
public function onRollOver (target:MovieClip):Void {
container_mc.shade_mc._alpha = 0;
}
Do I need to set up a listener or something? I'm totall perplexed? Any advice is greatly appreciated.
|