Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0

Thread Tools Rate Thread Display Modes
Old 02-18-2005, 02:39 PM   #1
Registered User
Join Date: Feb 2005
Posts: 49
Default Using a String aboslute path to a movieClip to check for mouse over and mouse down

Let's say I have a class Organize which handles my input. So in the main.swf I have action script that calls my Organize:ProcessUserInput() function on each frame. So something like this.

var Org:Organizer = new Organizer("_root.instMain.instSub");

Now the Organizer constructor takes a String paramter. This parameter is an absolute path to an instance of a movieClip on the screen. So looking at the string provided above, I have a movieClip with the instance name 'instMain.' Then I have a sub movieClip to that instance with the instance name 'instSub.' So that makes the absolute path to the sub movieClip '_root.instMain.instSub.' So next, here's my Organizer.as file.

class Organizer{
   private var:String m_pathSubMovieClip;

      this.m_pathSubMovieClip = pathSubMovieClip;

   public function ProcessUserInput():Void{
      //This function will be shown again below after I illustrate
      //the rest of my problem.
So now we finally get to the questioned summarized in the subject of this thread. When you have an absolute path to an object represented as a String, you can use setProperty() to update it. So if I wanted to move the movie passed above to the 10 pixels I could use getProperty and setProperty like so.

var tmpXval:Number = getProperty(this.pathSubMovieClip, _x);
setProperty(this.m_pathSubMovieClip, _x, tmpXval + 10);
So what I want to do is to be able to check and see if the mouse is pressed on my movie clip, if it's not inside my movie clip or if it is released over my movie clip using the absolute path stored as a string that I have in my Organizer class. So here's some pseudo code to show what I'm going for. It's the ProcessUserInput() function;

public function ProcessUserInput():Void{
   if(/*mouse is over this.m_pathSubMovieClip*/){
      if(/*mouse is down*/){
         //do whatever
      //do whatever
So after making a simple question really long, here's my question summarized. I have a movie clips absolute path as a String. I want to use that string to check mouse collision with the movie clip. I can't use onClipEvent or at least I'm not sure how I would do that with only the absolute path as a string. I kind of wrote this up on the fly and all this code is hypothetical so there could be some errors. Please help .

Last edited by canstein; 02-18-2005 at 03:00 PM.
canstein is offline   Reply With Quote
Old 02-18-2005, 05:06 PM   #2
Registered User
Join Date: Feb 2001
Location: vancouver
Posts: 2,219

Why don't you just pass the reference to the movieclip directly, instead of a String (You will need to change the typing of your m_pathSubMovieClip variable from Strng to MovieClip)?

var Org:Organizer = new Organizer(_root.instMain.instSub);

Then you can just hitTest the clip reference against _root._xmouse,_root._ymouse...

deadbeat is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

All times are GMT. The time now is 10:25 PM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.