ActionScript 3.0 :: Create An Instance At The Correct Position?

Oct 22, 2010

basically, I am trying to create an instance at the correct position. I understand that I will have to utilize globalToLocal() and/or localToGlobal() to get relevant positions, but for some reason, I can't position the instance at the correct location. here is the codes:

parent class:

Code:
//create bullet
bulletList.push(new Bullet(100, 100));
addChild(bulletList[bulletList.length - 1]);
Bullet class:

Code:
x = localToGlobal(new Point(pX, pY)).x;
y = localToGlobal(new Point(pX, pY)).y;

pX and pY are the arguments for the Bullet Class. When I do this, it is shifted over 100, so the absolute position being x = 200, y = 200, and the local position being x = 100, y = 100.

View 4 Replies


Similar Posts:


ActionScript 3.0 :: Getting Correct Instance Name With Arrays?

Apr 14, 2010

I'm new to Actionscript 3.0 and flash and I'm trying to make a simple drag and drop project that using externalinterfacecall will have javascript check or uncheck a value on a webpage when an image is dropped into a certain box. I'm trying to give myself a solid string to pass through to the javascript however when I do this one way, I get a stack overflow that is as follows :

Actionscript Code:[code]........

View 3 Replies

ActionScript 3.0 :: Getting The Correct Instance Name Of A Button?

Jan 27, 2011

I'm using a loop to generate and position a bunch of movieclips on my stage and another to add mouse eventlisteners to them, turning them into buttons.

All this works fine however when i attempt to trace the instance name of the button pressed, output is firing "instance40" or "instance41" etc.

how do i get the correct instance name? I'm attempting to get at the value of the textfield held within the movieclip i.e. trace(evt.target.value_txt.text); however this is resulting in errors.

Is there a standard procedure for generating buttons in a loop? I'm not understanding why my buttons aren't tracing the correct instance names or why i can't access the movieclips contents, specifically the value of the dynamic text field?

Code's below, if anyone wants to see the whole code, or FLA, give me a shout.

