Actionscript 3 :: Dealing With Display Objects On The Stage?
Oct 3, 2011
I think there are 2 different practices with dealing with display object on the stage.You draw all the objects on the stage and then manipulate the "visible" attribute to show or hide them.You use addChild and removeChild to manipulate the visiblity.How do you think what is the best method for this?
I am making a strategy game and came across a kind of problem. Basically, I don't know how to deal with the dynamic creation of the units I need. Should I use some big switch statement or is there a more ideal solution?
I'm new with strings and arrays. I want script to calling display objects to the stage and the timer to move images up and down to appear like a scrolling numbers. I start getting sloppy, and mess up passing to Tweener.
- An explanation or strategy may be enough, "I've got pretty close on this one" - There was confusion regarding the Containers and addChildren...looked like arrays
The code "get as far as error with NumbersView and numbers undefined etc".
The methods were proved separately. "I got a earlier version of the document going, but I need to work through this to understand it."
Symbol Properties Class ImageView Tweener The "caurina" folder needs to be present Rolling Numbers "Success loading numbers and connecting to counter".
Placed the movie clip object on stage with two dynamic text fields in it. Make sure the container is placed on stage, has the two text fields in it, and everything is given a proper instance name. Also include the caurina folder.
Seconds MovieClip symbol with instance name of seconds firstDigit Dynamic text field with instance name of firstDigit, placed in seconds secondDigit Dynamic text field with instance name of secondDigit, placed in seconds
Symbol Un-tick 'Export for ActionScript' Use 'Name, Class, and Instance' correctly
How can I use arrays and some how display my objects accordingly based on my code below?
What I have here are three buttons that when clicked a new clip is added to the stage with a predefined position which means that when button1 is clicked the MovieClip will be added at the very top and when button2 is clicked the MovieClip will be added at second and when button3 is clicked the clip will be added at the very bottom, but what I would like to do is to be able to dynamically position these objects based on how many clips exist, in other words if button3 is clicked first, I want the clip to be positioned at the very top and if later button1 is clicked the clip is positioned
Accordantly (at second place). I know this may be simple, in fact I could probably use a few IF statements but I know the code would look ugly (yes, even more) and I may have add more buttons later. What I would be awesome is to some-how use arrays or something that makes more sense to hold the MovieClips and then display them accordingly.
I've been putting off asking this question and have tried to resolve it myself since it would seem to be so basic; however after much frustration , here goes:Can a display object (ie an instance of a class loaded from the library such as a filled rectangle {trying to keep this simple} be positioned on the main stage by using the following syntax:myrecTangle.stage.align = StageAlign.BOTTOM;I have created a fairly simple class to load objects to the stage by class type (recTangle) and name (myrecTangle) and all works fine up to the positioning. The objects are created and named properly and are placed on stage; however, they are all placed on stage at 0,0 stage coordinates. I can postion them anywhere using x. and .y values but when I use syntax similar to that above they are still positioned at 0,0. There are no errors thrown. I have also tried to create a sprite for each, load them into the sprite and addChild the sprite to the stage. They are still positioned on stage at 0,0. Is the stage.align/StageAlign syntax peculiar to absolute main stage positioning or am I allowed to use it also for object positioning.
If an object exists outside of Flash's stage boundaries, is on the Display List, and is visible, is it causing a performance hit from Flash rendering it? In other words, does Flash render what isn't seen?
This leads me to believe so: http://stackoverflow.com/questions/170203/how-do-you-make-flash-not-render-an-object-on-the-stage
When using Loader class to load display objects (bitmaps, SWFs...) from remote URLs, is there any way for them to be instantiated (referenced as we know, by Loader::content property) as some user specified valid subclass? For example if I had a class that extended a Bitmap, is there any way for the loaded object to be of this class?
Is there any way to display flash objects which are outside the display area when flash is embeded in HTML The reason i ask is my current project has a rotating + enlarging effect which is largely dynamic so sometimes an object may clip the edge of the stage areathis looks messy but i dont want to increase the stage area to cover the largest possible area any object could enter because most of the time the objects are at the center and small so i would end up with a lot of white space
I have a list containing display objects from throughout the application (insertion order). I want to process the list either top-down (parent, child) or bottom up (child, parent). The only requirement is that either a parent is processed before any child or vice versa a child before its parent. What is a good approach? This question is not about sorting a list. It's about retrieving the depth of a particular display object.
Example Display list: A (root) B1 C1 C2 D1 B2 ......
My list: list = [E1, F4, A, B2, B1, C3, ..., N9, N8]
Bottom-up: N9, N8, F4, E1, C3, B2, B1, A
Top-down: A, B2, B1, C3, E1, F4, N9, N8 Does not matter if N9 before N8 or N8 before N9. Important is that any N is before M (first run) or any M before its children N* (second run).
How do I identify all the display objects in the display list in ActionScript, bellow the one that I have clicked? All the other objects are shadowed by the first one. What if other objects have visible parameter as hidden?
I have drawn colored rods which I have placed in the library and have put one of each on the stage with instance names likeblueRod_mc, etc.I place them around with time-line code like blueRod_mc.x = 300.0;I have now created an Actionscript class called Problem.I build a new object from Problem which I have called Riddle.But when I put blueRod_mc.x = 300.0 in a method (of Problem),I get the message that blueRod is not accessible.So I triedstage.blueRod_mc.x = 300.0;That did not work either.
I'm writing a web based flash app that's written entirely in AS3. I have objects on the screen as part of a GUI. I would like the user to be able to resize the window, or make it full screen. I would like everything to auto-scale with the resize, but also remain in the same relative position on the stage.
I have a library swf (asset.swf), it's document class binded to Asset.as, and in the Constructor function of Asset,[code]as known to all, we cannot visit the stage attribute before the display object added to the stage.so, when my loader.swf try to load asset.swf, it throws exception and the loading come to failure is there some one tell me how to load the asset.swf? I cannot modify the asset.swf.
I'm trying to get data from a namespaced xml file in a flex app. There is a root namespace (xmlns="blah") and another namespace (xmlns:i="blah"), and I'm able to access most tags using the following: var ns:Namespace = doc.namespace(); var result:XMLList = doc.ns::element;
However, there are several tags that are subject to change in the application, and i'd like to not hardcode them, possibly using the elements method: var result:XMLList = doc.elements(configuredField); Is there a way to get elements with namespaces using the elements method, or a similar way to get XML elements in flex using a parameter?
I'm making a small memory game that is XML driven (users can upload images into the game). I've come to the point where I need to check if the user has filled out certain nodes or not, and if so; check that the input is valid - int when int is expected and whatnot.
What are the ways to check this, and which is best? So far I've only tried checking if a node is == "" or not, but I imagine there must be better ways. I will include lots of switches for the user which should all be optional. This calls for a neat way to validate it.
I am testing parts of an application as actionscript-only and then merge them into a flash project.[code]things align perfectly. When I do the same in flash, s1.height is 0 and objects sit on top of each other?
i don't understand why none of my display objects are not being removed. when i press the button, i'm expecting a trace and removal of both shapes and the button, but nothing happens:
[Code]...
i realize there are better ways of accomplishing this, but i'm learning and therefore only interested in why the above code doesn't work.
I am trying to create a singleton class, that extends Sprite. It seems to work correctly, but it doesn't actually update the screen.If I access my instance and change the properties (x,y,alpha,etc) they will all update, but the display doesn't change.eg:My clip starts at x=0.MyClass.getInstance().x = 99;trace(MyClass.getInstance.x); //traces 99, but it still appears at 0 on the screen.
I would like to send and receive OpenSoundControl in an AIR application, on the opensoundcontrol.org website I have found existing libraries for many languages, but none for Action Script so far, do you know of one that could be readily used?
I have an app that has a fullscreen button that goes into fullscreen NO_SCALE. Keeps everything looking sharp. However, all of my movieclip positions aren't correct. To fix this, I need to use:
Then, in my stageResize function, I duplicate all my movieclips' x and y and (if necessary) widths. This seems wrong and cumbersome.
Here's an example of what I'm talking about. Full Screen - Doesn't Work Clicking on fullscreen brings you to fullscreen but the mc positions stay put. Here's the code for this one:
Code: var btn_fullScreen:btnFullScreen = new btnFullScreen(); var btn_normalScreen:btnNormalScreen = new btnNormalScreen(); var bar_bg:barbg = new barbg();
Everything dealing with sharedObjects in the first frame is this:
[AS] var PlannerData:SharedObject = SharedObject.getLocal("PlannerData"); SubjectChoices = PlannerData.data.subjectChoices; if (SubjectChoices == undefined) {[code]....
Going to the second frame from the first frame, the data is perfect. Going back to the first frame from the second, I'll trace the data many times throughout the code without an onEnterFrame, and it'll tell me that the Array is good...But when I trace the onEnterFrame, it shows the Array is [undefined, undefined, ...] like..undefined 17 times.
I am currently working on an AS3 where I need to fit many differently sized display objects within a rectangular boundary without them overlapping. If you take a look at this link, [URL]and take note of how the speech bubbles are able to align themselves in the swf without overlapping, this is pretty much exactly what I hope to achieve.
I'm developing a touchscreen application in AS3, and I havesome problems because the applications reaches 1,5 Gigabyte ofmemory if it's keep running for an hour.this memory size is because I show some videos in streaming,one after another (not in the same), and then they are not garbagecollected: I set the references to the videos to null and I removethe listeners, but flash seems to keep them in memory. I tried todelete the code section about the videos, and I have no problemswith memory (I also load some external images with the videos), soI'm pretty sure they're guilty in some way...I read that there's a bug in flash so displayobjects are notgarbage collected even if you remove the pointers to them: is it
I have two classes ( shown below after problem description), the InteractiveStrategy and Filters classes. The class InteractiveStrategy is the main class definition. In there I declare and instantiate two variables, updateData and filters. I also display the lists mqList and sqList. In the Filters class I have two methods, MainQuestions() and SubQuestions(mq:int). The method MainQuestions() populates a list mqList with the main-questions and SubQuestion populates list sqList with the sub-questions. This means each main-question has a set of sub-questions associated with it.
Thus whenever the main-question (via mqList) changes, the set of sub-questions must change also. My attempt at accomplishing the above is shown in the skeleton code below.The MainQuestions() method dispatches an event called 'mqChanged' while the filter.MainQuestions() listens for the event. However I have no idea of how to execute filter.SubQuestions(mainQuestion) with the newly selected mainQuestion so as to display the new set of sub-questions.
public class InteractiveStrategy{ public var updateData:UpdateData; public var filter:ArrayFilter; public var mainQuestion:int=0; public function InteractiveStrategy(){ [Code] .....
I have a stage with instances of bauble_mcs on it that are attached by the document class of the main timeline (can someone tell me what the right term is here? I don't know what I call the main time line in AS3).
I then have instances of snow_mc attached by the same class. Inside the snow_mc I want to test to see if it is hitting any bauble_mcs but I don't know how!
I am aligning my display objects in the middle. stage.stageWidth/2. for some reason, they are aligning further off to the right of the screen. I haven't altered anything but the stage width in flash. Has anyone heard of this problem? Again, I haven't done anything except widen the screen and adjust the height.
My focus point on the display object is top left. So it aligns perfectly when set to 0,0 stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; stage.stageWidth = 300;