Professional :: Accessing Mouse X & Y In A Loaded Movieclip?

Mar 4, 2010

I have a movieclip that gets loaded into another container.  The movieclip reads the mouse x & y position to resize a circle according to the mouse position - it works fine on its own, but when the movieclip is loaded into a container I think the actionscript is reading the container's x & y, not from the mc itself.

The code I'm using to read the mouse x & y is:

d = Math.sqrt(Math.abs(_root._xmouse-this._x)*Math.abs(_root._xmouse-this ._x)+Math.abs(_root._ymouse-this._y)*Math.abs(_root._ymouse-this._y));

It works out the distance of the mouse from the central point (centre of the circle movieclip.)

Like I say, it works fine on its own, but when in another container the _root is causing the x & y to be displaced.I've tried _lockroot, but that stops other stuff working properly in the movieclip (drag and drop.) Is there another way I can directly access the x & y properties of the main movieclip without using _root?

View 2 Replies


Similar Posts:


Actionscript 3.0 :: Accessing A MovieClip Inside A Loaded Movie?

Feb 24, 2010

I'm running into an error accessing a movieclip from a loaded swf. Inside of my loadedMovie.swf file, I have a movie with the instance name of "bg". I want to change the width of that to movie clip when it is loaded into the parent movie but I'm getting an error saying "Access of possibly undefined property bg through a reference with static type flash.display:Loader."

Code: Select all/* ---------- LOADER ---------- */
var myLoader: Loader = new Loader();
myLoader.load(new URLRequest("loadedMovie.swf"));

[code].....

View 4 Replies

ActionScript 3.0 :: Accessing A Movieclip Of Dynamically Loaded Swf File

May 16, 2009

in (swfA.fla) I have this code in frame1

var module1:Loader = new Loader();
var admin = new MovieClip();
addChild(admin);

[Code]....

(my thought here is that 'admin' contains swfB.swf?) - this would seem very simple... but it...

...does not work and gives me this [seriously unhelpful] error:

TypeError: Error #1010: A term is undefined and has no properties.
at swfA_fla::MainTimeline/frame1()

View 7 Replies

AS3 :: Flash - Accessing And Editing Loaded Swf Movieclip From Main Movie?

Jun 23, 2010

