ActionScript 3.0 :: Using Addchild With Loop?
Mar 29, 2011
I had a previous old script working with AS2 and have tried to convert it as the new system requires AS3 .the below script :
function displayItems() {
var xPos = 0;
var yPos = 0;[code].....
This gives me the following for the bolded line
Scene 1, Layer 'as', Frame 1, Line 44 1067: Implicit coercion of a value of type String to an unrelated type flash.display:DisplayObject.
This line used to be addmovieclip which worked. I'm not sure how to edit this to suit the new addchild method.
View 12 Replies
Similar Posts:
Feb 8, 2012
Is there a simple equivalent to what I used to do in AS2 to add a bunch of new objects to the stage and throw them into an array so they can easily be referenced? I'm finding this more difficult than it used to be.
Old code:
ActionScript Code:
mc_array = new Array();
for(i=0;i<5;i++){
[code]....
View 6 Replies
Jan 20, 2010
Is there a simple equivalent to what I used to do in AS2 to add a bunch of new objects to the stage and throw them into an array so they can easily be referenced? I'm finding this more difficult than it used to be.
[Code]...
View 3 Replies
Aug 14, 2009
I've a loop that adds a child (loader that loads image) to the stage.
This is working fine but when I go to the other page the images just stays on the screen.[code]...
View 4 Replies
Mar 5, 2011
Ok what i want to do is to put MORE than one instance of a MC on stageFor that i try to create a name to the MC inside a (FOR) loop (working)what dident work is to put multiple instance of it on stage.Seem preety basic but i can figure it out
function generateHex(e:MouseEvent)
{
tileSet.x = tileSize;
[code]......
View 2 Replies
Mar 10, 2008
I want to load multiple different movieclips from my library(mc1, mc2, mc3 etc.)with a loop and I can't seem to succeed with this..
each movieclip is unique and it would be a nightmare to code them.
View 7 Replies
Jul 18, 2009
I am just trying to grasp a simple concept of utilizing loops, addChild, and eventListeners.My goal is to use a loop to create multiple instances of the same type of object from my library (called Ball), and when one is clicked, have it move "above" all other instances on the stage (and eventually drag, but that's easy enough to make happen later).My current code attempt is:
for(var i:uint = 0; i<=10;i++)
{
var my_ball:Ball = new Ball() //new instances of Ball from library export
[code].....
View 2 Replies
Jan 7, 2011
I cant get addChild to work withing a loop (while).
I have a range of movie clips in the frame hidden away. These are called item_1, item_2, item_3 etc.
It works FINE when Im adding say item_1, then item_2, but if the code tries to add "item_1" twice, it seems to just overwrite the first new "item_1"!?!
This is what I need to do, and it just wont work!
ActionScript Code:
while(i<10){
this["item_new_"+i] =new MovieClip();
this["item_1"].y = 0;//I put this in just to make sure they line up right
[Code].....
View 8 Replies
Mar 31, 2011
I have a MovieClip called item with the same linkage set and my first task is to display 10 of these items on the stage nested inside a movieclip called MainItem. I have dragged MainItem to the stage and have the following for loop:
[Code]....
View 5 Replies
Jun 15, 2011
I'm trying to have a class file which can add objects to the stage via addChild; however, when I call addChild from within the class file, I get the error "1180: Call to a possibly undefined method addChild." I've tried importing flash.display.* and that doesn't fix the problem. Does the class file have to extend Sprite or MovieClip to be able to add objects to the stage?
View 8 Replies
Jan 16, 2012
I have downloaded Box2d ([URL]) and created a project that looks like this: [URL]. catalyst is the green cube and it has the base class "shapes.box", it is inside "world" which has the base class "wck.World". What i want to do is to add another "catalyst" from the library inside "world" when i click on add_btn. I tried to accomplish this by this code:
[Code]...
Symbol 'buttons', Layer 'Actions', Frame 1, Line 41061: Call to a possibly undefined method addChild through a reference with static type Class.
View 9 Replies
Jan 20, 2011
I have the followings:
_p:Player (which is a MC)
a1:Animation1 (which is a MC)
_p.addChild(a1); //doesn't display anything
_p.stage.addChild(a1); //displays a1
Why won't the MC display a child without using his stage?
View 1 Replies
Aug 11, 2009
I'm trying to resolve an issue that reared it's ugly head yesterday.Frame one of main timeline I have the following code:
Code:
import flash.display.MovieClip;
import flash.events.MouseEvent;
[code]....
The newMC doesn't show up.If I add 'parent.' in front of the addChild then it appears.mc_LibItem has a base class of "flash.display.MovieClip" and is exporting for ActionScript and on frame one.For grins I created a new .fla and began messing around with the same addChild idea and it worked.
View 14 Replies
Oct 30, 2005
somewhat understood the basics of adding and removing children, however, I am facing another problem. After using the removeChild Function, I can't seem to add another child.For example:
ActionScript Code:
var attachedMC = new (getDefinitionByName("Content1") as Class)()
Page.addChild(attachedMC);
[code].....
View 3 Replies
Jul 29, 2009
I have a main "shell" swf which, by clicking several buttons, will load/unload various external swfs into a Placeholder_mc which resides on the main timeline in Shell.swf In the documentation and tutorials I've seen a couple different methods, and I'm not sure I quite understand the difference, or at least the reason you would use one over the other...In the 1st method, you can just add the Loader object using the addChild() method:
Code:
var myLoader:Loader = new Loader();
var myURLRequest:URLRequest = new URLRequest("ExternalFileA.swf");
myLoader.load(myURLRequest);
Placeholder_mc.addChild(myLoader);
This will apparently add myLoader to the display list once it has completely loaded.The 2nd method, you supposedly can add the Loader.content; however, it appears you can only do this once the content has completed loading, so you need to incorporate an event handler with the contentLoaderInfo object:
Code:
var myLoader:Loader = new Loader();
var myURLRequest:URLRequest = new URLRequest("ExternalFileA.swf");
myLoader.load(myURLRequest);
[code]....
What are the pros/cons of adding the entire Loader object, as opposed to the Loader.content and vice versa?
View 7 Replies
Apr 16, 2010
I would like to create a loop so the icons in the menu continually loop indefinitly.[code]
View 2 Replies
Dec 11, 2010
I am attempting to use a loop to create text field with the loop's current value. The code looks like this:
ActionScript Code:
for (var i = 1; i<=10; i++) {
var 'nameHolder'+[i]+'_txt':TLFTextField = new TLFTextField();
'nameHolder'+[i]+'_txt'.x = 40
'nameHolder'+[i]+'_txt'.y = 40
'nameHolder'+[i]+'_txt'.text = "Hello World"
}
So essentially what it should do is create 10 text fields at 40, 40 with the text: "Hello World".
View 7 Replies
Jun 13, 2004
i'm trying to do an infinate loop for my m.clip.the looping part does not want to loop...it loops back to my firrst frame even though there are two same picture in the movie clip.....here's a sample of what i use for the infinate loop script..
[Code]...
View 2 Replies
Jul 20, 2009
I have need of loops / nested loops that pick different figures depending on where you are in the loop. The whole function needs to run through 'ml' times. 'ml' is a dynamic figure. Loop 1 = While the loop is within the first 12 iterations, 'exconemp' must equal 100. For iterations 13 - 24, 'exconemp' must equal 102.5, for 25 - 36 it will be 105.06, for 37 - 48 it will be 107.69. This needs to change every 12th iteration until it has reached 'ml'. The calculation takes the value of the previous 'exconemp' and then multiplies that by 0.025.
Loop 2 = While the loop is within the first 120 iterations, 'abc' must equal 0.015 and any further iterations must use 0.01. This must also work in a way to figure out whether 'ml' is higher or lower than 120 and work accordingly. My main issue is this - how do I get the loops to run through as this: While the iteration is < 12, do this, THEN take the final figure (12th iteration) and start on 13 - 24, do this THEN etc etc. How do I produce a THEN statement? I can get the code to pick up the final values, but not change along the way.
[Code]...
View 6 Replies
May 5, 2011
Say, I had a loop in a function...
[Code]....
How would I refer to a in another function
View 8 Replies
Nov 9, 2010
Should I declare the _mcContainer var before the loop or no? (performance increase?)
for(var i:uint = _startIndex; i <= _endIndex; ++i){
var _mcContainer:MovieClip = _mcParent["i_" + _position];
}
[Code]....
View 1 Replies
Jun 2, 2011
Recently I'd been criticized for structuring my for loops like so:
var i:MovieClip;
for each(i in array)
{
[Code]....
This reads better for me personally, yet I'm being attacked for it. Is there any difference?
View 2 Replies
Nov 29, 2011
basically I need a loop within a loop to compare two different arrays in my actionscript3 lottery game. I have attempted the loop but I cannot seem to get it to work ...
[Code]....
So basically within this code check_win is a button. Once the button is clicked it runs the loop. It is meant to take an instance of matches which contains 6 properties and loop until index is greater than matches. According to my output this is happening but the second loop doesn't appear to do anything.
View 1 Replies
Aug 25, 2010
How do i word a for loop to make it loop through multiple arrays?I want 1 for loop to loop through multiple arrays in order to move/alter objects.I want to keep the arrays separate.
ActionScript Code:
characters = new Array();
characters[0] = male;
[code]........
View 3 Replies
May 15, 2011
I'm trying to make a matching pairs game. First of all I'm making all the tiles, using a loop inside a loop. How do I get the ID of an item inside that loop? My code looks like follow:
Code:
var matches:Array=new Array(1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8);
makeTiles();
function makeTiles() {
[Code].....
View 3 Replies
Aug 27, 2005
dayVal = day.value;
for(dayVal = 1; dayVal/7 != 1; dayVal++)
{trace (dayVal);
}
the loop starts at 0 and not 1 so the loop ends at 6 does any one know how to resolve this issue?? its so that what ever number dayVal is it will be rounded up to a number that is Divisble by 7 .
View 4 Replies
Feb 19, 2007
Basically, I have data organized by date in an XML file. I'm trying to make a website application that will allow the user to click on a date (in a text field) to see another textfield populate with all the data under that particular date. So far, all the information loads into the textboxes at the same time. How can I get it to only load information under a particular date when somebody clicks on that date?
Before I started this project, I was convinced I could do this by manipulating the [j] (see code below) in the myFunc2 function. Currently, it's set up to increment blank_mc._y by whatever value is returned by [j]. But for some reason this doesn't work. I feel that if I could atleas get this part to work - I could probably do the rest.
AS code:
Code:
function loadXML(loaded) {
if (loaded) {
var nodes = this.firstChild;
[code]....
View 1 Replies
Mar 2, 2007
I have some code that seems to have a problem. I can't seem to pass the x variable from one loop to within another loop.
Code:
var myLv = new LoadVars();
var myNv = new LoadVars();[code]....
View 2 Replies
Mar 20, 2007
wondering if anyone knows if its possible to have a pause within a 'for loop' before it runs through the next loop? heres the script i've built up so far, i'm running off other variables and arrays to pull in the logos and the animating in is working fine except that they all run in at the same time, basically what i want is that they would run one after the other with a 5 second gap between them..[code]so i did that and put wait(delay); after the var boxcounter=2; in each of the If statements.. but no luck... can anyone shed any light? or suggest a way it get it to hold for a few seconds before running though the loop again? or am i going about this in completely the wrong way??!
View 5 Replies
Jun 30, 2011
I have published my intro to my website I checked "Loop" and unchecked "Loop" under the Flash section of publishing no matter which I it continues to loop and not go to my website. This is the action I am using:[URL]...
View 1 Replies