ActionScript 3.0 :: Clicking To AddChild To Stage Coordinate?
May 5, 2009
I have a function for shooting at the stage/baddies using the code below. This has two problems, one, when I click somewhere it fires their, but when I click a second time, it fires at 0,0 coordinates on the screen, then if I move the mouse and fire, it doesn't track accurately.
Code:
package{
import flash.display.*;
import flash.events.*;
[Code].....
View 4 Replies
Similar Posts:
Dec 27, 2010
Is there anyway to implement the parent addchild without its parent x and y coordinate?
ActionScript Code:
iamparent.x =100
iamparent.y=100;[code]....
the final coordinate of the child would be x=200, y=200. But, is there anyway that that i cant addChild with only respect to the coordinate of iamchild?
View 5 Replies
Jan 20, 2011
I have the followings:
_p:Player (which is a MC)
a1:Animation1 (which is a MC)
_p.addChild(a1); //doesn't display anything
_p.stage.addChild(a1); //displays a1
Why won't the MC display a child without using his stage?
View 1 Replies
Jan 16, 2010
I think I did this before but can't find the code. Flash as many other graphical frameworks use the top-left corner as the coordinate origin (0,0) because it's how the underlying memory model is by convention. But it would be really simpler for my calculations if the origin was in the center of the stage, because all the game revolves around the center and uses a lot of trigonometry, angles, etc. Is there some built-in method like Stage::
setOrigin( uint, uint );
or something like that?
View 2 Replies
Nov 15, 2010
PHP Code:
var MapBtnArray:Array = [];
var MapBtnSprite:Sprite;
var i:int;[code].....
I'm using to code above to create several sprite on the stage, but when I click on the sprite, the index of each trace work just fine (output of J is according to the target i click); however MapBtnArray[j].x keep equals to "0".I want the coordinate of the sprite on stage, how come what i get is "0" instead?
View 3 Replies
Mar 31, 2010
I have 3 square. smallest square s3 is inside s2. s2 is in side s1. each is 10px larger [code]how can I find the coordinate of child in its parent's coordinate system?
View 1 Replies
Aug 11, 2011
If im usin function to add a mc to the stage like so:var myChild:MC= new MC();
function somefunc()
{
stage.addChild(myMC)
[code].....
View 4 Replies
Apr 30, 2011
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] .....
View 1 Replies
Nov 5, 2010
I started working with AS3 a month ago, I know the basics and stuff, but I can't do that much. The user would draw lines by clicking on the stage. The code works exactly as I wanted it to, but it is on AS2 . I tried, but I can't 'convert' it to AS3. I would like to know how this code would work on AS3! Here's the download link of the .fla, so you can see better what I mean: [URL].
View 3 Replies
Mar 15, 2011
I have a frame-by-frame animation. I want to be able to click and drag on the stage back and forth and traverse through the animation. I.e. I want to click and drag from left to right to make the animation go forwards and right to left to make the animation go backwards. How would I achieve this? I am making an assumption that there will be some maths involved in calculating mouse position and traversing to the correct frame, but how would I do this?
View 2 Replies
Jul 13, 2009
Following is the code I paste in the first frame of layer1..it was working before I added for loop..I am tring to explode all six balls on the stage clicking..but what is missing ?How can I get it work ?
for (var i = 1; i<6; i++) {
ball[i].onPress = function() {
ball[i].gotoAndPlay("explode");
};
}
View 2 Replies
Jul 7, 2009
I am just starting out new with AS3 and I have a question about this block of code I have. i have checked this against I don't know how many examples and it looks fine, yet... when it's run, I get nothing. Traces on everything came out OK.
Code:
var sheep:mcsheep;
var xpos:int;
var ypos:int;
[Code].....
View 2 Replies
Jan 6, 2010
I'm having a very odd bug with ActionScript 3 in Flash CS4. I am adding movie clips to a stage in a for loop and then moving them out of view so that I can pull them in and remove them when I need them.
I've narrowed down the issue to a point that I know that every time one of the movie clips are added to the stage using addChild(), the stage shifts to the right by one pixel. I know that sounds odd, but it's literally true... the 0 line on the y axis is shifted to the right one pixel every time the movie clip is added.
Here's the code that is doing the work:
private function setupSlides():void
{
for(x = 0; x < TOTAL_SLIDES; x++)
{
[Code].....
View 1 Replies
May 31, 2011
I am trying to add an object to my main stage via the addChild() method. Normally, when working within the FLA itself, using addChild(myObject) works just fine. However, it does not work within an external AS class.
All of the other tutorials I have found showed me how to do something like this, which is not what I need:
var myMovieClip:MovieClip = new MovieClip();
myMovieClip.addChild(myObject); // Works great, but not what I need
how to add an object to my main stage via an external AS class.
View 2 Replies
Oct 4, 2011
I just tried to add the movieclip "box" to the "container.holder". Both movieclips are on stage. Nothing happends with this script.
container.holder.addChild(box);
View 1 Replies
Oct 1, 2010
I've created a function that works on the main stage and I am trying to transfer it to an external class to make it an easily reusable function.When I run it however, everything works except for the fact that it doesn't put anything on the stage as it should. All the info it needs is there it's just not putting it there.Therefore I conclude that I am using the addChild(); incorrectlyhere is some of my code if needed:
ActionScript Code:
public function drawBoard(i:int, j:int, tiles:Tile, boardArr:Array, stageBoardArr:Array):void {
[code]....
View 3 Replies
May 29, 2010
I CAN add something to the stage using the Addchild... What i am trying is to add to the stage but in a PARTICULAR frame, lets say frame 50. Should i create a "container" on frame 50 and add my movie to that container?
View 2 Replies
Apr 11, 2011
var boaty:boat = new boat();
boxy.addChild(boaty);
How do I refer to the stage position (what we see on screen (might be called something else)) of a object added like this (boaty
View 8 Replies
Jan 28, 2010
I have a small mask that I need to animate across the stage in response to clicking various buttons. It has to go a different distance each time depending on which button is clicked along the x axis. I can get at the starting and ending x co-ordinates. need to develop a set of x cordinates so that the mask starts moving fast and slows down as it gets nearer - kind of like the easing effect. I figured using some sort of simple 1/x^2 expression and have spent an hour or so fiddling in excel. Trouble is its a LONG TIME since I did maths, and I can't remember what formula to use. Have tried google with "parabola", "simple curves" etc etc
View 3 Replies
Aug 19, 2010
I'm having an issue with a blank open document, clicking on 'import to stage' will crash the program or clicking on 'import to library' will crash the program I have tried uninstalling CS4 and re-installing CS4. The problem remains the same
View 3 Replies
Mar 21, 2012
I´m trying to catch KEY_UP event if I press ENTER, without clicking on stage.
I´ve already disabled keyboard shorcuts for flash player, and added stage.focus = stage.
Not succeeding.
It only works if I click on stage.
It seems that for the other keys the KEY_UP works.
View 8 Replies
Apr 1, 2011
I have a drop-down menu that stays open when I click it, until I click it again. I want it to close when I click away from it. So I created an event listener of type MouseEvent.CLICK and apply it to the stage.
The obvious problem is, though, that when I click the drop-down menu to make it open, I'm also clicking the stage, which prevents it from opening.
I think there's probably a simple solution to this but I'm stuck. I called stopPropagation() on the drop-down menu and that seems like it should help but it doesn't.
View 2 Replies
Feb 15, 2010
I have an .fla file with 1 image in the library and 1 .as file.I have linked the image up with the Class name of libraryImages and Base class is flash.display.BitmapData.This is my AS:
package {
import flash.display.Bitmap;
import flash.display.BitmapData;
[code].....
View 1 Replies
Jan 21, 2011
When I add an object from the library to the stage in the timeline (by putting the script in the timeline) it works but when I try to add it from this .as file nothing happens.
[Code]...
View 1 Replies
Jul 18, 2011
I just wanna add an image from my library on the stage and have an event listener on it so when i click on it, it will do something. imgFromMyLib is already set to the image i want from my library.
import flash.display.Bitmap;
import flash.events.*;
import flash.display.Sprite;[code].....
View 2 Replies
Oct 25, 2011
How do I make sure that a movie clip that starts on the stage has a higher zindex then when I addChild and add a linked movieClip from the library.
Really my code is pretty simple
background_image = new Sprite();
main_container.addChild (background_image);
But I have a movieClip "message_box" that I dragged onto the main timeline. When i add the background_image which is the full size of the stage it overlays the "message_box"
I know you can set the childs index but how do I set the "message_box" index?
View 2 Replies
Jan 25, 2010
I have a movieclip with 8 frames and i would like to add each of the frames to the stage with addChild and with a different X, how can i do it? I was looking for something like addChild(nameMC[2]); //for frame nr 2 but i can't found any info related to this..
View 2 Replies
Mar 5, 2011
Ok what i want to do is to put MORE than one instance of a MC on stageFor that i try to create a name to the MC inside a (FOR) loop (working)what dident work is to put multiple instance of it on stage.Seem preety basic but i can figure it out
function generateHex(e:MouseEvent)
{
tileSet.x = tileSize;
[code]......
View 2 Replies
Aug 13, 2007
Does anyone know how to addChild(aMovieClip) to stage by using a static function, like:
public static var player
public static function LoadPlayer()
{
GameEngine.player = new Player
stage.addChild(player)
}
(Or better yet tell me how to run functions in different class without creating instances of them or using static function )
View 8 Replies
Jun 8, 2009
I have a class that adds to the main stage fine, but not inside an MC
var SliderTestClass = new SliderTestClass;
mContent01.addChild(issSlider); //trace says undefined
addChild(issSlider);//trace says [object SliderTestClass]
Why would it refused to be added to mContent01 which is a visible MC on the stage?
View 8 Replies