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




Instance Loop Control



The little man in the attached - I want the gotoAndPlay(1) command on him. The idea is that he will keep tapping his foot (up to meimpatient frame 14) until I say so, then a custom animation of him (no doubt hilariously) falling with his glasses staying in the air a bit. Unfortunately Flash does not recognise my command within the entity, so it loops the entire animation.
Could someone tell me the correct syntax, to make the entity loop, stop, play etc.?



FlashKit > Flash Help > Flash ActionScript
Posted on: 11-08-2003, 10:49 AM


View Complete Forum Thread with Replies

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

Instance Control
How do i tell target and control a movie(instance) from within another movie.

tell target doesn't work ...what do i do??

Control 3 MC's With Same Instance Name?
I have 3 MC's with the same instance name of "wrong", is there any AS i can use to only write 1 line of code to control all 3 of them instead of naming them "wrong1" "wrong2" "wrong3" then having another 3 lines of code to control them

"wrong1.onRelease = function() {
timer.stop();
rw.gotoAndPlay(16);
} "
"wrong2.onRelease = function() {
timer.stop();
rw.gotoAndPlay(16);
}"

etc...

Can anyone help?

Control 2 Objects With One Instance
Hey Guys and Gals,

I want to control to objects (movie clips) with one button. The actionscript I am using below will allow me to control just one of the objects. I want the "back1" instance to slide two seperate objects off of the screen. See the link below. Pick the menu button and then the features button. I then want to hit the back button to remove both of these panels.

Could someone give me a suggestion?

Thanks in advance for the help!

THS 2000

Here is the page!



onClipEvent (load) {
endX = _x;
endY = _y;
_x = 1350;
_y = 80;
div = 3;

}

onClipEvent (enterFrame) {
_x += (endX-_x)/div;
_y += (endY-_y)/div;

_root.main.features.onRelease = function() {
endX = 111.5;
endY = 64.5;
};
_root.back1.onRelease = function() {
endX = 603.3;
endY = 64.5;
};
}

MovieClip Instance Control
Hi All.
I'm using mx2004 (mac)

main timeline has a movieClip in it.
In the movieClip, the 1 frame has a stop(); on it.
In the main, I'm animating the frame 1 of the mc, until I get to frame 10, at which point I want the MC to play all starting on the next frame.

So, frame 10 on the main looks like this:
stop();
this.myMC.gotoandplay(2);

It just stays stuck on the MC's frame 1. I've also tried:
stop();
_root.myMC.gotoandplay(2);

and

stop();
_level0.myMC.gotoandplay(2);

and

stop();
_level1.myMC.gotoandplay(2);

I'm pretty sure ONE of these would work. So I'm thinking that I've goofed up the naming of the instance on the stage. I named the instance where the keyframe is stopped at frame 10. No change. So I also made sure that the previous KF and tween were highlighted and named that myMc as well.
Still no go.

Any suggestions would be appreciated.
sb

[F8] Button Control Instance.
Tried searching, couldnt find anything.


But I made a button with a roll over and rollout state, then i put them on my main timeline. but how do i have those buttons control a instance thats on my main timeline also?

lemme know if i dont make sense. haha

Change Instance Name In A Loop
I have an actionscript that imports values from an external php file, and I am trying to plug the different values into various different dynamic text fields.

There are almost 100 records I'm importing into the flash file. So I've written a loop that will place the different fields into different dynamic text fields, based on the instance name of the movie clip.

The problem is, how do I change the instance name in my loop?

Here's a small sample of what I got...

code: for(var i=0; i<this.cant; i++){
w1['date'+i] = this['date'+i];
w1['title'+i] = this['title'+i];
}

Now this works, but I want to avoid having to write a line for each field (80+). Thus the loop.

But how can I change the instance name from 'w1' to 'w2' on the second pass? etc.

Any help would be apprieciated.

(Using Flash MX 2004 Pro)

Instance Names From For Loop
Hello,

I am using a for loop to create multiple image loaders and have a question. I can get the script to work fine, but I am wondering if there is a way to make a specific instance name for each loader created, instead of just attaching a .name attribute.

here is my code, in case this helps answer the question:

Code:
for(var i:int=1; i<=5; i++){
var refNum:Number = i;
var kitsTNStartX:Number = -9;
var kitsThumbLoader:Loader = new Loader();
var kitsThumbRequest:URLRequest = new URLRequest("images/kits/tn/"+i+".jpg");
var kitsImageRequest:URLRequest = new URLRequest("images/kits/webRes/" + i + ".jpg");
kitsURLArray.push(kitsImageRequest);
kitsThumbLoader.x = kitsTNStartX+i*50;
kitsThumbLoader.y = 581.8;
kitsThumbLoader.load(kitsThumbRequest);
addChild(kitsThumbLoader);

kitsThumbLoader.filters = filterArray;

var kitsThumbB:MovieClip = new MovieClip();
kitsThumbB.graphics.beginFill(0x000000);
kitsThumbB.graphics.drawRect(kitsThumbLoader.x, kitsThumbLoader.y, 45,45);
kitsThumbB.graphics.endFill();
kitsThumbB.alpha = 0;
kitsThumbB.buttonMode = true;
addChild(kitsThumbB);

kitsThumbB.name = "kitsB" + i;
kitsThumbB.addEventListener(MouseEvent.CLICK, loadImage);
kitsButtonArray.push(kitsThumbB.name);
}
As it is right now, I am referencing each loader by the .name attribute attached in the for loop, but am feeling limited by it. If there is a way to create an instance name other than [object loader], I would love to hear about it!

