Flash :: "IF" Statement, Within A For Statement, To Control Movieclip Within Movieclip?

Dec 18, 2011

I have a movieclip on the screen called "mc_bg". Within this movieclip are 7 movieclips called "barrier1" through "barrier7".From main.as I want to be able to do this call:

for (var i: int = 1; i < 3; i++ ){
trace("got here")
trace(mc_bg["mc_barrier" + String(i)])

[code]....

View 1 Replies


Similar Posts:


Flash :: Accessing Movieclips Within Movieclip Using For Statement?

Nov 1, 2011

I am trying to access movieclips within my movieclip using a for statement. To try and make this clear, here is how it looks at the moment:

sections = Holder movieclip where dtf_sections is placed, as well as other clips that are needed.

dtf_sections = Where all the title movieclips are placed that are going to be used when called. Placed in here to make it easier to move, within sections

title = Movieclip that contains the text that needs to be changed, within dtf_sections

Here is my code that works:

sections.dtf_sections.title1.dtf_title.text = "Section 1"

There are upto 10 titles within dtf_sections. So, what I thought would work is this:

for(var i:uint=1; i<10; i++){
sections.dtf_sections.["title"+String(i)].dtf_title.text = "Section" +(i)
}

The reason why they are within the movieclips is masking, and appearing at different times.

View 1 Replies

ActionScript 2.0 :: If Statement From Within Movieclip

Feb 8, 2009

I am using Flash CS3 AS2. On my main timeline I have 3 buttons, each of which, when pressed go to the same frame in which a movieclip loads. However, when the movieclip gets to the end I want it to gotoAndPlay a different frame on the main timeline depending on which button had been pressed.

I'm guessing I need to use button instance names in combination with an if statement from within the movieclip but I'm not sure exactly.

So far I have tried

if (isPressed= "btn_latest_mar_cgn"){
_parent.gotoAndPlay("latest_cgn");
}

but something isn't quite right about that. Do I need to put something on my main timeline

View 7 Replies

ActionScript 3.0 :: Movieclip In Conditional Statement Of If?

Nov 28, 2009

In the code below how can I use the movieclip in the conditional statement? This is simplified, there is lots more going on but the basic issue is shown. I want to say if currently dragged mc is dot1_mc do the copyDragTo35 function

PHP Code: var item:MovieClip;
//add event listeners to all dots
kite_mc.dot1_mc.addEventListener(MouseEvent.MOUSE_DOWN, onItemDragStart);
kite_mc.dot2_mc.addEventListener(MouseEvent.MOUSE_DOWN, onItemDragStart);
function onItemDragStart( e:MouseEvent ):void {

[Code]...

View 2 Replies

ActionScript 2.0 :: If Then Else Statement Load Movieclip?

Jan 29, 2011

I have built a calculator with a running total variable (stotal) this is working great. There are 30 buttons each having its own value each add or subtract from "stotal".The attached is a much scaled down and simplified version of the calculator. In this sample each button has a value of 200. If the user gets to 1000 or more I want to load an exiernal SWF "succes.swf" that notifies them they have reached 1000.

Here is the AS for one of the buttons. I know I need to wtite this as an "If then Else If" statement in order to get it to work but I am not having much luck;

q1a.onRelease = function(){
if (a1a==true){
a1a=false;
_root.stotal -=200;

[code]....

View 6 Replies

ActionScript 3.0 :: If Statement And Random Movieclip?

Aug 3, 2010

I'm creating a small guessing game where on stage there are 6 squares, and the user has to click on a square, and see if it's the correct one (it should be a bit more exciting when it's finished!) The random answer is created using the math.random method and I'm using an array for the square movieclips. The problem I now have is with the IF/ELSE statements.

have a look at the following code, and the bit I need you boffins to look at is just after the if statement.

var myArray:Array = [mc_square01, mc_square02, mc_square03, mc_square04, mc_square05, mc_square06];
myArray[Math.floor(Math.random() * myArray.length)].addEventListener(MouseEvent.MOUSE_DOWN , chooseMe);

[Code].....

View 3 Replies

ActionScript 3.0 :: Movieclip Focus Not Working On If Statement

Jul 7, 2010

I have created menu which has roll over and out animations.What I am trying to achieve is to play the roll over animation when rolling over the menu, but stop the roll out animation IF the focus has been set on a specific movieclip.[cod]I am not sure what I am doing wrong, but if I trace the stage focus inside the if statement nothing happens, but it works if I trace it on else statement(gives null) which means that the if statement is bypassed and the else is played.

View 7 Replies

ActionScript 3.0 :: Movieclip Focus Not Working On If Statement?

Jul 6, 2010

I have created menu which has roll over and out animations. What I am trying to achieve is to play the roll over animation when rolling over the menu, but stop the roll out animation IF the focus has been set on a specific movieclip.

Here's my code:

Code:
function menuOut(e:MouseEvent):void
{
stage.focus == contentMc;

[Code]....

if I trace the stage focus inside the if statement nothing happens, but it works if I trace it on else statement(gives null) which means that the if statement is bypassed and the else is played.

View 1 Replies

ActionScript 3.0 :: Created Some Movieclip Buttons / Set A Statement To Disable It

Nov 18, 2009

I created some movieclip buttons, set a statement to disable it, but I can't enable them again when another button is selected how can i resolve this?[code]

View 4 Replies

ActionScript 2.0 :: Continue Statement - New SWF Is Not Loaded Into Movieclip After Reaching The End

Dec 18, 2005

[Code]...

What I'm trying to do is: When this button is pressed, whatever is in the current news_Clip movieclip goes to frame 71 and plays till it reaches the end of the outro animation which is frame 101. When it reaches frame 101, I want to load a new swf into news_Clip. Using the above code, the contents of news_Clip does its outro animation but the new SWF is not loaded into it after reaching the end. I've been screwing around with this for the past 7 hours and can't figure out what I'm not doing or doing wrong.

View 1 Replies

ActionScript 2.0 :: IF Statement - MovieClip Drag And Drop Into Certain Area

Mar 27, 2008

I am wondering if I can write an IF statement that is a movieclip is drag and drop into a certain area that an event occurs. Everything I try seems not to work any idea?

View 2 Replies

ActionScript 3.0 :: If Statement : Trigger If The Function Is Triggered By A Specific Movieclip?

Jan 10, 2010

I have a bunch of event listeners that refer to different movieclips but trigger the same function.I have an if statement within this function that I need to trigger if the function is triggered by a specific movieclip.

ActionScript Code:
//movieclip stuff....
addChild(backgroundPoint);
backgroundPoint.addEventListener(Event.ENTER_FRAME, animateBall);

[code]....

I know I could just create two separate functions but the code within the function (not shown here) is fairly long and I dont like repeating code.

View 2 Replies

ActionScript 2.0 :: First Requirement Of The If Statement When Type In The Proper Input And Go Straight To The Else Statement

May 14, 2009

Having a few problems with what I thought was a simple if statement. Here is the code:

[Code]...

I can't quite figure out the small problem with the code. It seems to just bypass the first requirement of the if statement when I do type in the proper input and go straight to the else statement.

View 7 Replies

ActionScript 1/2 :: Execute Code In Previous If Statement If Second If Statement Is Executed?

Aug 31, 2011

if (variable == 1){
//code
//Execute this code.
} else if (variable == 2) {
//code

[Code]...
 
I dont want to copy the code from the first into the second and the first and second into the third.
 
My mind isn't working and there is probably an extremelly simple way to get this working.
 
I know I could used functions but for some reason it stops the instance referencing working: _root["bullet"+j] doesnt work in a function.

View 7 Replies

ActionScript 2.0 :: Loading Data From XMl File And Uses It To Run An If Statement. If Statement Fails?

Oct 10, 2008

The Flash movie contains 2 Text files, one Component button, and 1 component checkbox.The purpose of the application is to load an XML file(works)Populate 2 text fields with information from the XML file(works)Compare the two text fields, if they contain the same information then the checkbox, via AS is told to be selected. (Heres the problem);

Heres the code:

Code:
runCode_btn.onPress = function() {
data_xml = new XML();
data_xml.ignoreWhite = true;
data_xml.onLoad = function(success) {

[code]....

The idea behind this app is that its an electronic form. The user fills it out, the information is then sent to a newly created XML file, months later the open the XML file in flash, and Flash fills out text fields and check and or unchecks Checkboxes based on the XML data.CheckBoxes are mandatory.But I don't see how I'll be able to use them if i can't create and condition statements based on the loaded Data.

View 1 Replies

ActionScript 2.0 :: Create If Statement That Would Load Movie Clip After Different Movieclip Is Loaded

Apr 19, 2004

is there a way to create an if statement that would load a movie clip after a different movieclip is loaded.i have text_mc and scroll_mc. I dont want scroll_mc to load unless the content is loaded into the text_mc.I tryed to make an if statement sort of like a something used for a preloader but I must have been off just a bit because it was not working. I dont even know if it possible.

View 7 Replies

ActionScript 2.0 :: If Statement Inside If Statement Won't Work

Mar 30, 2011

why this code won't work

[Code]...

I'm sure you can put if statements inside other if statements, seriously I can't figure it out

View 4 Replies

ActionScript 3.0 :: Another 'if' Statement Inside An 'if' Statement?

Sep 22, 2010

I need to write an if statement inside an if-else statement. But no matter how I write it it keeps giving me a syntax error.The syntax error is "1083: syntax error: else is unexpected".[code]No matter how or where I place the braces, it keeps giving me errors.

View 13 Replies

ActionScript 3.0 :: Use A For Statement To Create An If Statement

Jul 12, 2010

what I'm trying to do is create an else if argument for each object in an array based on a user set number

Code:
for(var i:int=0; i < numberOfElseIfs; i++){
GENERATE AS3 CODE
}

to which I want it to GENERATE THE FOLLOWING CODE:

Code:
}else if(baskets[i].used == false){
baskets[i].used = true;
drawButton(i);
}

the problem is obviously that the compiler reads this code rather than understanding I'm trying to regenerate the code within the for loop...does that make sense :S? So basically I need as3 to read the code between the for statement as if it is going to echo that out later. Is this even possible?

View 4 Replies

ActionScript 2.0 :: If Statement In Button - Timeline Control

Feb 27, 2010

I am having a problem using an if statement in a button. What I want to do is go to a frame dependent on which frame we are already on. For example if I am on frame one and I press the button the first time it will take me to frame five, if I then press the button a second time the actionscript detects we are on frame five so goes to frame ten and so on.

ActionScript Code:
on (release) {
gotoAndPlay(5);
if (currentframe == 5) {
gotoAndPlay(10);
} else if (currentframe == 10) {
gotoAndPlay(15);
} else if (currentframe == 15) {
gotoAndPlay(20);
}}

When I first press the button it takes me to frame 5, the second time I press it goes to frame 10, but when I press after that instead of going to 15 it takes me back to 5 then 10 then 5 then 10 etc and is stuck between going from 5 to 10 and back again.

View 8 Replies

ActionScript 2.0 :: Get Control Of The Time Line Using A Conditional Statement?

Nov 26, 2008

I'm using Flash MX 2004 Actionscript.

I'm trying to get control of the time line using a conditional statement.

if (myVars.logged == "Logged") {
gotoAndStop(20);
}

I trace the myVars.logged variable and the trace tells me the value is Logged.

But the above statement won't go to frame 20.

View 9 Replies

ActionScript 2.0 :: Flash8 Variable Set-up - 'if' Statement To Run From Variable When Playhead Encounters MovieClip

Aug 21, 2009

I want to declare a variable on the main timeline that can be called from anywhere in my movie. So, _global var should be the right approach. I want to declare a movie clip 'MC1' "open", or "closed" so that when it is revisited, my flash file knows the user has been there before and performs a different task from the one it does when 'MC1' was first encountered. So, i need a 'if' statement to run from the variable, when the playhead encounters the movieClip.

[Code]..

View 2 Replies

Actionscript 3 :: If Statement Not Working - Loop Carrera(a Lenghthy Movieclip) From Frame 2 Back To Frame 1

Nov 25, 2011

This is an if stament on a frame on the root. I want to loop Carrera(a lenghthy movieclip) from frame 2 back to frame 1. (For testing purposes) This is the code:

[Code]...

View 3 Replies

ActionScript 3.0 :: Write Another "if Statement" Inside Another If-else Statement?

Sep 22, 2010

I have a script which is giving me a lot of trouble since I have no idea how to write another "if statement" inside another if-else statement. I keep getting errors, I guess I don't know where to put the braces exactly...

example:
if(bla == bla) {
<------------how would I write another if statement here?
}else if (bla == bla){
}

View 3 Replies

As3 :: Flash - Control A Movieclip From Within Another Movieclip?

Feb 1, 2012

I have got two movieclips on the main timeline. First one is envelope_mc and second is bg_main. In envelope_mc timeline there is a button on 25th frame which plays ahead when clicked.

stop();
on_btn.addEventListener(MouseEvent.CLICK, playAhead);
function playAhead(event:MouseEvent):void
{
play();
}

I have also got some animation on bg_main which I wan't to trigger on 30th frame (inside bg_main timeline) when button is clicked in envelope_mc timeline.

View 1 Replies

ActionScript 2.0 :: Button Inside Movieclip To Control Another Movieclip's Timeline?

Oct 23, 2009

I have a button inside a movieclip, to which I would like to apply a rollover function. When rolled over, this button (inside MOVIECLIP 1) would make (MOVIECLIP 2) jump to second frame. I'm using Flash 8.This is turning onto a real headache for me, since i've searched every single forum and thread concerning this matter, and nothing seems to work.

View 7 Replies

ActionScript 2.0 :: [CS3] - Control Hero Movieclip With Movieclip Buttons

Jan 21, 2009

Originally, the client wanted to control "hero_mc" using the keyboard but now they would like to control him with buttons only. Here is the original code on the "hero_mc" which works as expected:

[Code]...

View 2 Replies

Flash 'if Statement' - Getting Errors?

May 18, 2010

Ive been working on a pong game, and its coming alond well, but i have a problem with that if your score is 5, or the AI's score 5, it goes to the 'you lose/win' screen.Well, ive been working with this:

if(bluesco==5) {
gotoAndStop(6);
}

bluesco is the enemys score

6 is the lose frame

Ive tried everything i can, ive added _root.'s, changed the equals (to things like '=', '==', '>=4'), and tried things like 'nextFrame' instead of '(6)', ive changed the instances thousands of times, and if it helps:

score = 0;
bluesco = 0;

Ive also put the top code on frames, movieclips, even buttons, but i either get these errors: Nothing happens when the score gets to 5.It goes to frame 6 as soon as the frame is loaded

View 6 Replies

ActionScript 3.0 :: Switch Statement For Flash CS3

Mar 11, 2010

I currently have a code of a switch statement for as1- as2.[code]This code is for a dynamic tet with the var 'hint' (No ' ' )But in as3 there is no var and I am having trouble converting it to AS3 coding, can someone show me the correct conversion of the code to make it work with AS3. I will make the instance name 'hint'.

View 7 Replies

Flash :: Check An If Statement For A Particular Object?

Jun 9, 2011

I am trying to use a mouseevent.startdrag to move a particular movieclip, but I don't know how to go about checking the object in question. The code below doesn't seem to work with either ==Object(MCsquare) or just ==MCsquare.

function onStartDrag(evt:MouseEvent):void
{
trace(evt.target);

[Code]....

How can I run a check to see if the target object is MCsquare?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved