ActionScript 3.0 :: Add A Drawn Object To The Stage?
Mar 14, 2010How do you add a drawn object to the stage using actionScript 3? Does the object need to have an instance name?
View 2 RepliesHow do you add a drawn object to the stage using actionScript 3? Does the object need to have an instance name?
View 2 RepliesHow can I delete a drawn object from the stage to then use the same function to draw it up again?
View 1 RepliesI have created a class, call it Class1, that has various objects drawn on the stage (drawn in the IDE). It also has a function, called setColour, for changing the colour of those objects. The function works fine if I call it from within Class1.
Now I have another class, call it testClass1, that imports Class1 and calls the setColour function. First of all, none of the stage objects from Class1 are visible. Secondly, when setColour tries to modify the colour of an object, I get the error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
This is the code for testClass1:
ActionScript Code:
package
{
import flash.display.*;
[Code].....
So, what is the problem? Is it possible to change objects that are drawn on the stage of an imported class?
Lets say I have a customMovieClip. I sometimes draw an ellipse with customMovieClip.graphics and sometimes a rectangle. Now I want to know what was the shape ( ellipse/rect) that was created using a particular graphics object. Doing this would enable me to pinpoint what exactly to do with that customMovieClip() instance.
View 3 RepliesI had to create dynamic with AS some rectangular on stage using moveTO and lineTo. I had a button and when I press it should add a new rectangle on stage but it doesn't. Because the array that I am storing the MovieClip created are overriding I guess
var i:Number =0;
button_name.onRelease = function() {
i++;
var instancename:String ="new_mc"+i;
var mcClip:MovieClip=createEmptyMovieClipinstancename,this.getNextHighestDepth);
[Code] .....
I need to drag a component along a programmatically drawn path composed by different kinds of graphic, like lines, curves, etc.
View 3 RepliesLets say I have a customMovieClip. I sometimes draw an ellipse with customMovieClip.graphics and sometimes a rectangle. Now I want to know what was the shape ( ellipse/rect) that was created using a particular graphics object. Doing this would enable me to pinpoint what exactly to do with that customMovieClip() instance.
View 3 RepliesThis time round i need to get the pattern drawn on the drawing board to be repeated on another area of the stage.I need it to be repeated 4x4 tile.
View 1 RepliesI would like to change backgroundColor of an drawn object(square) by mouseover. I acutally found the function for mouseover in action scripts but BackgroundColor("#ccc") does not work.
View 3 RepliesI was wondering if it possible to write up some AS that will take line paths that you have drawn and convert them into a Path object? For example say you drew a jagged line from left to write, would there be a way to have AS convert that into a Path object.
View 11 RepliesI 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.
View 0 Repliesfigure out why the movie i just made is off stage. I just I don't want to start from scratch or move every object that is off stage onto stage. What did i do to get it here to begin with???
View 1 RepliesI have a stage bigger than the size of a browser, and I have a camera to navigate around the area.Now when I click on a button, I will have something pop up blocking the whole browser, like a lightbox effect with another box on top of the blocker.The problem now is, when the blocker pops up, its position is not on the TOP LEFT corner of the browser. I've tried stage.align, but it would makes the camera or other object on stage position run.So is there any other way I could get the blocker to position according to the browser, not the stage?[code]
View 1 RepliesOk. So heres what I am trying to do. I want one movie clip to follow another one that I move around with actions on the main timeline.The problem is that the follower clip is linked to a class file and I cannot find a way to find the players position.
[Code]...
I want to know the difference between [object main timeline], [object Stage] and root in as3? I have read from the topic How stage, root, and MainTimeline Fit Together. But I didn't get clearly.
View 3 RepliesI'm trying to create a boundary for a player object, controlled with arrow keys, in my game using the main stage's height and width. For example, one test point is at the top edge of the player object's bounding box so that when the player object's head touches the stage's top edge, the player can't move anymore to the north. The player object is manually instantiated to the center of the stage by using the Flash stage editor so it will start at the center before the program starts.The problem is that right at the start of the program, I can no longer move the player object up or down with the arrow keys but I can still move it left or right. The intention is to allow the player to move north until the player object's head touches the top edge of the main stage.[code]
View 1 RepliesThe following is that long only because I gave examples of what I want to know, not because it is complex .I have three basic questions regarding AS 3.0 classes.
1. How can I make a class object interact with an object on stage?
For example, when I have a square (mc_Square) with class "square" attached to it and I want it to trace "Colliding!" and print the X and Y of the mc_Box on contact with an on-stage *hollow* box (mc_Box) that has no class attached to it.how to do it vice-versa would also be awesome .
2. How can I make a class object interact with the same class object? For example, when I have two squares (mc_Square) that both have the class "square" attached to it and when they collide, it prints the X and Y of both of them.
3. How can I make a class object interact with a different class object?
For example, when I have two squares mc_Square1 with class "square1 (that also has a variable Primary=true written in it)" and a mc_Square2 with class "square2"; When they collide, the one with Primary=true would be removed and it's X,Y position traced.
I'm trying to get an object to increase in size the lower it goes down the stage, and decrease in size the high it moves up the stage.
It only needs to increase or decrease by a small amount. Basically, it's for a game character. To ad realism to his movements, it would be nice to have this feature.
This is where i'm up to so far:
Code:
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
[code]....
I think I need something like:
if (object moves up)
decrease
else if (object moves down)
increase
i'm trying to use code so if i type in -10 to 10 the object will move up or down the y axis. The code i'm using at the moment calculates how far to move it from the number inputed, then it removes te object and places it in the required position. However doing the removeChild technique messes up when having many on the stage. I was wondering if anyone knew a way of calculating the rating and then using it to move the object on the stage without removing it and adding it. Here is the code i'm using to move it. OR a way in which i can remove certain objects on the stage using remove child
[Code]....
I am making a game where I reference "Player_mc". There are many different characters you can play as, so there can't be only one movieclip being called "Player_mc" I have each character (movieclip) in the library. How can I call upon them to come to the stage and be given the instance name "Player_mc".Also how can I remove them when the character is changed?[code]
View 1 RepliesI'm trying to make a function for centering movieclips to other movieclips, or centering the movieclips to the stage. My problem is movieclips use _width & _height and the stage uses width & height without the underscore.I'm passing the 2 objects as parameters to the function "center" (reference for centering, and the object I want to center), but I don't know how to make the function know if I'm passing a movieclip or the stage
View 1 RepliesLet's say I have an object, and I use a motion tween to animate it around. Great. Now, I want that object to stay at the final location while other stuff happens on the stage. I can't figure out an efficient way to do this. You can't copy individual frames of a tween, and copying and pasting the whole tween and breaking it up into individual frames and then removing all but the last frame is a bit... time-consuming.how I might be going about using tweens wrong? I feel like I'm just not doing things the way it was designed.
View 3 RepliesI am kind of new to the whole flash sceen and am getting a little bit frustrated with the snapping (I am used to Photoshop Snapping). I have a bunch of objects the exact same size as the stage and I would like to snap them to the stage (I am making a slideshow-rotating image). I always find myself having to zoom in extreamly to make sure the edge of my image is lined up with the edge of the stage... is there a way to snap my images to the stage.
View 1 RepliesI would like to know if there's the way to do collision check on every object on the stage,
[Code]...
I want to make the object such that it falls on a rotated platform and land according to it's angle. I've success fully make it landed according to it's angle before it lands. but the problem here is that, after the landing when I trigger the rotating platform, the object falls when the platform is out of it's hit area. Is there a way such that it will work like a car wiper and wipe the object towards it's direction?
I have built a site in AS2 and would like to know the position of a ball so that I can move a sign to it always.The whole website is in AS2, but I think I have written an incomplete code below for AS3. I need it for AS2 because the whole site is in AS2. The get position of ball is wrong, but I just wanted to throw in some ideas eg.
Code:
// get position of ball
ball_mc.addEventListener(<what goes here?>, ball_pos);
function signMove(Event:MouseEvent):void{[code]..........
I created four instance of movieclip on stage and named them t1_mc,t2_mc,t3_mc,t4_mc. Then I made and array and loaded them inside the array
var arr1:Array = new Array( t1_mc, t2_mc, t3_mc, t4_mc );
var names:String;
//function made to add event listener to each object
function addListner():void {
for ( var i:uint = 0; i < arr1.length; i++ )
[Code] .....
I have some object, which extends movie clip:public class MyClass extends MovieClip Now, I want to put two of this in the stage:[code]That would put one, but the other I want it to be exactly the same as the first, so I just need to add a "reference" of obj to the stage, along with obj itself.In the end, I want two objects of type MyClass doing the same thing in the stage. If I try to simply do:[code]only obj2 will appear in the stage.How could I achieve that with references? (in order to save memory and CPU time (it is really important))
View 6 RepliesI'm doing a tutorial and I get this error about the "stage". I just copied the tutorial code.. what's missing ?
Code: TypeError: Error #1009: Cannot access a property or method of a null object reference.
at ParticleDemo() at myFlashFile_fla::MainTimeline/frame1()
Code:
package {
import flash.display.Sprite;
import flash.events.Event;
[Code]...
I've been working on an as3 project for quite some time now, but I can't seem to get the following code working for some reason:
Code:
var test1:Object = new Object;
stage.addChild(test1);
I keep getting the same error:
Implicit coercion of a value with Static Type Object to a possibly unrelated type flash.display: DisplayObject
I'm trying to make a function for centering movieclips to other movieclips, or centering the movieclips to the stage. My problem is movieclips use _width & _height and the stage uses width & height without the underscore.
I'm passing the 2 objects as parameters to the function "center" (reference for centering, and the object I want to center), but I don't know how to make the function know if I'm passing a movieclip or the stage.
I tried typeof which returns [object object]....