Thanks in advance y'all!
varPBR

Target An Instance From A Loop
If you have a loop that produces multiple instances of a class (such as in the code below), how do you target these instances when
1. you dont know there name
2. you don't know there index
3. you DO know who their parent is
from outside of the loop?


ActionScript Code:
for (var i:Number=0; i < 4; i++) {
                var movementBtn:GenWorkBtn=new GenWorkBtn;
                movementBtn.name=passedName + i + "_btn";
_mainTL.menuCont.addChild(movementBtn);
private function outClick(event:MouseEvent):void {
//target instances here
        }

Using For Loop With Instance Names
Hi everyone,

I'm trying to run through a for loop and use the "i" variable to change which instance name I'm referring to, which I then store in the variable x. I then use the instance name to call a function.

Why doesn't this work -


Code:
for (var i:Number = 1; i<6; i++) {

var x = "main_mc.ball" + i + "_mc";
trace(x);

x.onRollOver = function() {
trace("hgjghj");
ballRollOver(this);
}
x.onRollOut = x.onDragOut = function() {
ballRollOut(this);
}
x.onRelease = function() {
ballClick(this);
}

}
The trace(x); produces the expected results -
main_mc.ball1_mc
main_mc.ball2_mc
main_mc.ball3_mc
main_mc.ball4_mc
main_mc.ball5_mc

... which suggests that this code should work. However the rollovers don't work (I don't even get the trace that's sitting within the rollover function).

HELP!!!!

Instance Name For Loop Question
if i have several instances of a mc with names such as BR1, BR2... BR10 or whatever, how do i write a for loop that will cycle through them all?

Loop Instance(noob)
Im just picking up actionscript and need a noob little help.

I've created a variable inside a loop and am having difficulty targeting that specific variable.

if ( var i:int = 0; i < 10; i++) {

var test:TextField = new TextField();

}


This'll create 10 variable 'test', but how do I assign number to each? Like test1, test2, test3, etc.. test[i] don't work

thanks!!

How To Set The Mc Instance Names In A For Loop?
hello,

i'm a bit confused. on my stage i have some buttons with the instance name ma01 to ma027.
this is my code but the buttons won't work in this way. the trace shows me the right instance name. can someone give me a hint?

Code:

for(i=0;i<27;i++){   
   var t = "ma0"+i;
   trace(t);   
t.onRollOver = function(){
trace("over");
   }
   
t.onRollOut = function(){
trace("out");
   }   
}


thanks a lot.

-Tukinu

Control An Instance Alpha With Button?
All I want to do is simple turn the alpha of a clip instance from 100 to 0 and back with a single button.

HELP!!!!!!!!!

Carter

Single MC Multi Instance Control
I have a MC that has several instances on stage. I dont want to target directly to each instance as more will be added and taken away at run time. I have tried setting a variable (XYZ) at root level and have the main mc look at that variable and set the ._current frame equal the that variable (XYZ). I then have two buttons the control the variable (XYZ) so that all the MC cliip instances would react and change based on the original clip. EXCEPT THAT IT DONT WORK. I think it sounds like it should but it dont. Any suggestions on how to pull this type of instance controlling off.

Thanks
Carter

How Do I Control A MC Whose Instance Name Is Stored In A Variable?
I feel like such a noob.

I have duplicated a MC 30 times dynamically in level0. Basically, I have:

_level0.dot1
_level0.dot2
_level0.dot3
_level0.dot4
.....
_level0.dot30

sitting on the stage.

I have a script running on another movie clip that chooses one of those at random:

onClipEvent (enterFrame) {
randomDotValue = int(Math.random()*_root.totalDots+1);
_root.chosenDot = "_level0.dot"+randomDotValue;
}


This is successful in assigning one of the 30 instance names accurately to the variable _root.chosenDot.

Here is where I'm stuck...how do I get that particular movie clip to play? I can't, for the life of me, figure it out and it's aggrivating me! Help!

TIA
Steve

Movie Clip Instance Control
I am trying to do a simple animation in which I have stars in the sky which brighten and dim at random times. I have created a movie clip, on which the brighten and dim tween starts at frame2 and frame1 is just a stop() command.

Then on the main stage, I have two layers. One in which I have dragged several instances of the movie clip and one for actionscript. The movie clip instances are named "star1","star2", and so forth. There is just the one frame in both layers.

I cannot get it to do anything on the instances from the actionscript layer. This is the code I am trying to use to test it and it does absolutely nothing.


Code:
_root.star1.goToAndPlay(2);


Thanks for any help

How Do I Control An Instance Created With AttatchMovie() ?
Hey guys, Im working on my new site, and Ive had actionscript pull in all of my sections using something around the following code:

_root.content_mc.attatchMovie("section1", "section_1", "1");

How can I talk to the clip I pull in with that? I tried so much stuff, but couldnt find the correct path to it.

I really need to tell it what to do, any ideas?

=)

Thanks a lot guys,

Scott
05Studios.com

Swapping From One Instance Of An Audio Loop To The Other?
I know this is sound related, but I have already posted there and found out that its impossible to loop perfectly an externally loaded MP3.

Its now over to the actionscripters to tell me if they think my theory will work for getting around this problem.

The problem is basically that MP3s loaded in will have a small amount of added silence at the beginning and end, thus making a perfect loop impossible. I have attached a GIF to try and show a possible workaround I have been thinking about. Please tell me what you think, if it would work and roughly how!!

It basically involves loading in the MP3, then creating 2 seperate instances of it, and swapping between the 2 with an overlap, using sound.position as the overlap point.

Let me know what you guys think, cheers!

Play An Instance Of A Flv For Only 15 Seconds And Loop
I need a little help here. I'm using Flash 8 Professional and using FLVplayback to load and play a FLV movie. I want an instance of this flv movie to play for only 15 seconds and continue to loop. Below is a little bit of code that I have begun working on. As you can see I'm using FLVplayback to progressively play the movie from the webserver. Any help would be greatly appreciated.
Thanks

import mx.video.*;
my_FLVPlybk.contentPath = "BonSeries.flv";
var listenerObject:Object = new Object();
// code to play the first 15 seconds of movie and keep looping


};
my_FLVPlybk.addEventListener("complete", listenerObject);
stop();

Give Instance Names To Mcs In For Loop
Hello, i have a for loop setting up items to be menu buttons, and at the moment part of my code looks like this:


PHP Code:




private var mainmenu:Array = new Array();
private var mainaddress:Array = new Array();
private var MainMenu:MovieClip = new MovieClip;

mainmenu = ["about","design","artists","projects","contact"];
            mainaddress = ["about","design","artists","projects","contact"];
            
            
            for (var i:Number = 0; i<mainmenu.length; i++) {
                trace(mainmenu[i]);
                Box = new box();
                Box.x = 0;
                Box.y = spacing + i* (Box.height + spacing);
                Box.name = mainaddress[i];
                Box.hello.butText.text = mainmenu[i];
                MainMenu.addChild(Box);
                Box.addEventListener(MouseEvent.MOUSE_OVER, over);
                Box.addEventListener(MouseEvent.MOUSE_OUT, out);
                Box.addEventListener(MouseEvent.CLICK, menuclick);

            }
            
            trace(" ");
            
            addChild(MainMenu);
            MainMenu.x = MainMenu.width + 20;
private function menuclick(evt:MouseEvent):void {
            switch (evt.target.parent.name){
                case "about" :
                trace("this is working")
                break;
                case "design" :
                trace("this is working")
                break;
                case "artists" :
                trace("this is working")
                break;
                case "projects" :
                trace("this is working")
                break;
                case "contact" :
                contact.x += 20;
                break;
                default :
                trace("this is working");
                break;
            }
        }








So, when you click any of the buttons that are generated, they each say "i'm working" etc, but with my last line, clicking contact doesn't move the contact menu as it says "contact" is an unidentified property. How do i refer to the buttons i have created if i want to animate them? the idea is that, when you click a button the buttons beneath it will scroll down, then some sub menu movieclips i have made will scroll in from the side.

Thank you so much for any help in advance, you guys are all awesome.

Dynamice MovieClip Instance Name In A For Loop
heya guyz m stuk in 2 a prob vich may b very small 4 u ol ..so kindly help me out..Luk at d code fragment below :

for(i=0;i<5;i++)
{
_root."movie"+i._x=200;
}

_____________________________
Now, i have five movie clips namely...movie1, movie2, movie3, movie4, movie5...so what i want is to dynamclyy set their x position ..n thats y m using loop but i m unable to get the desired result..error is comin in this syntax:
."movie"+i._

so kindly tell me d correct form of dynmclly chnging the path .or name of the movie clip...ill b really obliged
waiting 4 ya reply
..........

For Loop And Instance Of Loader Class
i've got a for loop and inside it i'm trying to load images into a clip created from the library (and then i assign that clip as a new material for a papervision cube). I feel like such a noob, but I can only get the last created clip(cube) to load its image. I think its because on each iteration of the loop my loader object is being consumed and recreated... zoinks!

code within for loop:


Code:
for (var i:uint = 0; i<finArray.length; i++)
{
var cubeFront:frontClip = new frontClip();
var cubeBack:backClip = new backClip();

var cF:MovieMaterial = new MovieMaterial(cubeFront, true, true, false);
cF.interactive=true;

var cB:MovieMaterial = new MovieMaterial(cubeBack, true, true, false);
cB.interactive=true;

//load image into clip
var imageLoader = new Loader();

var theURL:String = finArray[i];
var imageRequest = new URLRequest(theURL);

imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);