ActionScript Code:
var eggs:Array = [];
for(var i:uint = 0; i < 24; i++){

[Code].....

View 1 Replies

Force A SWF From Top Left Corner To The Correct Position?

Sep 27, 2009

how to force a SWF from Top left corner to the correct position.. When I tried to use a container it made the external swf not work at all, though it was in right position

WITH THIS CODE, THE SWF LOADED BUT JUST IN WRONG POSITION :
on (release) {gotoAndPlay(4);
loadMovie("gallery.swf",1);
}

then when I used a EmptyMovieClip it came in as the attachment.

Is there any other way to still use the LoadMovie() and adjust the x and y positions?

View 1 Replies

ActionScript 2.0 :: Get The Correct Position Of The Textfield Within The Movieclip?

Oct 29, 2003

I have two dynamic textfield and they are both within two movieclips because I have action to rotate , enlarge and move the related movieclip so that the text changed accordingly.

But there is problem like after I record the position after modification to database and retrieve them back to the flashpage. The position of the movieclips are changed or maybe it is the textfield's position within the movieclips are changed which I have no exact idea what happened.

So could any one who can give some suggesion how should I arrange the textfield within the movieclip and how to keep track of the right position after enlargement or rotations,etc then?

Isn't it I have to consider the relative position of the textfield to the movieclip at the beginning.

View 2 Replies

ActionScript 2.0 :: Get The Correct Position Of The Textfield Within The Movieclip?

Oct 29, 2003

I have two dynamic textfield and they are both within two movieclips because I have action to rotate , enlarge and move the related movieclip so that the text changed accordingly. But there is problem like after I record the position after modification to database and retrieve them back to the flashpage. The position of the movieclips are changed or maybe it is the textfield's position within the movieclips are changed which I have no exact idea what happened.

So could any one who can give some suggesion how should I arrange the textfield within the movieclip and how to keep track of the right position after enlargement or rotations,etc then? Isn't it I have to consider the relative position of the textfield to the movieclip at the beginning. Becuase I have no exact idea how should it work.

View 2 Replies

ActionScript 3.0 :: Test To See If The Class Of An Instance Is The Correct One?

Apr 13, 2009

How can I test to see if the Class of an instance is the correct one? Say I have two Custom Classes, Circle and Square. How would I make it so that if the class of instance one is Circle, a specific function is carried out?

View 1 Replies

ActionScript 2.0 :: Button Is Not Being Placing In The Correct Position When Set The X And Y Values?

Jan 15, 2011

My buttons are not being placed in the same position as my other buttons are on another page? I copied the same x and y cordinates as the other page..but they are still not being placed in the same position..why is this?

View 2 Replies

ActionScript 2.0 :: Dynamic Images Not Loading In Correct Position?

Feb 8, 2007

Currently, I use loadmovie to load a jpg into a movieclip. However, when the jpg is loaded, I believe that the top left hand corner of the jpg is in the middle of the clip and does not line up with the top left hand corner of the clip.

How do I get the jpg to line up correctly?

View 3 Replies

ActionScript 2.0 :: Load Movie At Correct Size And Altering Position?

Dec 12, 2010

How can i get the file to load at the correct size by using the onloadInit at the moment the file is loading but its loading in the centre. [code]...

View 7 Replies

ActionScript 2.0 :: Make Images Gallery Into Area Correct Position

Dec 19, 2011

I'm doing flash project slide images but i don't know how set images into area correct position. And textfield load file .txt.

[Code]...

View 3 Replies

Professional :: Animating Step Through One Frame At A Time And Move The Linkage Rod And Piston Into The Correct Position

Dec 19, 2010

how to animate a piston like the one above in flash cs5? Should I use bones? if so how? At the moment the only way I can see to do it is to step through one frame at a time and move the linkage rod and piston into the correct posistion.

View 2 Replies

ActionScript 3.0 :: Create New Instance() When Instance Is A Variable?

Feb 12, 2012

I have a base class I've used on 6 different MC's. Then when I use these MC's my function runs an if statement to check which one to add.

if(id=design) var obj = new design();
if(id=team) var obj = new team();

I want to make it a bit more dynamic and use the id:String to evaluate which new instance to create.

ActionScript Code:
public function loadChapter(id:String):void {
var obj = new instance_of( id )();
}

View 5 Replies

XML :: Flex - Correct Way To Create New File From Adobe Air

Dec 21, 2011

I'm having trouble creating an XML file from Air. It always seems to have some extra character in front of the first block in the xml file like this "¥". This application can read back out of the document, but if i open it with a text editor to make a change and save it, it will no longer open in my application. When I create this XML file, the whole reason I want to use an XML is so that I can possibly edit it on another computer, or in a text editor, and send it back.

Right now I'm creating the XML like this:
var myXML:XML = <motor>
<type>{motor.type}</type>
<shopLocation>{motor.shopLocation}</shopLocation>
<customer>{motor.customer}</customer>
<tech>{motor.tech}</tech>
[Code] .......

View 1 Replies

ActionScript 3.0 :: Save The SoundChannel.position Number (and Also Call SoundChannel.stop()) In Correct Time

Dec 6, 2008

I just finished a simple music player... For testing purposes. I upload it in the following address:http:[url]....with 10 music songs that I had recorded from radio stations(added the last 2 twice for testing).The problem is that when a song has totally loaded, stop action taken needs about 1 second to be applied!I.e. When I press "STOP", the sound continue to play for 1 sec before stop. When I push "pause" it takes one second for the music to stop!

However when using resume (second time pause) the sound starts instantly! Thus I guess there is an issue with stop()function of the SoundChannel object that I am using to stop the sound. Also notice that when unpause the music, it continue ~one second before the last sound - which means that I saved the soundChannel.position number (and also call soundChannel.stop()) in correct time, but it didn't stop immediately - bug!?

This only happens when the application runs through a browser(plugin v. 10) - programmed in CS3.

PS1. Notice that ,this also happens when I change Volume too. Thus because Stop and Volume are parts of SoundChannel, I guess there might be a bug with SoundChannel in online plugins..... :/

PS2. Notice that ,this also happens when I close the browser (firefox). Even if browser is closed the music continue for 1 sec the same way as when pressing stop!.. Thus I guess it's flash bug!...

View 2 Replies

ActionScript 2.0 :: Movieclip Name Is Undefined "despite Having The Correct Linkage And Instance Name"

Feb 8, 2004

I'm trying to attach a movie clip to the main stage using:

[CODE]...

However, it ain't showing up. Trace said the movieclip of that name is undefined, despite having the correct linkage and instance name. Anyone know why a movieclip might be MIA?

View 4 Replies

Modify Flash Files To Create Correct Links

Mar 12, 2012

I have been given the task of updating my company's website, which is written in ASP and has a menu in Flash. I am not experienced in neither technology so maybe you can help me a little bit.We have a menu in flash and just received a new one from an artist. They are pretty similar but the new one brings some new buttons. So far what I did was simply change the .fla and .swf files from my web project to the new ones. The new menu is working, but the buttons and links are messed up. For example, our website main page is called Default.aspx. In the old menu, when you clicked in 'Home' it would take you to Default.aspx. In the new one though, it tries to take you to 'index.aspx', which doesn't exist. This makes me think that the mapping of the links in the menu is something that is part of the Flash code. Am I right about this?

Now, if I am right and I need to modify the flash files to create the correct links, how the heck do I do that? Notepad++ doesn't read the .fla well. What is the best free tool that will allow me to modify a file and compile it into a .swf? I know Adobe Flash would work, but we don't want to pay anything.

View 2 Replies

ActionScript 3.0 :: Create Flash Quiz Based On Circling The Correct Answer?

Dec 27, 2010

I am quite new to actionscripting and need to create a flash based quiz.The user will have to circle the correct answer in the quiz.I do know of drag and drop function but didn't know how to create circling function.

View 11 Replies

ActionScript 3.0 :: Generate Movieclips / Instance Name And Position

Nov 1, 2010

I've got a movieclip in my library called primaryCommMC.I'm loading these 5 times onto the stage and naming them commMC0-4 using the following:[code]Right now they're all obviously loading on top of each other. I want to stack these movieclips on top of each other so the first movieclip will be at y=0 and the following at y=(the height of the proceeding MC + 5 (a little gap)).

View 1 Replies

Flash :: Get The Position Of Instance Whose Name Is Stored In An Variable?

Nov 18, 2009

How can I obtain the position of a instance whose name is stored in an variable? If there is a instance whose name I don't know, but the instance's name is store in an variable x. How can I obtain its position?

View 4 Replies

Flash :: Get Position Of Instance Of The Same Type In The Stage

Feb 3, 2011

i'd like to count and get position of instance of the same type in the stage.
i have tried:

var target;
for(var item in _root){
if(_root[item] instanceof MovieClip || _root[item] instanceof TextField){

[Code]....

but it says access to property _root undefined, and instanceof deprecated

View 1 Replies

ActionScript 3.0 :: Retrieving Instance Position From A Class?

Feb 22, 2011

I have an instance, hero linked to class Hero.as, and enemy instances "enemy1", "enemy2", "enemy3", each linked to Enemy.as class. From inside the Enemy.as class I would like to know the position of the hero instance and be able to move them accordingly towards the hero. If I was working from within the document class I could do something like hero.x and hero.y to get the x and y position of the hero.

View 1 Replies

ActionScript 2.0 :: AttachMovie - How To Get Y Position Of Movie Instance

Feb 1, 2004

How to get the _y position of a movie instance generated by the AttachMovie method? I'm trying to do something like this.
_root . mc full of attachedMovie instances . one of those clips . _y
The path I'm really using looks like:
_root . text . infoblock4 . _y

View 3 Replies

ActionScript 2.0 :: CS3 Create A Password Input Area Where A Player Can Insert Several Passwords And Be Correct

Mar 21, 2010

I'm trying to create a password input area where a player can insert several passwords and be correct, each password triggering the typing of that password in a separate area (which is what the numbers one to ten in the script below refer to). However, there is some flaw I can't find in the script and if I try to enter anything in the box, it is changed to "orangemarmalade" (see below) and only enters there (acting as if I typed "orangemarmalade" every time).

[Code]...

View 3 Replies

ActionScript3 :: Flex - Determine The Position Of An XML Instance In An XMLList?

Aug 11, 2009

What it says on the tin: I have an XMLList, and I want to find where in it a particular XML item falls. First index is good enough for my purposes. Note that I have no problem writing a function to do this by hand... but I was hoping that the API has something buried somewhere that'll do it for me. I didn't see it, though.

View 2 Replies

ActionScript 3.0 :: Get The Depths Of All The Blocks To Be At The Correct Levels At The Correct Times

Dec 30, 2009

I'm trying to get the depths of all the blocks to be at the correct levels at the correct times so that the 3d effect is maintained. I've tried many things, but have had little success. All the instances of the blocks are stored in an array, but since it's adding them in accordance with when they're added to the stage, it doesn't help me locate them to swap depths. Is there a way to arrange them by location on the board?

View 4 Replies

ActionScript 2.0 :: Create A Custom Class (Testing) That Would Create A Box When An Instance Of The Class Is Created

Aug 29, 2007

I've been playing around with custom classes. My objective was to create a custom class (Testing) that would create a box when an instance of the class is created. I've tried three different approaches, however only (3) seems to be showing up. I'm just curious why (1) or (2) doesn't work?

Also is there a better approach than (3)? Since at the moment it's been created on _root. I hope the box can only be accessible through the instance. Since I'd like to incorporate the whole idea of public, private, encapsulation, etc.

[Code]...

View 3 Replies

ActionScript 2.0 :: Create 100 Instance Of Same MC ?

Oct 28, 2005

What's the best method to put 100 (or 25 or any large number) of movieclip instance on stage & give them all the exact same onRollOver event/function ? Ofcourse with the fewest possible lines of code.

View 8 Replies

ActionScript 3.0 :: How To Create A Mc Instance

Feb 21, 2009

I'm loading an external image trough this code:

var richiesta:URLRequest = new URLRequest("img/foto1.jpg");
var immagine:Loader = new Loader();
immagine.load(richiesta);
addChild(immagine);

Now all works fine but I don't know how to use this image. If I want for exemple change the alpha of this loaded image how to do this?
Do i have to make a new instance of it?

View 1 Replies

ActionScript 3.0 :: Create An Instance Name

May 6, 2009

I have a movieclip called bg_mc. I don't want bg_mc to show up until I click the btn. When I click the btn it will perform a wipe.Currently I have bg_mc on stage because I need to access its instance name. I can't remember how to create an instance name in AS3.[code]

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved