ActionScript 3.0 :: Looping Through Stage And DisplayObject Items?
Aug 7, 2009
I'm trying to convert to Actionscript 3.0 and I'm trying to find out how to loop through Stage objects as well as DisplayObject.With AS 2.0 - I would only have to do:
[code]
for(var i in _root) // or MovieClip, this, ect
{
[code].....
View 1 Replies
Similar Posts:
Aug 7, 2009
I'm trying to convert to Actionscript 3.0 and I'm trying to find out how to loop through Stage objects as well as DisplayObject.
With AS 2.0 - I would only have to do:
[Code]...
This kind of works but the o[prop] always traces undefined and it's not showing any movieClips on the stage.I would like to be able to have the debug object function be able to take Stage and DisplayObject arguments like such:
[Code]...
View 1 Replies
Aug 7, 2009
Actionscript 3.0 looping through stage and DisplayObject items. I'm trying to convert to Actionscript 3.0 and I'm trying to find out how to loop through Stage objects as well as DisplayObject.
With AS 2.0 - I would only have to do:
for(var i in _root) // or MovieClip, this, etc { trace("i: " + i + " [i]: " + _root.[i]);}
In AS 3.0 I found this equivalent which works w/ some objects:
public function debug_object(o:Object, show_all:Boolean):void {
import flash.utils.*; var def:XML = describeType(o);
var props:XMLList = def..variable.@name; if(show_all)
props += def..accessor.@name;
for each (var prop:String in props) {
trace(prop + ": " + o[prop]); }}
this.showChildren(Stage);
This kind of works but the o[prop] always traces undefined and it's not showing any movieClips on the stage. I would like to be able to have the debug object function be able to take Stage and DisplayObject arguments like such:
this.debug_object(Stage, true);
this.debug_object(flash.display.DisplayObject, true);
View 12 Replies
Oct 4, 2010
I have multiple object doing random movement with random speed. i wanted to repeat the animation.I tried to use onComplete to restart each object once the animation end, but how could I specifically target it to that object? Currently its overflow
private function lineAnimation (e:DisplayObject):void
{
TweenLite.to (e,randomTime, {x:randomX, onComplete: lineAnimation(e)});
[code]......
View 1 Replies
Sep 23, 2010
I'm trying to resolve the following:I'v got a long xml file with a node called 'ows_Sub_x002d_Site' - this has several different values (e.g Home, about us e.t.c) which i then filter to make sure only items with that specific value are then looped thro to build a menu.
That part i got sorted (see below).The problem i have is that i need to know how many items there are in the xml file with that value before i loop thro the xml and build the menu (so i can determine the overall width of the menu e.t.c).
function buildTheMenu():void {
var filterBy:String = "Home";
var rss:Namespace = new Namespace("#RowsetSchema");[code]....
View 1 Replies
Mar 2, 2010
im building a product menu that loads a bunch of images through xml and uses one movieclip instance for the texts.URL..So far my code loads the 5 items and gives them 600px of space in beetween. This way i can use next/prev navigation. But the problem is when i reach the last one, it should loop, so that after the last one should come the first one again. And same in reverse for the prev-arrow.I have all this code inside a movieclip that im now controlling with the arrows:[code]And i cant get my head around that where should i include the looping, in pseudocode: "if picture x <= -600 reload it as the last picture && if picture x >= +600 reload it as the first picture"
View 1 Replies
May 14, 2011
- I have A.fla.
- A.fla includes buttons, movie clips and also B.swf is loaded in A.fla using a LOADER
- i want to access elements in A.fla, from the actionscript codes inside B.fla to modify those movie clips and buttons based on actions going on in B.swf
for instance, lets say there is a button X in A.fla, and there is a button Y in B.fla, B.swf is loaded into A.fla, and I want the button Y to erase button X when clicked.
general question: accessing elements in a stage, through a SWF file loaded into that stage.
View 2 Replies
Jan 28, 2010
How do I access the stage in Actionscript 3 in a class which is not my main class and not a displayobject?
View 4 Replies
Mar 3, 2012
The REMOVED_FROM_STAGE event is fired before the object is actually removed from the stage. I'm looking for a performant way to know when the object is finally removed.
View 3 Replies
Oct 26, 2010
I would like to be able to quickly check if a given DisplayObject is a descendant (not in the inheritance sense - ie. child, grandchild, great-grandchild, great-great-grandchild, etc.) of another DisplayObject. There doesn't seem to be a native way to do this and I can only think of two ways to achieve it: Create the mother of all nested loops. Seems a bit, I dunno, wrong? Dispatch a bubbling event at the 'child' and check if the potential 'parent' receives it.
[Code]...
View 2 Replies
Jul 2, 2011
I needed to make my document size larger. Is there an easy way to center all the content in the new size? Right now everything is flushed to the top left corner.
View 3 Replies
Jun 21, 2010
I am using preloaders to load "modules" of pictures. They are working but I need to unload them before navigating to the next frame (to load the next module). Is there a way to condition action upon leaving a frame? Do I need to create some kind of unloader before the preloader? That might be difficult because I won't know what page I am navigating FROM. Here is my loader [code]...
View 0 Replies
Nov 23, 2009
As this involves assorted dragging interactions to understand this explanation take a look at the file.URL...it should work like the last item on this page, called exploring kite interactive Url...I have a mc which includes 5 dots that can be dragged in various ways.each one needs to be limited to the stage area when it is being dragged.The limit should only apply to the dot when being dragged. If a dot being dragged causes another to exit the stage area that is fine.I have tried a few ways, none work too smoothly.One issue is that a dot which stops dragging at the edge can be hard to pick again.Another issue is that if you drag really fast you can drag a dot offstage. This is usually when the top or bottom dot is dragged quickly from where it has stopped at the edge and the mouse is released just outside the stage.FLA is attached.
View 7 Replies
Nov 17, 2008
So, I have a file where I've added 27 movie clips to the stage using a for loop to cycle through items in an XML document. Here's the pertinent part of the code I'm using, it's AS3:
So, I end up with 27 instances of mini_mc, each named 0, 1, 2, 3, etc.
I'm trying to write code to remove them at a certain point in the movie but having problems. Here's what I'm using[code]...
View 5 Replies
Apr 8, 2009
In actionscript 2 if you wanted items on the stage to not appear to the user you would just use the onclipevent(load) and then move them, alpha them and so on. In as 3 I cannot figure out how to get the items off of the stage before the stage renders them. There's always a flash of the stage items and then they disappear. What should I use? I don't like the addChild method because it's impossible to design a site that way. I like all my items on the stage and then go from there...
View 7 Replies
Jun 23, 2009
I have an app that uses several Loader objects to load extenral swf files. Things go well except for one point. I have a quiz element that's loaded through a loader named 'quiz'. When the quiz is done, I remove the quiz element with removeChild(quiz). The quiz disappears from the screen every time except for one question. I can't identify what's going on differently for that question. I've debugged this and can see that my quiz object is set to null, but I can plainly see the quiz still onscreen.
To further confuse me, I use the same loader object multiple times through the app, and just add it and remove it from the display list with addChild and removeChild. When my one problem question comes up and fails to go away, the app continues to the next question, and I can see that there are now 2 quiz objects stacked on top of each other. I have no idea how this can happen when I'm using the same loader object for all the questions.
[Code]...
View 1 Replies
Apr 14, 2010
I am adding few items dynamically from the library to the stage by creating instances. If I remove them using removeChildAt() then the item gets removed from the display but exists in the memory. How can I remove this from memory?
View 2 Replies
Oct 7, 2010
I am using the CS4 version and when I click on the library item and drag it to the stage, there is nothing there. It is just a blank canvas and it's like the image(s) are hidden behind the stage or something. When I do a Publish Preview, I can see the .swf file with all the images, but in the .fla, there is nothing showing but the text files, and then that is even hidden in a newly created file. I am not sure if I accidently turned something on/off that is preventing my images from not showing on the stage or what. I really need to find a solution to this problem because I need to create a Flash file for a project I am working on in one of my classes. Does anyone know what could be causing this? I have done Google searches and Forum searches to no avail unless I'm not using the right keywords in my search.
View 2 Replies
Sep 9, 2009
I have the AS to move pictures around (like a jigsaw puzzle i guess), im just struggling with setting boundaries so that the pieces cannot be dragged off the stage...
Im presuming setting the boundaries is a matter of adding X and Y values or similar.
View 1 Replies
Jul 16, 2010
I've been trying and trying to delete some basic cards from the stage whenever I reset a game, but thus far absolutely zero luck.
[Code]...
View 7 Replies
Aug 10, 2010
So what will be faster:a) From actionscript construct library items and put on stage and Tween;b) Or keep those library items on stage, but not on visible zone and then with actionscript make them appear with a Tweener?
View 9 Replies
Aug 5, 2011
I have a lot of different movieclips on the main stage, with a majority of them being mcHotspot movieclips. These mcHotspots are simply yellow boxes which display a 40% alpha so users can see where they can click on the stage. When you click one of these hotspots, a menu is displayed which contains more mcHotspot movieclips embedded within it.
I'd like to have a single button that will loop through all the items on the stage and display anything that is of type "mcHotspot". Is this possible, and is there a way I can dig down into any items of type movieclip that are NOT mcHotspots to see if they have mcHotspots themselves? I'm basically looking to use a recursive loop that will go to the lowest level. I know there is a typeof function that returns either Number, String, movieclip, etc. but is it possible to know what type of movieclip it is?
View 2 Replies
Mar 11, 2009
I have instances of items on the stage, on various labelled frames. I have an actionscript class that uses gotoAndStop('framelabel') to move forwards and back. When using the IDE this works perfectly.
However, when I view the swf on its own, or in a HTML page, I get the error:
Error #1009: Cannot access a property or method of a null object reference.
If I use a timer to create a delay between gotoAndStop and trying to reference the items it also works fine. So it seems that when using gotoAndStop, the actionscript is trying to access the items on stage before they have been added to the display list.
Is there a way to force Flash to load the display list of the frame it's stopped at before trying to access those items? Surely it should load the stage instances before running the actionscript?
Below is an example of the script
Code:
private function goThree(e:MouseEvent = void):void {
Main.root.gotoAndStop('Three');
var btnMinus:SimpleButton = Main.root.getChildByName('btnMinusThree') as
[Code]....
View 2 Replies
Sep 10, 2009
why when I place something on the stage it does not match up on the web page. Do I have to set the co-ordinates of the item for it to appear in the correct place on a web page.
View 2 Replies
Nov 27, 2010
In CS5, I want to have a frame with buttons that when clicked, reveal different graphic symbols or movie clips (I'm not sure what to use?). The symbols will reveal text information and graphics, and might fade in when clicked, though will not move or do anything else.
1. Is it better to make these text and graphcis into movie clips or graphic symbols?
2. How do they get hidden on the stage until a user clicks on a button to reveal it?
3. Using Code snippets, which option will make this work?
View 7 Replies
Feb 4, 2009
I want to rearrange an item on stage when the visitor changes the browser size. The item is initiated in an external class G94Menu:
ActionScript Code:
public function addItem(item:MenuItem):void
{
item.y = (item.height + _spacing) * _items.length;
[code]....
View 0 Replies
Mar 7, 2012
How to access a display object on the stage in a class which is not a document class?
I am looking for a solution that doesn't involve passing the stage as a parameter to the class.
One solution i always come across is using "TopLevel.as". Is it a good method because as far as I have heard using global variables is not recommended because it might cause some problems while working on big projects.
View 1 Replies
Dec 27, 2010
I have an AS2 .fla with all of my stage items on the timeline as opposed to inside a container swf. I must chose Center vertical and Horizontal options in the HTML alignment options when publishing in order for my movie to be perfectly centered in the middle of the browser. I would like to have a FULL Browser Background Image, however when I try using the following code, my background ("bg") does not fill the entire browser.
what I am doing wrong and if it is even possible to have a full browser background image while still using CENTER alignment in the HTML publish settings? I have tried the following code with and without the Stage align settings and with the xy coordinates centered-still no luck!
bg.Stage.align = "TL";
Stage.scaleMode = "noScale";
bg._width =Stage.width;
bg._height =stage.stageHeight;
bg.x = 0;
bg.y = 0;
View 30 Replies
Feb 16, 2011
I have a for loop wich passes 11 times:
private var currentItem:uint;
for(var i:uint = 0;i<10;i+){
addChild(arr[currentItem]);
[Code]....
So the problem is that the array only contains 6 items. So when it comes to the 6th item the currentItem resets and the next 4 items that are getting added are the 4 first from the array again. Now when i trace the items, the last 4 trace "null". how can i add items from the array multiple times without losing its properties etc?
View 1 Replies
Oct 6, 2009
What I'm trying to do is dynamically assign instance names to movie clips placed on the stage based on their position on the stage. Say if one had an _x value of 1, i would want to assign that clip the instance name of "clip1" and if another had the _x value of 599, I would want to assign that clip the instance name of "clip599". Logically, I would think it would work like this (placed on each individual movie clip):
ActionScript Code:
onClipEvent (load) {[code].....
View 3 Replies