ActionScript 3.0 :: Connector Object Would Take Two Display Objects As Parameters?
Jul 12, 2007
I'm wanting to write a Connector class for my first jump into AS3.A Connector object would take two display objects as parameters, and it would draw a connecting line between them.Whenever either object moved, the Connector would keep track of that and update the connecting line appropriatly.
var connector:Connector = new Connector(sprite1, sprite2);
Will Connector be able to register itself as a listener for when sprite1 and sprite2 move or does that have to be done outside of the Connector class?
private function onCntrMouseDown(event:MouseEvent):void{ trace("Target: "+event.currentTarget.name); //trace(event.target.name);
[Code].....
Does anyone know how to get the circle array name through the onCntrMouseDown function trace part cause as what i put for the coding as event.currentTarget.name, it gives me the object instance name which is not the array circle name that I wanted...
and I also facing the connector problem..I wish the point of the object can be link with the point of the line...but it doesn't work..
If I create a rectangle with 100px width and 100px height and then rotate it, the size of the element's "box" will have increased.With 45 rotation, the size becomes about 143x143 (from 100x100).Doing sometimes like cos(angleRad) * currentWidth seems to work for 45 rotation, but for other bigger angles it doesn't.At the moment I am doing this:
var currentRotation = object.rotation; object.rotation = 0; var normalizedWidth = object.width;
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 was wondering about which is the best method to use when passing variables to a class. So if I were making a complex class which required many variables to be passed/set to function [code]...
To date have used method #1, but I guess I lean toward method #2 although my inexpierience has me majorly doubting that and was wondering if anyone else had any views on this?
After dragging many MovieClips/Components onto the stage, how can I generate a report (or display on screen)by listing the names,parameters, values of all the movie clips/ components dragged on the stages?
I have a URLVariables object (variables) that I'm setting its properties this way. [code]But the properties differ so I want to just pass an object in the following format and have it set the property names and values correctly.{fname: "fname", lname: "lname", address: "address"}I tried a forloop like this, but it's not working. Not sure exactly how I achieve the same thing as setting the properties manually.[code]
I have an Object that has several parameters. In this case they are Arrays. For example: myObject.Name, myObject.Description (myObject.Name is an Array that contains a bunch of names)How do you detect all the parameters that are attached to the object without having to use the debugger for each instance?
I have the Class and the parameters of its contructor as an object. What I need to do is a function that returns an instance of this class, passing this parameters to the constructor.
This is the code: Some random and unmodifiable class:
public Foo { public function Foo(a:int, b:String) { // constructor } }
And some function (in some another class):
function bar(params:Object):* { var baz:Foo = new Foo(params.a, params.b); return baz; }
What I need to do is make this function generic, without pass params as parameter to Foo constructor because I can't modify it. Something like:
function bar2(clazz:Class, params:Object):* { var baz:* = new clazz(/*some magic way to transform params in comma separated parameters*/); return baz; }
I am working on a side-scrolling platformer game. Because of this, I have a class that acts as a floor. I also have a class representing enemies. I am having problems with passing a parameter to a custom class' constructor. The class (SkullDemon.as) extends MovieClip. I am trying to pass an instance (called "floorL1") of a customer class called "FloorLevel1." "FloorLevel1" also extends MovieClip (I do not have a written .as file for "FloorLevel1"; I just exported the floor MovieClip to that class).
I am trying to pass an instance of "FloorLevel1" so that the "SkullDemon" object can land on the floor just like in a platformer. My main class is called "TME2_Main." This is the class from which I try to pass the "floorL1" instance to the "SkullDemon" class. This is how I try to create a Skull Demon instance and pass "floorL1" to its constructor:
[Code]...
What am I doing wrong here? I have spent a while looking for solutions (including moving code outside of TME2_Main's constructor),
Flash gives access to query-string parameters via calling loaderInfo.parameters() method.And I couldn't delete the field on the object. IS it possible to delete some fields in the object? how can I do this?
I'm trying to set 2 object each with different data, and pass it into another function as parameters, but when I trace for the data in the object, I can only get the 2nd object data. Seems like the 1st object was replaced by the 2nd object.
I want to serialize ThugtrisShapes' children (heritage/polymorphism) but his children like Right_LShape take constructor parameters,i have to assign it a default value (in my case null because they receive an Array type), but i get this error even when implementing IExternalizable.
Take Note: IForm extends IExternalizable.
here is a link i found about it but it still does not work...[URL]
Code: public class ThugtrisShapes extends Sprite implements IForm { var squares_:Array; var numsquares_:int=MAX_SQUARES;
[Code]....
I know that not all class' can be cloned , but cloning is an important aspect of OO programming.... There should be a solution for my problem,besides taking the parameter out of the constructor and add a setter.
Is there a way out there to essentially loop through a generic object to find out what parameters/properties are being used and/or what there names are?
ActionScript Code: var obj:Object = new Object(); obj.foo = "hello"; obj.bar = "world"; //... and on for however many params you need [Code] .....
I might be trying to do something that is essentially not possible, but I'm just thinking it would be very nice sometimes to access different parts of an object without having to directly know what the param name is...
Can you make one Bitmap Object (I'm using an external jpg) or something similar, and then display it many times simultaneously without creating a separate object each time?
Also, would they be easily removed or hidden?
I've got a little checkmark jpg graphic loaded here, but I'm not sure how to go about using it in many places at once.. I can only display it in the one place at any one time...
I'm thinking there might be a way to load the picture once, then use its bitmapData elsewhere in new display objects somehow, without needing to reload the image over and over?
It's my understanding that a display object cannot be in the display list more that once.So if I add something to the stage shouldn't a second addition of the same object replace the first? for instance:
[code]...
there should now only be one "myDisplayObject" on the stage.
I know this should be very simple, but in following the examples I can find on passing parameters from HTML to my Flash App I have not been successful. I would like to find a relatively current example using AS3, Flash CS4. I need to pass the url of an XML file off to the flash app so that it can go pick up instructions on what it is supposed to be playing. We want to do it this way because we don't control the web site so we can't just leave the XML file on the server and maintain it as needed.
I am trying to store my Application.application.parameters to my local variables For example: var myVar:Object = Application.application.parameters; So here is the tricky part, is I do ObjectUtil.toString(myVar) I can see all the values and properties. However if I do myVar.clientName or any other properties I always get null or undefined.
What I'm trying to do is create a simple message class that I can pass a set of textfield parameters of my choosing rather than specifying each textfield parameter in the constructor.Is it possible to pass a textfield instance an object of parameters instead of setting each one individually?
Code: public class Example { private var message:String; private var messageTextField:TextField;
Currently I am designing a project and it has twoscenes.First scene contains a button and it will take you to thenext scene, where I have an XML connector and a combobox, boundedtogether
So I must say I like the direction that Adobe is taking AIR, giving the ability for web developer to create applications for the desktop / mobile devices is wonderful. One things when I was learning php that was helpful (and something that has been a selling point for Dreamweaver) was the ability to point to a Database and Dreamweaver would generate the code for the connection. With Flash being ported to Droid and Adobe clearly making a push to Flash to move beyond the web why has this same functionality not been ported to Flash? In Dreamweaver you can point to a data source, select segments of data you want to access, sort, use a text field to filter data, etc..I must admit that my Flash skills are rusty but when I look at the steps it takes to get exteranal data into Flash, well what a mess.