All Objects On Stage Of Particular Class
Is there way to get an array or other collection of all the objects on the stage of a particular class? Or, at least to loop through all the objects on the stage so I can test them for their class?
Example: I have defined a class called "attractor" which extends MovieClip. Objects of this class have effects on objects with the class "attracted", which has an array property to hold references to all the "attractor" objects currently effecting it. I want to define a function that will find any "attractor" objects on the stage add them to the "attracted" object's array.
Thanks for any help you can offer.
ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 09-19-2006, 06:37 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
All Objects On Stage Of Particular Class
Is there way to get an array or other collection of all the objects on the stage of a particular class? Or, at least to loop through all the objects on the stage so I can test them for their class?
Example: I have defined a class called "attractor" which extends MovieClip. Objects of this class have effects on objects with the class "attracted", which has an array property to hold references to all the "attractor" objects currently effecting it. I want to define a function that will find any "attractor" objects on the stage add them to the "attracted" object's array.
Thanks for any help you can offer.
Document Class And Objects On Stage Problem
I am using a document class on my project right now, and it works fine. I get an error when I give instance names to my MovieClips i have on the stage.. and the error is found on the doc class, on line 1, a comment.
and also, I am going to load an swf into this project, but when I try to load it, i get this error
Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at xxx_fla::MainTimeline/spontaneousBox_fla::frame1()
the code in that one is on the timeline..
Create Array On Stage, Mathematically Referring To Objects On The Stage
Ok what I want to do is create a set of small images on the stage and name them sequentially like you would an array, then refer to them mathematically in actionscript. I tried naming them as an array but it says that the name is reserved for the system or something. Does anyone know how to get an array of objects onto the stage, or have an idea of something else I could do to get the same effect?
Create Array On Stage, Mathematically Referring To Objects On The Stage
Ok what I want to do is create a set of small images on the stage and name them sequentially like you would an array, then refer to them mathematically in actionscript. I tried naming them as an array but it says that the name is reserved for the system or something. Does anyone know how to get an array of objects onto the stage, or have an idea of something else I could do to get the same effect?
Store And Retrieve Array Of Custom Class Objects From Shared Objects.
Hi,
I am stuck up with a problem in ActionScript 2. I am using Flash MX 2004 on windows XP.
I have created 3 custom classes say Parent, Child, and GrandChild. Parent class contains in it an array of its Child objects. Similarly each Child object contains in it an array of GrandChild objects. Also I do have one global array of all the Parent objects.
I want to store this array to the shared objects on specific events(say exiting the session) and then reload them from the shared object(on next session startup). I am able to store the global array to the shared object but when I try to retrieve the same array from shared object, I could not do it. The retrieved array is not of my custom class type [Parent].
Help needed to solve this problem urgently. Does anybody have idea how to do it??
Thanks in advance.
Cheers,
Naishadh Sevalia
Help: Stage Objects Get In Front Of Script Objects?
This is getting me mad...
addChild(my_script_object);
I can't see it...
If I try trace(numChildren) I get 10, so then I try addChildAt(my_script_object,9) and still cant' see it.
If I delete all the objects in stage then I finally see it.... If I delete one by one I find my_script_objects gets beneath a bitmap placed by hand by the designer.
Any ideas?
TIA
Class Question: How To Access Timeline Objects From Class W/o Arguments
Hey all,
I am looking into builiding an application with OO functionality. I understand most of it. Except I cannot figure out how to access something in my app from a class. For instance, lets say I have one Loader class that loads some data and stores it in a variable inside the class (or on the main timeline, doesn't matter). Now, I know I can pass a reference to the data in an argument to another class for that class to manipulate. But if I have several data sources, and other variables and such, that I need to modify in a single class function, how would I do that without having to give the function access to them through arguments? I just want to be able to say, from a class, something like _root.someObject.someFunction();
So, any help would be greatly appreciated, and sorry if that made no sense at all, I tried to explain as best I could.
Happy Holidays!
Dave
Document Class Initialising Another Class With Display Objects
Hi
I'm currently learning AS3 and have got stuck with something fundamental to do with Flash and the Document Class.
I have a very simple Document Class as follows:
package {
import flash.display.*;
import com.Application;
public class EntryPoint extends Sprite {
public function EntryPoint() {
var app:Application = new Application();}}
}
I then would like to build out into other classes/patterns and want the following code to simply attach an item from the library on to the stage.
The item in the library has a Class reference of CircleTest and has a Base Class of flash.display.Sprite.
My Application class is as follows:
package com {
import flash.display.*;
public class Application extends Sprite{
public function Application() {
var mc_root:Sprite = new Sprite();
addChild(mc_root);
var circleTest:CircleTest = new CircleTest();
mc_root.addChild(circleTest);}}
}
When I compile this from Flash I get nothing other than an empty stage :-(
Please can someone tell me what I'm doing wrong here.
Many thanks in advance
D
Bouncing Ball Class Off Other Class Objects
Hello again people. Im getting far now with this AS3 learning and classes in general. Now im wondering how I will get my ball which is in a class and is called to the stage to bounce off my bats which are in other classes and are called to the stage. Heres my code all help would be great thanks in advance
Heres my Main.as class file which calls the classes onto the stage and moves m bats
Code:
package classes{
import flash.display.Sprite;
import flash.display.Stage;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import classes.nets.Nets;
import classes.bats.Leftbat;
import classes.bats.Rightbat;
import classes.ball.Ball;
public class Main extends Sprite{
// Variables
public var nets:Sprite;
public var myleftbat:Sprite;
public var myrightbat:Sprite;
public var myball:Sprite;
public function Main(){
nets = new Nets();
myleftbat = new Leftbat();
myrightbat = new Rightbat();
myball = new Ball();
//
addChild(nets);
addChild(myleftbat);
addChild(myrightbat);
addChild(myball);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressedDown);
}
private function keyPressedDown(event:KeyboardEvent):void {
var key:uint = event.keyCode;
var step:uint = 5
switch (key) {
case Keyboard.UP :
myleftbat.y -= step;
if (myleftbat.y <-250) {
myleftbat.y =-250;
}
break;
case Keyboard.DOWN :
myleftbat.y += step;
if (myleftbat.y > 249) {
myleftbat.y = 249;
}
break;
case Keyboard.NUMPAD_8:
myrightbat.y -= step;
if (myrightbat.y <-250) {
myrightbat.y =-250;
}
break;
case Keyboard.NUMPAD_2:
myrightbat.y += step;
if (myrightbat.y > 249) {
myrightbat.y = 249;
}
break;
}
}
}
}
And here are my bat classes, these just draw the bats
The left bat
Code:
package classes.bats{
import flash.display.Sprite;
import flash.display.DisplayObject;
import flash.events.*;
public class Leftbat extends Sprite {
public function Leftbat():void {
graphics.lineStyle(1);
graphics.beginFill(0x2f9b4b);
graphics.drawRect(0,250,25,100);
graphics.endFill();
}
}
}
The right bat
Code:
package classes.bats{
import flash.display.Sprite;
public class Rightbat extends Sprite{
public function Rightbat(){
graphics.lineStyle(1);
graphics.beginFill(0x2a00ff);
graphics.drawRect(774,250,25,100);
graphics.endFill();
}
}
}
And Finally my ball class, this creates the ball and makes it move around the stage
Code:
package classes.ball{
import flash.display.Sprite;
import flash.utils.Timer;
import flash.events.TimerEvent;
public class Ball extends Sprite
{
private var myBall:BallClip;
public function Ball( )
{
myBall = new BallClip( );
addChild( myBall );
var moveTimer:Timer = new Timer( 25 );
moveTimer.addEventListener( TimerEvent.TIMER , myBall.step );
moveTimer.start( );
}
}
}
import flash.display.Sprite;
import flash.events.TimerEvent;
class BallClip extends Sprite
{
private var xspeed:Number;
private var yspeed:Number;
public function BallClip ( )
{
graphics.lineStyle(1);
graphics.beginFill( 0xffffff , 1 );
graphics.drawCircle( 20 , 20 , 15 );
graphics.endFill( );
x = 400;
y = 300;
xspeed = Math.random( )*5;
yspeed = Math.random( )*3;
}
public function step ( timeEvent:TimerEvent ):void
{
if ( x + xspeed > 850 ) xspeed *= -1;
if ( x + xspeed < -50 ) xspeed *= -1;
if ( y + yspeed > 570 ) yspeed *= -1;
if ( y + yspeed < 0 ) yspeed *= -1;
x += xspeed;
y += yspeed;
}
}
Now I know it will involve checking the balls x posistion and then bouncing it back if it meets the bats x posistion, but how do I do this? Can I check classes within classes?
Bouncing Ball Class Off Other Class Objects
Hello again people. Im getting far now with this AS3 learning and classes in general. Now im wondering how I will get my ball which is in a class and is called to the stage to bounce off my bats which are in other classes and are called to the stage. Heres my code all help would be great thanks in advance
Heres my Main.as class file which calls the classes onto the stage and moves m bats
Code:
package classes{
import flash.display.Sprite;
import flash.display.Stage;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import classes.nets.Nets;
import classes.bats.Leftbat;
import classes.bats.Rightbat;
import classes.ball.Ball;
public class Main extends Sprite{
// Variables
public var nets:Sprite;
public var myleftbat:Sprite;
public var myrightbat:Sprite;
public var myball:Sprite;
public function Main(){
nets = new Nets();
myleftbat = new Leftbat();
myrightbat = new Rightbat();
myball = new Ball();
//
addChild(nets);
addChild(myleftbat);
addChild(myrightbat);
addChild(myball);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressedDown);
}
private function keyPressedDown(event:KeyboardEvent):void {
var key:uint = event.keyCode;
var step:uint = 5
switch (key) {
case Keyboard.UP :
myleftbat.y -= step;
if (myleftbat.y <-250) {
myleftbat.y =-250;
}
break;
case Keyboard.DOWN :
myleftbat.y += step;
if (myleftbat.y > 249) {
myleftbat.y = 249;
}
break;
case Keyboard.NUMPAD_8:
myrightbat.y -= step;
if (myrightbat.y <-250) {
myrightbat.y =-250;
}
break;
case Keyboard.NUMPAD_2:
myrightbat.y += step;
if (myrightbat.y > 249) {
myrightbat.y = 249;
}
break;
}
}
}
}
And here are my bat classes, these just draw the bats
The left bat
Code:
package classes.bats{
import flash.display.Sprite;
import flash.display.DisplayObject;
import flash.events.*;
public class Leftbat extends Sprite {
public function Leftbat():void {
graphics.lineStyle(1);
graphics.beginFill(0x2f9b4b);
graphics.drawRect(0,250,25,100);
graphics.endFill();
}
}
}
The right bat
Code:
package classes.bats{
import flash.display.Sprite;
public class Rightbat extends Sprite{
public function Rightbat(){
graphics.lineStyle(1);
graphics.beginFill(0x2a00ff);
graphics.drawRect(774,250,25,100);
graphics.endFill();
}
}
}
And Finally my ball class, this creates the ball and makes it move around the stage
Code:
package classes.ball{
import flash.display.Sprite;
import flash.utils.Timer;
import flash.events.TimerEvent;
public class Ball extends Sprite
{
private var myBall:BallClip;
public function Ball( )
{
myBall = new BallClip( );
addChild( myBall );
var moveTimer:Timer = new Timer( 25 );
moveTimer.addEventListener( TimerEvent.TIMER , myBall.step );
moveTimer.start( );
}
}
}
import flash.display.Sprite;
import flash.events.TimerEvent;
class BallClip extends Sprite
{
private var xspeed:Number;
private var yspeed:Number;
public function BallClip ( )
{
graphics.lineStyle(1);
graphics.beginFill( 0xffffff , 1 );
graphics.drawCircle( 20 , 20 , 15 );
graphics.endFill( );
x = 400;
y = 300;
xspeed = Math.random( )*5;
yspeed = Math.random( )*3;
}
public function step ( timeEvent:TimerEvent ):void
{
if ( x + xspeed > 850 ) xspeed *= -1;
if ( x + xspeed < -50 ) xspeed *= -1;
if ( y + yspeed > 570 ) yspeed *= -1;
if ( y + yspeed < 0 ) yspeed *= -1;
x += xspeed;
y += yspeed;
}
}
Now I know it will involve checking the balls x posistion and then bouncing it back if it meets the bats x posistion, but how do I do this? Can I check classes within classes?
Problem With Class Objects Within Objects
Hi There,
I am having trouble creating an oop grid.
My initial object is "world" shown below which will contain an array of "Row" objects, which in turn contains an array of tile objects.
As i build up the rows and assign the tiles everything seems fine but when i try to retrieve the values the tiles in each row returns the same values from each tile..
class world{
//declare class members
private var goalScore
private var mapPreview
private var title
private var editor
private var createdBy
private var movieBorder
private var instructions
private var rows = new Array()
//Constructor
public function world(Param_goalScore, Param_mapPreview, Param_title, Param_editor, Param_createdBy, Param_movieBorder, Param_instructions){
this.goalScore = Param_goalScore
this.mapPreview = Param_mapPreview
this.title = Param_title
this.editor= Param_editor
this.createdBy= Param_createdBy
this.movieBorder= Param_movieBorder
this.instructions= Param_instructions
}
//Methods
public function createRow(){
if (rows==null){
this.rows[0] = new row()
}else{
this.rows[rows.length] = new row()
}
return this.rows[rows.length-1]
}
}
class row{
//declare class members
public var tiles = new Array()
//Constructor
public function row(){
}
//Methods
function createTile(Param_tileType, Param_completionScore, Param_objectType){
if (tiles==null){
trace("created first tile")
this.tiles[0] = new tile(Param_tileType, Param_completionScore, Param_objectType)
}else{
trace("created tile " + tiles.length +" tiles="+tiles)
this.tiles[this.tiles.length] = new tile(Param_tileType, Param_completionScore, Param_objectType)
}
return this.tiles[this.tiles.length-1]
}
}
class tile{
// declare class members
public var tileType;
public var completionScore;
public var objectType;
public var character;
// Constructor
public function tile(Param_tileType, Param_completionScore, Param_objectType){
tileType = Param_tileType;
completionScore = Param_completionScore;
objectType = Param_objectType;
//movementPreset = Param_movementPreset
//error = Param_error
//errorImage = Param_errorImage
}
// Methods
}
Any advice will be greatly received.
Jason
Can I Get The MouseX From One Class's Stage From Inside A Different Class?
I'm working on a first time game using Flash CS3 ActionsScript 3.0 that has a crow class placed on the stage of a main gameStage class. I need to access the mouseX coordinate from the stage of the gameStage class from inside my crow class. I'm attempting to do it via a getter function but seem to be having trouble tracking down the exact proper syntax to avoid errors. Is there any chance I could get an exact syntax example as apposed to hours of online research and study.................8-)
AS3: XObject Class - Treat Objects Like XML (E4X4O - "E4X For Objects")
I just finished this a few minutes ago (coincidentally while at a SilverLight camp ). Its an AS3 Object that allows you to add "elements" in the form of objects much like you would with XML using E4X. By assigning values to an XObject, you are adding that value into its "node" structure as one of its children with the given name. Retrieving a property, instead of returning a value, returns an instance of XObjectList which is essentially a list of objects (like XMLList) that are defined to that property. As with XML, there is a separation of elements and attributes using the @ character to precede references. Without @ you access a child, with, you are accessing a property or attribute of that particular XObject or whatever object defined inside it. Setting an attribute of an XObjectList, assigns the value to that property of all the objects in the list.
Its a little hard to explain. Its better to just see some examples.
ActionScript Code:
var rootNode:XObject = new XObject();rootNode.one = new Object();rootNode.two = new Array();rootNode.two = 20;rootNode.two[1].deep = "Hello XObject";rootNode.@three = "attribute";trace(rootNode);/* output:<XObject three="attribute"> <Object:one /> <Array:two /> <int:two> 20 <String:deep> Hello XObject </String:deep> </int:two></XObject>*/
ActionScript Code:
var rootNode:XObject = new XObject();rootNode.a = 1;rootNode.a = 2;rootNode.a = 3;delete rootNode.a[1];trace(rootNode);/* output:<XObject> <int:a> 1 </int:a> <int:a> 3 </int:a></XObject>*/
ActionScript Code:
var myMcs:XObject = new XObject();myMcs.badGuys = enemy1_mc; // movie clips on the screen...myMcs.badGuys = enemy2_mc;myMcs.badGuys = enemy3_mc;myMcs.badGuys.@x = 100; // all enemy mc's move to x = 100
It's pretty much done, but there might still be some problems, so if anyone finds any, just say so. I'm not sure how many more methods I might want to add in addition to what's there now (to match XML) though I think I want to keep it as simple as possible, so probably not much more, if any, than what's already there. To see what's there now, you'd just have to check out the classes - its not much.
Moving The Stage After Resizing - Or Moving All Objects On The Stage? Heeeelp
Hello! I'm in dire need of help!
I've been forced to resize the stage of my movie but as the stage is expanded to the right and down everything ends up in the wrong place. So I wonder:
Is there any way to move the stage rather than the contents thereon?
or
is there a way to move all the content on all layers and even all scenes simultaneously?
or
is there a way to expand the stage equeally on all sides rather than just right and down?
THANKS ALOT TO WHOEVER COULD HELP ME!
Freddy D, Stockholm, Sweden
Objects Off Stage
I am loading a small movie inside a larger movie. The smaller movie has object off the stage that move across. When I play the small movie by itself shows just the movie stage. But when I load this into the larger movie stage I see all the off stage objects on the smaller movie.
What am I doing wrong?
I Can See Objects Outside The Stage :(
hello,
im testing my flash site and everything looks
pretty good BUT when i resize the window to see what happens....anything thats in the flash file shows up even though it isnt on the stage.
how can i limit the window so it doesnt resize.
i didnt design the site to look good if someone resizes the window. i have very custom edges and if you resize the window the design falls apart.
did i screw up or do flash designers have a work around for this.
also, is it a BAD idea to design this way (framing the edge) because of peoples tendancies to want to resize their browser windows?
Off Stage Objects
I was under the belief that objects off (to the side of the stage) were not visible. When I "test movie" though they are clearly visible. Am I doing something wrong, possibly they need to be masked?
Thanks
Stuart
Objects Off Of Stage
i have a flash movie i made.... when i load it into an empty movie clip in a new flash document, it plays but shows all the items that were off of the stage and on the area around it - when these items are only supposed to be seen moving onto the stage. does this make sense? how do i make it not show any area off of the stage?
thanks a ton in advance
cosmo
MVC And Objects Already On The Stage
So I'm finally really digging into design patterns with AS3 and I'm finally getting the hang of it. I'm currently floating through Adobe's "Advanced ActionScript 3.0 with Design Patterns" by Lott and Patterson.
For the MVC pattern, where exactly does an object fit in that has already been placed on the stage?
The problem comes up because an object on the stage at compile time is immediately instantiated without any real control as to "how" it is instantiated (afaik). The above book's clock example shows adding objects dynamically through an Abstract view, but that view requires arguments, and I don't see how you can pass those arguments at compile time.
Just a bit confused how to combine this together. Check out the clock example here:
http://rightactionscript.com/aas3wdp/
Does MX Allow Objects Outside Stage?
may b its just me but, i remember placing instances outside the stage area and MX doesnt allow it 4 some reason or i'm totally missin somethin??
hog!!~~
Objects Outside Of The Stage
Hello,
As all of us know the objects that are placed outside of the stage are not visible. But is it possible to access and alter these objects. I'm asking that, because of security reasons. I don't want that the user access these objects even if they are not visible. So is it safe to place them just outside the stage.
Any suggestions will be helpful. Thank You.
Moving Objects On The Stage Help
Hello,
What I am trying to do is;
Assume there are 5 playing cards on the stage spread out evenly across the stage, and what I want to do is, when you move the mouse of each card (should I make them a button or movie instance?), the card will move to center of stage and go from about 20% of its size to 100% by the time it is in center screen. But this will have text on it, so at 20% you can't read it until it gets to center and is at 100%. Is this actionscript? I am not familiar with that other than gotoAndStop and so forth.
Ok, yes I am new to Flash MX, but I am learning more everyday from all of you, so can anyone please help me?
Thank you
Thorrax
Stage Aware Objects
Hi People,
Is there a script or extension that causes a mov to alighn it self to the edges of the screen no matter what the size of the browser is.
Check out this example:
http://www.bentleymotors.co.uk/bentl...ctlanguage.jsp
This flash site shows a logo in the upper right that moves it's placement according to the Monitor.
If you test it by using different size monitor sizes you will notice that
the logo always stays on the right but the rest of the movie stays the same.
You see that by the links at the top do not move.
So my question is again how is it possible to or what script would I use to tell an object, be it graphic or movie, to be aware of the size of the stage and align to the right .
This is a very cool trick.
What's really cool is the html page seems set at a percentage but the top of movie file grows or expands instead of just enlarging.
This is crazy.
Any help on this would be appreciated.
Thanks,
Joseph
How Do I Prevent Objects From Being Seen Outside The Stage?
When I watch my animations I don't want the objects to be seeable when outside the white box stage. I know you can use masks but is there a real way to do this? If there isn't then I don't get the point of the designated stage area....
Thanks in advance.
Objects Off Stage Showing
I thought it didnt happen, but long objects off stage show up in my .exe and .swf files, and they print as well.
I thought things off stage were not supposed to show. is there a setting or way to block out the off stage images until they scrolling onto the stage? (other than covering with background matching color)
Thanks
Steve
Objects Showing Off Stage
I thought it didnt happen, but long objects off stage show up in my .exe and .swf files, and they print as well.
I thought things off stage were not supposed to show. is there a setting or way to block out the off stage images until they scrolling onto the stage? (other than covering with background matching color)
Thanks
Steve
Objects Showing Off Stage
I thought it didnt happen, but long objects off stage show up in my .exe and .swf files, and they print as well.
I thought things off stage were not supposed to show. is there a setting or way to block out the off stage images until they scrolling onto the stage? (other than covering with background matching color)
Thanks
Steve
[F8] Stage Objects Not Right In Flash8
Hi,
A Summary.
The Object Instances from Flash 8 are not the same as those which come with the Flash MX 2004 D.R.I.A. coursework, which I'm currently going through.
The parameter names are different and I'm somewhat confused as to why.
eg
Flash MX2004 Group Name
Flash 8 Pro groupname.
etc.
I have Input Text boxes, checkboxes not behaving properly with Actionscript and now radio boxes where if I set an inital value it ignores other items in the same group and cannot switch off.
Any ideas what I can do or an explkantion as to why this is wrong in Flash 8? I desperately want to learn Flash properly but it seems the course I paid for and attentded a few year ago could well be defunct.
Outline
I did the Flash D.R.A.I. course a few years ago (flash MX) but didnt get a chance to practice or use any of it. I have recently decided to work through it again and have run into problems while manipulating push buttons and checkboxes.
I have created object instances, two of which need to be cleared when the user selects a push button with a clear function attacted to it.
I have named them correctly and I have typed in the correct actionscript commands. I have even checked the actionscript against the solution files and everything is exact. Yet the flash movie doesn't behave correctly. (eg the 'clear' button isnt working)
I then noticed that the object instances on my stage seemed different to the ones from the solution files.
They had the correct name etc.., but the checkbox from the solution file seems to be a symbol movie clip(???!!??) yet mine wasn't. and the Order_ID Input text had loads of superfluous parameters selected in the property inspector, which I did not set and do not seem to be able to change.
So obviously it was the objects on my stage which are wrong and to check this I copyied and pasted the instances objects from the solutions file stage onto my stage and hey presto they work.
My question is. Why is this happening. Why is the check box a movie clip symbol, which you arent supposed to be able to set parameters for anyway.? Bascially, help!!!
Here's my code, which works
/***********************************************
included ActionScript files
***********************************************/
/***********************************************
object constructors and object creation
***********************************************/
/***********************************************
functions and object methods
***********************************************/
orderID_txt.onChanged=function()
{
message_txt.text="You Entered "+orderID_txt.text;
}
clear_pb.clear=function()
{
orderID_txt.text="";
back_ch.setValue(false);
message_txt.text="";
}
/***********************************************
run at once commands
***********************************************/
message_txt.autoSize=true;
message_txt.textColor=0x630000;
message_txt.text="new message";
clear_pb.setLabel("Clear");
clear_pb.setClickHandler("clear",clear_pb);
Spacing Objects Out On The Stage...?
Hi guys
i'm trying to find a tutorial for spacing objects out on a stage...
Say for example I have 20 spheres on the stage different sizes I want to create a script (OOP probably) that will ensure that the spheres don't overlap etc.
Does anyone know of any tutorials or can suggest a way for me to go about writing such a script?
Many thanks.
Stacking Many Objects In The Stage
Im trying to make a slide show of many pics (sliding from right to left) but there is a problem. They wont fit in a straight line when stacking them in the stage. There is just not enough room to stack them all in, and then make the sliding! What can i do?
I have attached the sample but i haven't put it all to be working properly, i have just added the extra samples i wanted, so you can get an idea when the fitting is beginning to become a problem!
AS3 Find Objects On A Stage
How can I access instances of an object that i added on a stage. I create buttons with the use of class and add them on the stage giving them some label name that are read from an XML. All works well and the buttons are displayed on the stage but i want to know if there is a way to access them from within the stage.
Moving Objects On Stage
I recently was asked to make sort of a slideshow, not a problem.
My question is, since there were 100 objects at once to be moved at the same time in the same direction, is there a simpiler way to make everything move at once instead of making them all move one at a time?
How Do You Move Objects Across Stage?
Hi i can't seem to move the picture to the stage..I loaded the picture in but when i press play all it does is show the picture...i want the picture to load to the x and y cordinates of 0,0 (center of stage) and it doesn't matter where the starting point is...can somebody please help? Here's the code so far...please tell me what i should do to fix the problem
var startX:Number = myImageHolder._x
var startY:Number = myImageHolder._y
var endX:Number = 0;
var endY:Number = 0;
myImageHolder.onEnterFrame = function () {
if (this._y > endY && myImageHolder._x > endX)
{
myImageHolder._y += ((endY - startY)/100);
myImageHolder._x += ((endX - startX)/100);
trace("x/y start:"+myImageHolder._x+"/"+myImageHolder._y);
trace("x/y end:"+endX+"/"+endY);
}
}
// create the XML variable
var xml:XML = new XML();
xml.ignoreWhite = true; // you must ignore whitespace
xml.onLoad = function() { // the function that is called when the xml is loaded
var nodes = this.firstChild.childNodes; // tells you the number of child nodes
numOfItems = nodes.length; // tells you how many items you have
for (var i = 0; i<numOfItems; i++) { // attach icons
myImageHolder.loadMovie(nodes[i].attributes.image);// attach image to the myImageHolder MovieClip
nextimage();
myText.text = nodes[i].attributes.caption; // set the text
}
}
xml.load("xml/images.xml");// load the xml
Manipulating Stage Objects
Hi all,
I'm working on a movie that at some point in the timeline has a dynamic text field. I want to populate this field in the background depending on what I get passed into the movie. The name of the field is "PhoneNumber". In AS I try to do this, but it's not working:
PhoneNumber.text = "000-000-0000"
I keep getting this error:
1120: Access of undefined property PhoneNumber.
This has been keeping me up for the past 3 hours and I'm starting to hate it. Could someone tell me how to reference objects on the stage and edit them like I'm trying to do with this text field.
Thanks in advance!
Deleting All Objects On Stage
Hi guys,
sometimes AS3 keeps driving me mad. In my application I have a function which indicates the application to restart. As everything in the application is built by classes, I used weak references for the listeners in these classes. So far, so good. Removing everything from the stage works fine as well, BUT also I used the weak references the garbage-collection doesn't kill all of the objects.
Is there any way to definitely kill all the objects that are currently on the stage including all their listeners or pointers?
Thx for any reply
hellslawyer
Loop Through All Objects On Stage?
Is it possible to loop through all of the objects on the stage of a movie?
Say I have a movieclip that I placed 10 TextFields and 2 Combobox Controls on (not dynamically, at design time).
How would I loop through all of the objects?
I have tried the
ActionScript Code:
for (var obj in this)
{
trace(this[obj]);
}
but that does not trace anything, like it isnt getting into the for loop at all.
Finding An Objects Stage
hello,
i'm trying get the stages "Document Class" (_root) of an object in its controller class with the following code:
ActionScript Code:
var targetClass:Class = Object(this.stage).constructor;
but it gives me #1023
what can i do to this?
thanks for any help
Hide Objects Out Of Stage
When using full browser flash and resizing the browser window, the flash scales, but when the browser window gets to narrow e.g., any content/objects/shapes outside the stage are visible as well. Is it possible to use full browser flash, scaling the swf, but hiding the outer stage content somehow?
Mouse Out Of The Stage (even If I Have Objects On It)
How can I detect when the mouse is out of the stage (even if I have objects on it) ?
If I use:
1) stage.mouseOut, it doesn't work because I have buttons on the stage, and it detects when the mouse goes on the buttons (and it is not anymore on the stage)
2) mouse coordinates, it doesn't work because if i move the mouse out of the stage sometimes the last xMouse value, (or yMouse) is > 0.
thanks
Tracing Out Objects On Stage
I want to build an array of all of the dynamicly generated movieclips that are currently on the stage. Is there someway to trace this out?
Most greatful for any advice...
Aligning Objects On The Stage
Does anyone knwo how I can align my MC's to the center of the stage? I've used the Align Panel but when I export my movie all the MC's (menu, borders and background - the lot!) are placed to the left of the window. Any idea why?
Sorry if this is a real noob Qs...
wB
Printing Everything On Stage EXCEPT A Few Objects?
Hey guys,
i just need to know how i would go about printing everything on the stage except for a few things which i define, also all the lines on the stage are dynamic will they print?
(*** edit: I know how to print, but have never actually used it because i dont have a printer, so i cant test ***)
Accessing Objects On Stage
Hello all,
Could someone explain me the concept of objects at the stage? How I would access them.
For example: I've made 3 classes, in one of them I made an container that contains a Circle. In another class I want to access them. So I know the structure of the stage is now as follow:
stage
_ container
____ circle
First I thought about giving the container a name so I could access it with getChildByName(). Only when I try stage.getChildByName() I get the error that I cannot access a property or method of a null object reference.
Thanks in advance
|