Actionscript 3.0 :: Changing The Class Of A DisplayObject?
Sep 21, 2009
So say I've got a MovieClip that's sitting on my stage. If I wanted to apply a custom class to that, what would be the best way?I know I can associate the class with an item in the library, and then drop that onto the stage with code. But is there a way of turning a MovieClip into another class when it's already sitting on the stage?
View 2 Replies
Similar Posts:
Sep 25, 2009
is there a way to change the registration point of a DisplayObject through as3? I am loading an image through XML and the registration point defaults to top left. I need it to be in the center so my rotation tween looks right.
View 7 Replies
Nov 4, 2009
I'm writing a class that really doesn't need to be anything related to a displayObject. It's really more for organizational purposes, than anything else. It's there to handle 1 thing, and 1 thing only. However, I want to have it dispatch an event when it's done so that nothing gets ahead of itself, and I don't end up running functions before the SWF has finished setting itself up.
Simply using the ActionScript Code:
dispatchEvent(new Event("masterFinished",true));
Method isn't working, as the class is. I keep getting the:
PHP Code:
1180: Call to a possibly undefined method dispatchEvent.
However, if I change the class to extend Sprite, and then add it to the Stage as a displayObject, then it works just fine. Is there a way to get the class to dispatch an event without turning it into a displayObject or writing a custom EventDispatcher (I'm assuming the latter would work, but I'm not positive...).
View 4 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
Oct 5, 2009
Okay, actually it extends DisplayObjectContainer, but anyway...I want to be able to use this class in several different applications, even applying it to library items. It also overrides several of DisplayObject's methods, which is very important.Basically, it works (or will work) just fine extending DisplayObjectContainer, but how do I allow other classes that extend DisplayObjectContainer to use the features of my new class. For instance, here is how the class looks now:
Code:
public class DockContainer extends DisplayObjectContainer
{ ... }
[code].....
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
Apr 9, 2011
I tried this:
(DisplayObject(slider)).parent.addEventListener(CustomEvent.CUSTOM_EVENT_TYPE, onCustomEventType);
but flash doesn't like
For whole context see Why Flash doesn't recognize this parent property ? How to get the parent which instantiated an object ?
View 1 Replies
Aug 23, 2009
I have a SendData class that sends form info to a php script. It is a static class that does not extend anything. I want to be able to dispatch an event if there is an error, or when it gets info back from the server. I have a custom event class that I have been using to dispatch events like this, but I have only used that in displayObject extended classes.The problem is, it seems like something has to be a displayObject based class to dispatch events. I know there must be a way to do this, but I'm having trouble finding it in searches.
View 2 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
Oct 23, 2009
My following document class is working fine. But, when I want to import it instead of using as a document class, it reports an error "1067: Implicit coercion of a value of type Class to an unrelated type flash.display:DisplayObject.". My class code is here:
package{ import flash.display.Sprite; import flash.display.Shape; import flash.text.TextField; import flash.events.MouseEvent; public class Shapes extends Sprite { var square: Sprite = new Sprite(); var txt: TextField = new TextField(); public
[code].......
View 2 Replies
Sep 7, 2010
I have two document classes. One is Main.as the other is Step2.as. I want to declare a public variable in Main.as then need to give it a value from Step2.as. That value will later be used in my next Document class Step3.as How would I write the code that gives the value in my Step2.as and then how would I write the code that retrieves the value in my Step3.as?
Note I can't import my Step2/ or Step3 document class into my Main.as.
View 2 Replies
Apr 5, 2012
So for instance, I've got three .as files called 'Helicopter.as, Game.as, Blue.as'
and I also have a .fla file called Helicopter.fla (These files are all suppose to link together, to make the helicopter game) . In the Game.as file, I have the following;
[Code]....
Flash doesn't recognise the original Helicopter symbol (in the Helicopter.fla file, because I deleted it). But I want the system to detect the 'circle' drawn using API (In the Helicopter.as file). And I have no idea how to how to name the API drawn circle 'Helicopter', thus I'm getting an error. So how do I name the API circle to 'Helicopter', so the Game.as file recognises it.
View 1 Replies
Jun 24, 2009
I have a class called Background that has a function that creates a textfield when my movie is first called:
Code:
public function MakePoint() {
var txt:TextField = new TextField();
addChild(txt);
txt.text = "Points: " + StaticValues.puzzlePoints.toString();
}
I want the text to change whenever the user does something. I have a function in another class that controls that. How do I change the text from another class? I've tried with the code below, but it doesn't work:
Code:
Background.txt.text = "Different Text"
View 4 Replies
Oct 14, 2010
i'm playing around with Senocular's brilliant transform tool. Here's the code that I'm having issues with - it targets the instance name, which is great and works perfectly.
ActionScript Code:
_transformTool.targets = [pasteBoard];
_transformTool.activeTarget = pasteBoard;
Here's the issue. When I have an MC placed on the stage with the instance name of 'pasteBoard' the above code (which tells the transform tool what to transform), works just great. However, when I place the MC on the stage with AS and name it, the transform tool can't find it . Here is the code I'm using to place the MC:
ActionScript Code:
var pasteBoard:_pasteBoard = new _pasteBoard();
addChild(pasteBoard);
pasteBoard.name = 'pasteBoard';
pasteBoard.x=128.00;
pasteBoard.y=300.00;
Now, surely this should work as I'm even giving it an instance name? But it does not, it does not work even with no instance name, or when the class object name is different than the instance name. Weird huh? Surely this should work just fine as I'm doing exactly the same thing as placing it on the main timeline, just doing it with code. But the transform tool, referenced by the code at the top of this post, can't find pasteBoard.
Do I need to alter the code at the top to find pasteBoard by class instance? how would I do that?
View 4 Replies
Feb 29, 2012
I have a non-document class that I want to put in charge of changing scenes when some conditions are met.First things first, I need to figure out how to change scenes!Here's my code:
Code:
package classes {
import flash.display.MovieClip;
[code]....
View 8 Replies
Mar 14, 2011
i have a class and trace its type with flash.utils.describeType(this)
class Data extends EventDispatcher
{
public function Data()
[Code]....
Is it possible to override this information e.g type.@isDynamic, as well as extendsClass.@type, at runtime? without bytecode?
View 5 Replies
Dec 28, 2010
For some reason Adobe doesn't allow us to change the size of the handle in the default slider component. This handle is small and hard to click on quickly. If you try to increase the size of it graphically it just gets resized back down to 13x13 pixels. I've looked into the Slider.as code found in:
Program Files(x86)/Adobe/Adobe Flash CS4/Common/Configuration/Component Source/ActionScript3.0/User Interface/fl/controls/Slider.as
And found that on line 803 there is the code thumb.setSize(13,13). I tried changing that to 60,60 but it doesn't change the size of the handle. I don't know much about classes and I didn't think you had to compile these. I thought that in Flash when you clicked on the Components button that it loaded these classes in at that point but I must be wrong.
ActionScript Code:
override protected function configUI():void {
super.configUI();
thumb = new BaseButton();
thumb.setSize(60, 60);
[Code] .....
View 5 Replies
Jan 14, 2012
I'm trying to change a varialbe in a seperate class from inside a movieclip that I have on the stage in the timeline, but the variable I'm trying to change keeps coming up as null instead of what I am trying to change it to. How is this usually done?
View 6 Replies
Dec 30, 2008
I'm trying to make a URL-Loader Class to speed up my workflow, but I can't manage to make the images I am loading visible, turning their alpha to 1.
I use the following line to invoke my custom loader:
import com.ab.utils.Load
Load.Image(menuitem.holder_mc, menuitem.image, this)
[Code]....
Notice where I call a Tweener, trying to make my mc (_ITEM)'s alpha turn 1.
I tried thing like loader.content and loader.content.holder_mc, but to no avail.
View 2 Replies
Jan 17, 2011
I wrote a simple class called CustomTextField.as as follows:
package{
import flash.text.TextField;
public class CustomTextField extends TextField{
[code].....
View 2 Replies
Aug 14, 2009
How do I change the corner radius of a Label component in Flex. Tried applying style name, and the setStyle('cornerRadius',9) methods, but doesn't work. How can I change the arrow image in the combo box control to a different image?
View 4 Replies
Aug 31, 2009
I want to create another button on the main menu of my flash site. I want to take one of the existing buttons (which are set as movie clips) and modify it to show a different menu name and page link. BUT when I go into my library and "duplicate" my movie clip, change the instance name, drag it to the stage and attempt to modify it, the original changes as well. I need to keep the original the same and create a new one with the same code, frames, etc but with different static text. I keep going in circles
View 1 Replies
Feb 1, 2006
basically when you load the .swf it changed everytime u re-load it , i want it to keep on changing even when the user hasnt reloaded the image
[Code]...
View 1 Replies
Apr 8, 2010
I've come across a pretty bizarre bug in my code when working with level generation in a side-scrolling platformer I'm trying to make... I've been desperately trying to debug it for the past 2 days! I have a movieclip (exported for AS) called Section1, that contains the first section for a level. It's basically a huge movieclip containing other movieclips; this Section1 movieclip contains the graphics for the level, as well as collision detection (the graphics are .pngs converted into movieclips, the collision detection is transparent rectangles converted to movieclips). FYI, it's a BIG movieclip... roughly 3400 pixels wide.
So, since it is the 1st section of a level, I have it spawn at the beginning of the game. However, I need to access all the platforms, walls, and graphics inside section1 from inside AS. So, here's the code I am using to do this:
public var s1:Section1;
public var platforms:Array, walls:Array, levelGraphics:Array;
...
// in Main's constructor now:
s1 = new Section1(2236, 8);
[code]....
Initially, it works... I've traced the data in the arrays in my update method (run every frame), and I can see that the arrays contain displayobjects... for a split second, that is. Seemingly out of nowhere, the values for all the elements in the arrays become NaN! I think to myself... of course these DisplayObjects are "not a number"... they're displayobjects! Of course, this renders my arrays useless, since I can no longer access the data I need to do collision detections!
View 5 Replies
Oct 13, 2011
I can rotate it, or modify>transform>rotate +/- value
but what is the manual equivilant to simply object.rotation=0;
View 4 Replies
Sep 4, 2008
I have 2 sprite which I create near the beginning of my video application. A bg and screenOverlay. On the first load of the file all is good but when I navigate away and then return to the swf my bg and screenOverlay do not get added to the displayList. I have a example up here at [url]...
View 9 Replies
Feb 8, 2010
I have array with DisplayObjects and I need exactly copy of my current array with same DisplayObjects but each DisplayObject should not have direct and indirect relation with my current array. Do you have any clue about this coping display Object.
View 2 Replies
May 19, 2010
I have this class:
public class IskwabolText extends Sprite {
private var _tf:TextField;
private var _tfmt:TextFormat;
[code].....
View 2 Replies
Jun 5, 2011
I'm trying to load a module and add it to a mx:box object called "mod". [code]...
View 1 Replies
Jun 29, 2011
I know how to draw a rectangle and add it to a DisplayObjectContainer,but do you see a simpler method to directly add a border to a DisplayObject? DisplayObject don't seem to have addChild(), so I would have to add it on the parent, which is not perfect in my opinion...
View 3 Replies