imageLoader.load(imageRequest);

function onComplete(evt:Event) {
trace("image"+ i +" loaded!");
cubeBack.holder.addChild(imageLoader.content);
imageLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE);
}



var mList:MaterialsList = new MaterialsList({front:cF, back:cB, left:clearSide, right:clearSide,
top:clearSide, bottom: clearSide});
var cube:Cube = new Cube(mList, 120, 1, 120, 1, 1, 1);
scene.addChild(cube);
//start cube in center
cube.x=0;
cube.y=0;
cube.z=0;
cube.alpha = 0;
var cPosX:Number = XposArray[i];
var cPosY:Number = YposArray[i];
trace("cPosX: "+cPosX);
trace("cPosY: "+cPosY);

Tweener.addTween(cube,{x: cPosX, y: cPosY, alpha: 1.0, transition:"easeInOutQuad",time:1.5});

cube.alpha = 1.0;
}

Swapping From One Instance Of An Audio Loop To The Other?
I recently found out that its impossible to loop perfectly an externally loaded MP3, which has devastated me!

Its now over to the actionscripters to tell me if they think my theory will work for getting around this problem.

The problem is basically that MP3s loaded in will have a small amount of added silence at the beginning and end, thus making a perfect loop impossible. I have attached a GIF to try and show a possible workaround I have been thinking about. Please tell me what you think, if it would work and roughly how!!

It basically involves loading in the MP3, then creating 2 seperate instances of it, and swapping between the 2 with an overlap, using sound.position as the overlap point.

Let me know what you guys think, cheers!

How Do I Know The Direct Path Of Instance I Wanna Control?
cuz sometimes if i put instance in another layer
the telltarget will not work thou the instance its still same name
why is that?
whats easiest way to find out where instance belongs to which path?

An Instance: Loop Vs. Play Once Vs. Single Frame ?
FlashMX: wondering what the difference is between the 3...

I have a single keyframe that I place a symbol (as graphic) in. Then under the "instance of: blahSymbol", I have a choice of LOOP, Play Once, or Single Frame.

Does it matter what I choose since this symbol (as graphic) will only exist in this one keyframe? I always leave it as Loop (default).

When would I use the other options and/or is it better to use the other options ?

Dynamically Setting Properties Of A MC Instance. (using A Loop)
Hi I ran into a problem you might be able to solve.

In my application a number of similar MC’s will appear each time the user will press a button. the MC’s will appear randomly in different locations. Assuming there are 5 MC’s (movie1,movie2...) I would like to run a loop so each movie instance name will get one of 5 optional values:

-------------------------------------------------------------------
B=0
while(b<4){
pos=random(100)
eval("movie"+b+"._x = pos")
eval("movie"+b+"._y = pos")
b=b+1
}
-------------------------------------------------------------------

this script does not work, I understand that it might be because you can only read variables using 'eval' but not write them. however according to the Macromedia Flash MX help :
"You can also use the eval function to dynamically set and retrieve the value of a variable or instance name..."

how can I solve this and assign the X,Y property to each instance of an MC using a loop ?

Thanks.

Problem With For-loop And Mc-instance-names Inside
Flash 6.
Within an enterFrame code I got following code:

Code:
_root.shadows(_root.MCShadowholder.MCShadow1,_root.MCObject1._x,_root.MCObject1._y);
_root.shadows(_root.MCShadowholder.MCShadow2,_root.MCObject2._x,_root.MCObject2._y);
_root.shadows(_root.MCShadowholder.MCShadow3,_root.MCObject3._x,_root.MCObject3._y);
_root.shadows(_root.MCShadowholder.MCShadow4,_root.MCObject4._x,_root.MCObject4._y);
_root.shadows(_root.MCShadowholder.MCShadow5,_root.MCObject5._x,_root.MCObject5._y);
_root.shadows(_root.MCShadowholder.MCShadow6,_root.MCObject6._x,_root.MCObject6._y);
_root.shadows(_root.MCShadowholder.MCShadow7,_root.MCObject7._x,_root.MCObject7._y);


_root.shadows is a function that returns x and y coordinates of MCShadow1-7 based on the coordinates of MCObject1-7.
_root.MCShadowholder holds movieclips previously created.
MCShadow1-7 and MC Object 1-7 are movieclips previously created.

This works very well, but now I wish to transform that code into a for-loop since I want to enhance the code. Therefore I wrote following code:


Code:
for (i=1; i<_root.NumberOfShads+1; i++) {
NameShadow = new Object("MCShadow"+i);
NameObject = new Object("MCObject"+i);
ShadowInstance = _root.MCShadowholder.NameShadow;
ObjectInstance = _root.NameObject;
_root.shadows(ShadowInstance, ObjectInstance._x, ObjectInstance._y);

//debugging:
trace("Object?: "+typeof (NameShadow));
trace("MCShadow X?: "+NameShadow);
trace("Object?: "+typeof (NameObject));
trace("MCObject X?: "+NameObject);
trace("Movieclip?: "+typeof (ShadowInstance));
trace("_...MCShadow X?: "+ShadowInstance);
trace("-----------------");
}


NumberOfShads is a constant defined in _root.Frame1 and is set to 7 atm.
NameShadow, NameObject, ShadowInstance and ObjectInstance are not created before this code.

The trace-commands return:

Object?: object
MCShadow X?: MCShadow1
Object?: object
MCObject X?: MCObject1
Movieclip?: undefined
_...MCShadow X?:
-----------------
.
.
.
-----------------
Object?: object
MCShadow X?: MCShadow7
Object?: object
MCObject X?: MCObject7
Movieclip?: undefined
_...MCShadow X?:
-----------------

so the only lines not working are:

Code:
ShadowInstance = _root.MCShadowholder.NameShadow;
ObjectInstance = _root.NameObject;


Most Probably because Name Shadow and NameObject shouldnt be "objects". The mustnt be strings either - that I know.

Can anyone tell me how I can make those lines work?

Loop Video Inside .flv Playback Instance
I have a movie clip that needs to loop inside a movie clip in Flash. Would someone post the code to paste into the ActionScript window? The .flv has no skin on it. I have done this so that I can put the video file outside of the Flash movie.

For Loop + AddChild. How To Get Unique Instance Names?
I'm totally stumped. Can someone give an example of a for loop that creates mc's which have unique instance names and can be controlled by some as later in the file?

Creating New Object Instance/copy In For Loop?
The issue I'm having is rather for the sake of optimizing my code. While I'm still new to AS3, I guess I have troubles understanding some basic concepts. Anyway, here's the scenario:

It is from a game where the user picks a crop, either apples, corn or dairy. Based on that selection, the user will be able to play a matching game with a bunch of objects moving around. Those three main objects (apple, corn, dairy) are just containers, a movieclip that holds several different subobjects, like gala apple, golden apple, etc. With for-loops, I'm looping through the main object to place the subobjects on stage. This would look like this;


Code:
/**
* Depending on crop picked, bring the appropriate objects on stage.
*/
switch (_mainTimeline.cropPick) {
case "Apple" :

var matchObjectSilo:ApplesSilo = new ApplesSilo;
matchObjectSilo.gotoAndStop(_objectToPick);
matchObjectSilo.x = _CROP_SILO_X_POS + (h * _CROP_SILO_X_SPACING);
matchObjectSilo.y = _CROP_SILO_Y_POS;
var colorTransform:ColorTransform = matchObjectSilo.transform.colorTransform;
colorTransform.color = 0xC7C7C7;// color them grey
matchObjectSilo.transform.colorTransform = colorTransform;
addChild(matchObjectSilo);
break;

case "Corn" :

var matchObjectSilo:CornSilo = new CornSilo;
matchObjectSilo.gotoAndStop(_objectToPick);
matchObjectSilo.x = _CROP_SILO_X_POS + (h * _CROP_SILO_X_SPACING);
matchObjectSilo.y = _CROP_SILO_Y_POS;
var colorTransform:ColorTransform = matchObjectSilo.transform.colorTransform;
colorTransform.color = 0xC7C7C7;// color them grey
matchObjectSilo.transform.colorTransform = colorTransform;
addChild(matchObjectSilo);
break;

case "Dairy" :

var matchObjectSilo:DairySilo = new DairySilo;
matchObjectSilo.gotoAndStop(_objectToPick);
matchObjectSilo.x = _CROP_SILO_X_POS + (h * _CROP_SILO_X_SPACING);
matchObjectSilo.y = _CROP_SILO_Y_POS;
var colorTransform:ColorTransform = matchObjectSilo.transform.colorTransform;
colorTransform.color = 0xC7C7C7;// color them grey
matchObjectSilo.transform.colorTransform = colorTransform;
addChild(matchObjectSilo);
break;
}
Although this works perfectly fine, for example purposes I only posted a couple lines out of the actual things that would need to happen in each case-statement. So rather than having some 50 lines of code per statement, where only one line is really different (first one), I would like to have only that one line in the case and the for-loop separate.

The thing that I don't understand now, how would I create a new (dynamic) object inside that for-loop, that would represent the one instantiated in the case-statement?

Here's what I've tried so far, which sorta worked but not quite; Copying.


Code:
switch (_mainTimeline.cropPick) {
case "Apple" :

var initObjectSilo:ApplesSilo = new ApplesSilo;
break;

case "Corn" :

var initObjectSilo:CornSilo = new CornSilo;
break;

case "Dairy" :

var initObjectSilo:DairySilo = new DairySilo;
break;
}

for (var h:uint = 0; h < _MATCHES; h++) {
var matchObjectSilo:Object = new Object();
matchObjectSilo = copy(initObjectSilo);
matchObjectSilo.gotoAndStop(_objectToPick);
matchObjectSilo.x = _CROP_SILO_X_POS + (h * _CROP_SILO_X_SPACING);
matchObjectSilo.y = _CROP_SILO_Y_POS;
var colorTransform:ColorTransform = matchObjectSilo.transform.colorTransform;
colorTransform.color = 0xC7C7C7;// color them grey
matchObjectSilo.transform.colorTransform = colorTransform;
addChild(matchObjectSilo);
}