import com.hydrotik.queueloader.*;
.................
public class Main extends MovieClip
{

[code].....

I need to get access to loaded STRATTransitions.swf from the main movie and remove some text from it. There is no source code available for the swf.

View 1 Replies

Professional :: Accessing Class Instance At Root From Movieclip?

Feb 25, 2010

I have declared a object in my 1 st frame of application.

ActionScript Code:
var objTest:Test = new Test();

I am tring to access the object from a movie clip. Movie clip is located in frame 2. I am getting error

ActionScript Code:
this.parent.objTest.IncrementCount();
trace(this.parent.objTest.QuestionCount);

[code].....

View 4 Replies

Professional :: Accessing Button Inside Movieclip/ScrollPane

Apr 19, 2010

I'm trying to understand how to build a button inside a movieclip.  I have a template that has movieclips within movieclips, and when I create a button (all using AS2) the button will work if I test the scene, but in the whole flash movie it does not work.  I also have some buttons located inside a ScrollPane that also do not call correctly.
 
For my button I am using this code:
  
facebookbtn.on (release) {
getURL("http://www.facebook.com/","_blank","GET");
}

[Code].....
 
^ This also does not work, with or without the button name before on(release).

View 1 Replies

Professional :: Accessing Timeline From Class Loaded Into Doc Class?

Jun 12, 2011

I can't find a way to directly access a MC (or textfield, etc) on the timeline from a Class loaded into my Document Class. No problem from the Doc Class, but can't do it directly from the loaded Class. Is there a trick to essentiall extend the Doc Class AS from another external class?

View 7 Replies

Professional :: Removing Movieclip When Another Is Loaded?

May 27, 2010

I have random buttons on the stage that I have set up so each one, when clicked, will load different movieclip.These movieclips load directly on top of each other in the exact same place.The problem I'm having is the previous movieclip does not clear off the stage when the the next button is clicked.I need to set up a condition that will remove the current movieclip when another button is selected to load the next movieclip.Below is part of my code that needs editing. I've been researching switch, else, and other conditional statements but can't figure out how to make this happen.I have the fla or swf file for viewing, let me know.

// Event Listenershempelbtn.addEventListener(MouseEvent.CLICK,btnActions);fourtyonebtn.addEventListener(MouseEvent.CLICK,btnActions);draycottbtn.addEventListener(MouseEvent.CLICK,btnActions);eg

[code].....

View 5 Replies

Professional :: Controlling MovieClip Loaded From SWC

Aug 25, 2011

I'm loading assets from a swc and I need to loop through every frame of the movieclip and find a certain instance so I can colorize it. Is this possible? It seems that with a swc I loose the ability to control the movieclips playback. It just plays and repeats no matter what I do.

View 4 Replies

Professional :: Loaded Video Inside Movieclip?

Mar 29, 2010

I'm working with several videos each inside their own movieclips. When I click my forward button to jump to the next video I get the second video playing over the first one especially towards the end part of the first video. I can play and stop the movies just fine but it's the gotoAndPlay that's causing me problems right now with forwarding and rewinding clips.

Hope my explanation was clear cause I'm just starting out with AS3

[Code]...

View 1 Replies

Professional :: Sound Play One Time When The Movie Is Tested BEFORE The Mouse Is Even Over The Movieclip Object?

Apr 17, 2010

I am using Flash CS4. To illustrate, I created a new flash file and added a short tick sound to the library. I set the properties of the sound to export to Actionscript and named the class "overSound". I added a Movieclip object to the stage to represent a button and gave it an instance name of "overButton". On frame 1 of the main timeline I added the following code:

[Code]...

View 5 Replies

ActionScript 3.0 :: TypeError: Error #1010, While Accessing A Movieclip From Another Movieclip?

Feb 1, 2012

I have got two movieclips on the main timeline. First one is envelope_mc and second is bg_main. In envelope_mc timeline there is a button on 25th frame which plays ahead when clicked. Here's the code for first movieclip:

Code 
on_btn.addEventListener(MouseEvent.CLICK, playAhead); function playAhead(event:MouseEvent):void { play(); }I have also got some animation on bg_main which

[code].....

View 3 Replies

ActionScript 3.0 :: TypeError: Error #1010 While Accessing A Movieclip From Another Movieclip?

Feb 1, 2012

I have got two movieclips on the main timeline. First one is envelope_mc and second is bg_main. In envelope_mc timeline there is a button on 25th frame which plays ahead when clicked. Here's the code for first movieclip:

Code:
on_btn.addEventListener(MouseEvent.CLICK, playAhead);
function playAhead(event:MouseEvent):void
{
play();
}

I have also got some animation on bg_main which I wan't to trigger on 30th frame (inside bg_main timeline) when button is clicked in envelope_mc timeline. Here's the code for second movieclip:

Code:
MovieClip(root).on_btn.addEventListener(MouseEvent.CLICK, playAhead);
function playAhead(event:MouseEvent):void
{
play();
}

Complete error:
TypeError: Error #1010: A term is undefined and has no properties.
at Flashphotographygallerywebsite7_fla::bg_1/frame25()

View 1 Replies

ActionScript 3.0 :: Accessing A Loaded Swf?

Jun 1, 2011

I'm using this code to bring in another swf into a movieClip called "movieLoader":
 
var myLoader:Loader = new Loader();
movieLoader.addChild(myLoader);
var urlMovie:URLRequest = new URLRequest("movie1.swf");
myLoader.load(urlMovie);
 
The movie loads just fine, but how do I access it?
 
I tried:trace(movieLoader.totalFrames);
 
and it just gave me "1".  I know the movieclip has more than 1 frame.What do I do to access the swf called "movie1.swf" I just brought into that movieClip?

View 4 Replies

AS3 :: Accessing Methods In Loaded Swf

May 20, 2011

I'm loading an external AS3 SWF using the Loader class but i need to access a method inside the loaded SWF. how can i do this?

View 1 Replies

ActionScript 3.0 :: Accessing Another Loaded SWF?

Oct 13, 2010

So I want to access another loaded SWF. How can I have ChildA talk to Child B? All are external SWFs.

[Code]...

View 1 Replies

ActionScript 3.0 :: MovieClip Accessing A Variable That Is In A Function Outside Of The Movieclip

Dec 8, 2010

I am trying to access the variable myParentVariable within the function myParentFunction() from the MovieClip's myMovieClip_mc function myMovieClipFunction().
 
I know that It works if I declare the variable myParentVariable outside of the myParentFunction() but I don't really want to do that

main timeline
//-------------------------------------------------------------------- ---
myParentFunction();
function myParentFunction():void

[Code]....

View 1 Replies

ActionScript 3.0 :: Accessing Parent MovieClip From Child MovieClip?

May 17, 2011

I'm trying to access a parent movieClip from the child movieClip

Here's what I want to do,

I've got a movieClip named wrong_mc, which plays for a couple of frames and on the last frame, its got a close button "close_btn" inside of it, now I wanna write the code such that when close_btn is played the movieClip "wrong_mc" should go and stop at frame1, I'm just not able to access this movieClip from the button.

View 5 Replies

ActionScript 3.0 :: Accessing Loaded External Swf?

Mar 30, 2009

I am using a zoom component which i purchased recently to load different external swfs on different button clicks. But instead of loading separate external swfs I would like to load a single swf and go to frame labels - "one", "two", etc. - I've been reading about casting the external swf as a movie clip, but I am confused how this would work with the code I have at the moment.

var image:String="introlocal.swf";
function loadContent () {
var myLoader:Loader = new Loader();

[code].....

View 1 Replies

ActionScript 3.0 :: Accessing The Url From Which A Swf File Has Been Loaded?

Jan 6, 2009

finding the url of the swf filefrom which it has been loaded? The purpose of the url is, I amloading some flv files using relative path. I just want to achievethe same by appending the relative path to the parent swf url fromwhere the parent was loaded. I am a newbie to AS3

View 5 Replies

ActionScript 3.0 :: Accessing A Variable Loaded From Another Swf?

Sep 15, 2008

I have a problem accessing a variable loaded from another swf. Actually the variable is a singeltone class, which needs to be initialized.It has structure presented in the last part of the message.The project has the following structure:

- main.swf - this loads all the other swf files and is their holder.

- assets.swf - contains some common elements and initializes the SingleTone class

- interface.swf - contains some interface elements and needs to use the SingleTone class

- all the three swf files have access to a common class structure, where the SingleTone class is defined.

Now, the problem I have is accessing the SingleTone class from the interface.swf file. If I try to send the SingleTone.singleTone. property parameter to the class I get "Type coercion failed: cannot convert from ClassName@.. to ClassName". If I try to access the SingleTone class directly from the interface.swf file i get "Cannot access a property or reference of a null object...". Both errors I get seem logical:

- if I send a parameter, I send the reference to that object, but the interface.swf file does not have access to the assets.swf domain;

- if I try to access the SingleTone class directly from the interface.swf file, I get the null error because the class is not initialized over the interface.swf domain.

Is there any work arround? I know a simple solution may be to initialize the variable over the interface.swf domain, but what if there is a variable that can only be instantiated in the assets.swf? Can I access that variable from another swf, or can I change the ApplicationDomain?

View 1 Replies

ActionScript 3.0 :: Accessing Webcam From Loaded Swf?

Nov 14, 2010

I am trying to load swf file with Loader class into AIR application. The broblem is that the loaded swf can not access web cam (it can when I run it standalone). Is there any security settings I have missed.
 
AIR loader code:
loader = new Loader(); loader.name = "moduleLoader";loader.contentLoaderInfo.addEventListener(Event.COMPLETE,

[Code]....

View 3 Replies

ActionScript 3.0 :: Accessing A Class From A Loaded SWF

Nov 23, 2011

In Flash Professional, I drew a shape, converted it to symbol, linked it to class Symbol1 (extends MovieClip) which is generated at run-time, and saved the SWF file as shape.swf.
 
Now my main application wants to load shape.swf and create multiple instances of Symbol1 but I get ReferenceError when trying to access the class Symbol1.
 
Below is my main application's code. Errors thrown are mentioned in comments.
  
public class MovieClipTest extends Sprite
{
public function MovieClipTest()
{

[Code]...

View 11 Replies

Flex :: Accessing Root Of Loaded Swf?

Mar 4, 2012

I have a SWf application built in flex 4. One part of the application relies on accessing a public variable ("step1") set at the application root, and is accessed with

var app:Object = FlexGlobals.topLevelApplication;
trace("step one is "+app.step1);

This, while not optimal, has worked fine. Now, hoever, I need to load this entire application into another application, and I can't figure out how to access my step1 variable any longer.I have been loading the swf into the new parent application like so:

public var myLoader:Loader = new Loader();
public var pizzaContainer:UIComponent = new UIComponent();
private var myUrl:URLRequest = new URLRequest("chickensoup.swf");

[code]......

View 1 Replies

ActionScript 3.0 :: Accessing Variables In A Loaded Swf

Jul 1, 2009

I am creating a flash program to open other flash programs (load swf files), and change their textfields to my own extended textfield class. This is to capture all text written to screen using a textfield object. Here is what I am doing:

1. If a textfield has been created, the event is captured

2. I want to replace the textfield with my own class extending textfield

*3. Any further access to the original textfield for value changes can be captured, and would update the replaced extended textfield object

The problem is if in their original code, at sometime, the text value of textfield is changed (mainly through textFieldObj.text = some_value) , I don't know how to capture this event.

This cannot be captured by event.CHANGE which requires the user input (ie: keyboard strokes) into the actual text field and changing the text through the code: textFieldObj.text = some_value does not trigger the event.

Here is a simplified example:

// FlashMovie.fla START -------------------------------------------
// any DisplayObjects (such as a created textfield) created will be captured
// by ChildAdded()
this.addEventListener(Event.ADDED, ChildAdded);

[Code]....

View 0 Replies

ActionScript 2.0 :: Accessing Button In A Swf That Is Loaded On To Another Swf

Jul 22, 2009

I have a movie called crime_scene.swf that is loaded onto another swf.

Code:
this.createEmptyMovieClip("myContainer", 1);
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip)

[Code]....

It seems like it's not working. I tried just myContainer.evi_1.onRelease and _level1.evi_1 but nothing seems to work.

View 2 Replies

ActionScript 3.0 :: Accessing Functions From A Loaded SWF?

Jun 30, 2010

I have a file which loads a series of SWFs. It loads one, allows it to play to completion, then stops. Right now, it will just wait for the user to press a button and select the next one. However, I need it to play them sequentially. Is there any way for the SWFs which get loaded to access the functions which control the SWF loading?

View 4 Replies

ActionScript 3.0 :: Accessing MC Children By Name On Loaded SWF

Jul 14, 2010

Im loading SWFs into my AS3 application. My SWFS are all the same and contain this structure:

root
-item
--color
--overlay

When i load up a SWF file into AS3, This is analogous to the root. So i can say:

[Code]....

I have tried everything i can think of to access this second depth by instance name. Whats wierd is that MovieClip(loadedSWF.item).numChildren returns 2. So Flash knows that theres 2 MovieClips inside of item.... But it just cant reference them by instance name. Since loadedSWF.item works, i assumed that loadedSwf.item.color would work too.

EDIT: I seem to be able to access the MC via getChildAtIndex(0); However this isnt ideal because it create a rule for the designer that he must follow a layering order. Id prefer to do it by name.

View 0 Replies

ActionScript 3.0 :: Accessing A Class From A Loaded SWF?

Nov 23, 2011

In Flash Professional,I drew a shape, converted it to symbol, linked it to class Symbol1 (extends MovieClip) which is generated at run-time, and saved the SWF file as shape.swf.Now my main application wants to load shape.swf and create multiple instances of Symbol1 but I get ReferenceError when trying to access the class Symbol1.Below is my main application's code. Errors thrown are mentioned in comments.


ActionScript Code:
public class MovieClipTest extends Sprite[code].............

View 3 Replies

Actionscript 3.0 :: Accessing Variables Of A Loaded SWF?

Jan 12, 2011

I'm having a SWF call functions from another SWF loaded in the first one with the Loader class. There are no problems as long as the target SWF does not contain any TLF TextFields created on stage by authoring time interface. As soon as I place a dynamic textfield on the stage of the loaded SWF, the main SWF (the loader) fails to call any of the functions within the SWF that is being loaded.Static text does not seem to present problems and neither do TextFields created via ActionScript.Also, is it possible to access variables of the parent SWF?

View 2 Replies







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