public function copy(source:Object):* {
var copier:ByteArray = new ByteArray();
copier.writeObject(source);
copier.position = 0;
return(copier.readObject());
}
This throws a compile time error, at the line where it tries to access the first property;

1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.display:DisplayObject.

probably due to the fact that through the copying process, it "forgets" what kind of class/object it was before. "registerClassAlias" is supposed to take care of this but I can't use it in my case, as I can't hardcode anything in the for-loop that references the original class. Since there are three original classes (apple, corn, dairy), this has to be dynamic.

Other option I tried, did work but only half way: Array.


Code:
switch (_mainTimeline.cropPick) {
case "Apple" :

var initObjectSilo:ApplesSilo = new ApplesSilo;
break;

case "Corn" :

var initObjectSilo:CornSilo = new CornSilo;
break;

case "Dairy" :

var initObjectSilo:DairySilo = new DairySilo;
break;
}

for (var h:uint = 0; h < _MATCHES; h++) {
var matchObjectSilo:Array = new Array();
matchObjectSilo.push(initObjectSilo);
matchObjectSilo[0].gotoAndStop(_objectToPick);
matchObjectSilo[0].x = _CROP_SILO_X_POS + (h * _CROP_SILO_X_SPACING);
matchObjectSilo[0].y = _CROP_SILO_Y_POS;
var colorTransform:ColorTransform = matchObjectSilo[0].transform.colorTransform;
colorTransform.color = 0xC7C7C7;// color them grey
matchObjectSilo[0].transform.colorTransform = colorTransform;
addChild(matchObjectSilo[0]);
}
This compiles and no runtime error but it only adds one object to the stage, the one from the last loop. Despite the "new" operator, it just seems to only reference once to the original class and does not create multiple instances...

Again, maybe I'm missing some basic concepts here and there is a much easier solution. I would appreciate any suggestions, on how to create a new dynamic instance of an object inside the for-loop. TIA.

Refer To Text Instance Dynamically Within Loop
Hi all,
I'm fairly new to flash and trying to finish off an assignment using it.

Basically I have a for loop, and for each iteration of the loop I would like to modify the value of a different dynamic text box.
The loop counts down from 8 to 1 (working fine) and there are 8 corresponding dynamic text boxes. (named chosen1_txt, chosen2_txt etc)
The text boxes are in a movie clip (instance name is chosen_mc) on the mian timeline.

I am trying to build the path to the text field like so: (this code happens within the loop)

Code:
textField = "_root.chosen_mc.chosen" + i + "_txt";
textField.text = "desired value";
i is the variable used to move through the loop. I know the path and instance names are correct because if I hard code the path it works fine.
I suspect it is because the resulting textField var is a string that it doesn't work.

Can anyone tell me how to dynamically refer to a different text field on each iteration of the loop.
Cheers.

HELP-MovieClips, Array, Instance, For Loop, Dont Know
     I am developing things for others as a template.  However, because they dont know actionscript, my code has to be able to mend to what they have.  One of the things I am doing is making a maze game.  However, I am not specifying how many wall they must have.  So therefore, if I use a hitTest, I wouldnt know how many to use.  So I want to use an array and for loop.  The idea is that they will enter the number of walls, and the for loop will go through all the walls and detect if they hit it.
For example, I thought it would go like:

// walls are named wall1, wall2, wall3, etc.
for (i=1;i<numberOfWallsVariable;i++){
     if (this.hitTest(_root.wall[i])){
          //what I want to happen
          exit for;
     }
}

This way if they had 4 walls, it would check to see if it hit any of the 4 walls and if it did, it would carry out the code.  However, for some reason it doesnt work.  I believe it is because instance arrays are different in actionscript than in other languages.  Could someone tell me what I am doing wrong. Thanks in advance.

Instance Names With Loop Values Attached To The Name Possibl
Hi everyone, I was just wondering if it was possible to have loop values attached to variable or instance names.

I know that it is possible in certain situations such as the createEmptyMovieClip() or the attachMovie() where you can declare the new instance name+the value of the loop but I was hoping to be able to expand beyond that to use with properties such as ._x

I'm looking for a way to set the properties with loops instead of having to physically type them out

i.e.
mc_1._x
mc_2._x

I hope this question makes sense and doesn't confuse anyone

How To Control The Volume Of All Sounds In The Movie (even If They Were In The Time Line (no Instance Name)
Hi,

I need to control the volume of all sounds in the movie even if they were in the timeline so they do not have an instance name, by AS3.0 code?

thanks a lot.

Loop Control
I have a little animation in a movie clip and I want it to loop several times. Is there a way to tell my movie to loop without duplicating keyframes?

Thanks!

Loop Control
Hi All,
I have a loop which runs three times around. On the third time, I would like it to stop in the middle of the move.

I can get the loop to run three times around, but I can only get it to stop at the end frame. Does anyone know how to stop it in the middle on the third loop?


PHP Code:



if (numLoop == undefined) {
    numLoop = 2;
} else if (numLoop == 3) {
    stop();
} else {
    numLoop++;
}

Loop Control
Hi I'm working with loop to create buttons.
My question is: Is it possible that each clip created become a button with his own onPress function

the loop:

myLoadVars = new LoadVars();
myLoadVars.load("txt/page.txt");
myLoadVars.onLoad = function() {

for (x=0; x<Number(this.page); x++) {
duplicateMovieClip ("myBTN", "dupBTN" + x, x);

_root["dupBTN"+x]._y = x*45;
_root["dupBTN"+x]._x = 300
}
};

For exemple:
dupBTN0 will load myClip0 onPress
dupBTN1 will load myClip1 onPress
etc

Some help would be greatly apreciated
Thanks a lot.

Setinterval To Control And How To Loop?
Hi all,

I am trying to use setinterval to control the timing of my flash banner, like


Code:
//timing van onze animatie
var root = this;
anime0 = setInterval(delayStart, 1000, motionBlur, photo_mc, 75,1.5,"anime0");
anime1 = setInterval(delayStart, 1500, motionMC, text_mc,100,1,"anime1");
anime2 = setInterval(delayStart, 6000, motionMC, fotoLijst_mc,420,1,"anime2");
anime2a = setInterval(delayStart, 6500, motionMC, text_mc,5,1,"anime2a");

anime3 = setInterval(delayStart, 8000, pulse, photo_mc,50,10,"anime3");
anime3a = setInterval(showItem, 8110, digitaal_mc, true, "anime3a");
anime3b = setInterval(glowItem, 8200, photo_mc.glow_mc, "anime3b");
anime4 = setInterval(delayStart, 8100, growX, text_mc,450,2,"anime4");

anime6 = setInterval(delayStart, 13500, motionMC, logo_mc, 80,0.5 ,"anime6");
anime6a = setInterval(showItem, 13500, digitaal_mc, false, "anime6a");
anime7 = setInterval(delayStart, 13500, motionBlur, text_mc,-500,0.1,"anime7");
anime8 = setInterval(delayStart, 13500, motionMC, fotoLijst_mc,310,0.1,"anime8");
anime9 = setInterval(delayStart, 13600, pulse, photo_mc, 90,2,"anime9");
anime10 = setInterval(showItem, 13700, ballon_mc, "anime10");
anime10a = setInterval(showShadow, 13700, ballon_mc, "anime10a");
anime10b = setInterval(showItem, 13750, win_mc, "anime10b");
anime11 = setInterval(glowItem, 13700,photo_mc.glow_mc, "anime11");
and delayStart looks like

Code:
function delayStart(functionName,mcName,endX,time,intName) {
var functionName:Function;
var mcName:MovieClip;
var endX:Number;
var time:Number;
var intName:String;
functionName.apply(mcName,[endX,time,intName]);
}
Now this seems to work.

Each function has a clearInterval(root[intName]); so each interval is nicely cleared.

My questions:
1/ is there a general function to check if all intervals are cleared?
2/ how do I loop my banner??

Sound Loop Control
hey guys,

I have a sound loop that starts when the site opens. The loop happens to start with a symbol crash, so its kinda abrupt when you first open the page. I like the loop but i want it to start after the symbol crashes and then continue on looping as normal.

Is there an easy way to do this? was looking though all the old sounds stuff but didnt find exactly what i was looking for.

Cool illustration... | ='s symbol crash

|-----music starts here---------|----------------|----------------|

thanks

AttachMovie In A Loop, How Do I Have More Control Over X/y?
hi there.

i've got an attachMovie in a for loop, that creates a number of buttons, depending on how many names are in an array. as of right now i have the buttons created vertically, and im controlling the x value, like this:

ActionScript Code:
allNames = attachMovie("menuButton",myArray[e],depth,{_y:allNames._y+allNames._height+5});
allNames._x = 520;
i'd like to do two things that this won't let me do:

a. have more control over the Y coordinate, so when the loop starts i can say 'start making the buttons at x: 520, y: 350, instead of them just starting at y: 0 like they are now.

b. have a way to check if the amount of buttons reaches five in height, if so, the array starts a new column at x: 600 y: 350. im trying to have it do that about 3 times, as the amount of buttons will vary from 5-15.

is a or b possible? i've been trying to figure out both to no avail.

thanks for any insight you might have.

take care!

What About Control Loop Of Extload Swf?
I've lost the original fla for my swf and i never put a stop on it before creating it. can i stop it's looping without access to it's original fla?

AttachMovie In A Loop, How Do I Have More Control Over X/y?
hi there.

i've got an attachMovie in a for loop, that creates a number of buttons, depending on how many names are in an array. as of right now i have the buttons created vertically, and im controlling the x value, like this:

allNames = attachMovie("menuButton",myArray[e],depth,{_y:allNames._y+allNames._height+5});
allNames._x = 520;

i'd like to do two things that this won't let me do:

a. have more control over the Y coordinate, so when the loop starts i can say 'start making the buttons at x: 520, y: 350, instead of them just starting at y: 0 like they are now.

b. have a way to check if the amount of buttons reaches five in height, if so, the array starts a new column at x: 600 y: 350. im trying to have it do that about 3 times, as the amount of buttons will vary from 5-15.

is a or b possible? i've been trying to figure out both to no avail.

thanks for any insight you might have.

take care!

What About Control Loop Of Extload Swf?
I've lost the original fla for my swf and i never put a stop on it before creating it. can i stop it's looping without access to it's original fla?

AttachMovie In A Loop, How Do I Have More Control Over X/y?
hi there.

i've got an attachMovie in a for loop, that creates a number of buttons, depending on how many names are in an array. as of right now i have the buttons created vertically, and im controlling the x value, like this:

allNames = attachMovie("menuButton",myArray[e],depth,{_y:allNames._y+allNames._height+5});
allNames._x = 520;

i'd like to do two things that this won't let me do:

a. have more control over the Y coordinate, so when the loop starts i can say 'start making the buttons at x: 520, y: 350, instead of them just starting at y: 0 like they are now.

b. have a way to check if the amount of buttons reaches five in height, if so, the array starts a new column at x: 600 y: 350. im trying to have it do that about 3 times, as the amount of buttons will vary from 5-15.

is a or b possible? i've been trying to figure out both to no avail.

thanks for any insight you might have.

take care!

Sound Loop Control
I have a sound file that is an external swf which is looped. I load this sound into my flash file . It works well. I have a sound on and off button. I have given the action stop all sounds, unload movie , to try to stop the sound from playing on hitting the off button. The sound does stop when you click the off button. But for some reason after a few seconds starts playing again. I guess that is because the sound is looped. But I know that looped sounds too can be stopped by some action.
I have tried a lot of things but it doesn't seem to help. I anyone can let me know what actions can completely stop the sound when clicked on the off button.
Note that the sound file is an external swf that loads into this file.

Thank you if you can come up with the right solution.

Instance Names...changing...or Addressing Txt Field Instance Based On Instance Of Mc
i'm creating a mail form, that has a text effect which displays the type of info to be entered in each input box. To create this effect, i had to assign the variable name txt to the input boxes as well as the instance name txtBox. each of these text fields is contained within a movieclip, each with a unique instance name. what i need to do, is somehow assign a value/variable to each text field to pass to PHP to generate an email. I have always used components for contact forms so i'm not sure how to make the switch, AND.. the script i use for my contact form is an EXTERNAL AS file. (i use a customized version of a contact form from www.actionscript-toolbox.com [which apparently is no longer Flash related site])

ok.. this is hard to explain..... so bear with me....
If my original mail form component instance names were: tiName, tiEmail, tiSubject and taMsg (ti for textInput and ta for textArea)
and my current instance names for the mc's which CONTAIN the input boxes (with txtBox textfield instance inside them) are: name_txt, email_txt, subject_txt & comments_txt...

how would i pass/convert the users input text in each movieclip's txtBox, into the original instance name for my mail form so i can continue to use the form/PHP i have been using??

OR....

how do i take the values input by the user in each txtBox (i.e name_txt.txtBox.insertedTextFromUser or name_txt.txt, email_txt.txtBox.insertedTextFromUser or email_txt.txt) and send them to a new PHP script to send mail??

please keep in mind i am PHP retarded... hence why i re-use the same form over and over..

thanks in advance for any help. it's greatly appreciated...

if you're confused about my problem, please let me know... i'm having a difficult time explaining....

How To Control The Loop In The Soundloop Actionscript?
Hello
Just a simple question, I use a sound with this actionscript method :

mySound=new Sound();
mySound.attachSound("linkageName");
mySound.start(0,99);

My question is

Is there a way to control the loop number???

For example, I play 99 times my sound with :

mySound.start(0,99);

but at the loop 4 I want to launch an other Sound...

What is the most simple way to control this number???
Do I have to put a MovieClip which always control the loop number of my sound???
Thank You!

Guitz

Control A Series Of Buttons With An AS Loop
I have a series of 10 buttons. I want the buttons to be able to "automatically" click, as if the user is clicking them with an interval of 1 second in between the clicks. Is there a loop that I can use to keep these buttons firing, one after the other with a second of time in between ?

Dynamic Sound: Loop Control
hi,

i'm trying to loop some seperate music tracks and mute the sounds individually by buttons- a bit like a mixer or sequencer. i'm loading them from the library using attachsound and looping them using onsoundcomplete which is fine if the loops are all exactly the same length but what about if i want to sync a sound that is not as long as the whole loop to only play at the beginning of the loop? eg. a cymbal crash at the beginning of a drum beat.

i've tried to contain all the sounds on one soundcomplete command eg...

drum.onSoundComplete = function() {

drum.start();
bass.start();
synth.start();

}

which works fine to keep the loops together but now all the volumes are set to zero when i press the button controlling the drum track. i tried to add a variable which was flicked to true onSoundComplete and when the variable was true trigger sounds to all start again. but instead they stopped looping altogether.

cheers,

dave.

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