Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Referring To A Class?



hello,

how do you refer to a class by name? I know how to get the class to do all sorts of stuff from inside the class constructor using the keyword "this". However how do you get the entire class to respond to a button press as the keyword "this" when on a button event handler refers to clip containing the button? right?



Ultrashock Forums > Flash > ActionScript
Posted on: 2003-02-24


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Referring To A Class Dynamically
I need to create a new instance of a class. I have the name of the class stored as a string, but how do I instantiate the class!? I should use the array access i.e.


var className:String = "MyClass";
var myInstance = new myPackage[className]();


but as you can see, I have to hardcode the package name, which in my case doesn't work. Another unclarity regarding the same problem is, wether I can type a variable dynamically i.e.


var className:String = "MyClass";
var myInstance:[className] = new myPackage[className]();


Is there a neat way to solve this dynamic referring, or do I need to start building work-arounds...

Cheers!

Referring From Class To Scene
I have constructed a rough game which is about catching 2 kinds of objects.
An object that increase score, and one that increases your teachers rage(its a game that will be about our school).

My problem lies in makin the Rage-bar, health-bar and score-increase when an object is caught.

If someone has a moment to take a look at it, it would be much appreciated.

I believe my main problem is that i can not refer the class to objects on the scene.

I uploaded the files to make it easier for you to point out my problem
http://www.casperholden.dk/files/flashkit.rar/


Thanks in advance.

Referring From Class To Scene
I have constructed a rough game which is about catching 2 kinds of objects.
An object that increase score, and one that increases your teachers rage(its a game that will be about our school).

My problem lies in makin the Rage-bar, health-bar and score-increase when an object is caught.

If someone has a moment to take a look at it, it would be much appreciated.

I believe my main problem is that i can not refer the class to objects on the scene.

I uploaded the files to make it easier for you to point out my problem
http://www.casperholden.dk/files/flashkit.rar (.rar)
http://www.casperholden.dk/files/flashkit.zip (.zip)


Thanks in advance.

Oop As2 - Component - Problem With Referring Class To Itself
hello, im currently creating a component which calls on an xml file. i want a function from the class to be called once the xml is loaded, but i cant seem to target the function.


Code:
class className {

// variable
var inputXML:XML;

// constructor
public function className () {
this.init ();
}

// initialization
private function init () {
this.inputXML = new XML ();
this.inputXML.ignoreWhite = true;
this.inputXML.load ("xmlfile.xml");
this.inputXML.onLoad = function (success) {
if (success){
this._parent.setContent (this);
}
}
}

// functions
private function setContent (xml:XML) {
trace (xml);
}
}
logic suggests that since inputXML belongs to the class, it's parent should be the class. however, with the onload, it seems that it cannot reach its parent. i even tried without relating to the class (setContent (this) instead of this._parent.setContent (this)) and still doesnt work

what should i look for?

Referring To Sub Mc
Hi

I have this problem. I am trying to refer to a sub movie clip.
The code goes like this.

_root["nodeText"+j].["node"+j]._width = node_size_x;[as]

the path goes like this but i want "j" to save me haveing to type...

_root.nodeText0.node0._witdth = ....
_root.nodeText1.node1._witdth = ....
_root.nodeText2.node2._witdth = ....

Cheers

Referring To Instances Through A Var?
Does anyone know of a way to refer to instances through a variable name?

i.e., if I have created an instance using
(where var_name = "instancename")
duplicateMovieClip(target, var_name, 1);

But now I want to immediately access the movie clip who's instance name is "instancename" (stored in var_name), but I can't just use var_name.text_name, because the AS will look for a movie clip named "var_name".

I want to name a text box "instancename" in the newly constructed movie clip, also called "instancename". So is there a way to do something like this?:

var_name.text_name = var_name;
^
|
|
do something to this so the compiler 'reads' it as "instancename" instead of "var_name"

Thanks.

Greg

When Referring To _levels
Hey there,

If you've set the level for a movie to be loaded onto as '8', when you want to refer to that level, do you say

code:
8.play()


or do you still have to say

code:
_level8.play();


Just wondering.


Thanks

[F8] Referring To Objects
Hi

I have loaded in a symbol with a linkage name of image using attach movie. It loads in fine, but how do I refer to it to to do things like modify its position etc.

Thanks
sand_monkey

Swf And Referring Domain
Is there a way to find the domain of the page that loads my swf. For example, someone embeds an swf served from my server on their www.myspace.com page. Is there is way for me to determine that the request is coming from myspace.com at runtime?

I have the option of using AS 3 if it provides a solution.

Referring To Functions
I have created a button within a movieclip and the following script appears in the button. This movieclip/button combination is added to the Flash game I am creating programatically:

ActionScript Code:
on (press) {
    startDrag(this);
}
on (release) {
    stopDrag();
    if (eval(this._droptarget) == _root.garbage) {
        actions.search_for_coin(this._name);
        this.removeMovieClip();
    }
}
I am trying to refer to a function that resides in a movieClip called "actions" which is at the root level. I can't seem to get to the "search_for_coin" function. What am I doing wrong?

Swf And Referring Domain
Is there a way to find the domain of the page that loads my swf. For example, someone embeds an swf served from my server on their www.myspace.com page. Is there is way for me to determine that the request is coming from myspace.com at runtime?

Referring A Mc Inside A Mc
i have a parentmc and a childmc.
parentmc.onRelease=function(){
trace("parentmc was clicked");
}
parentmc.childmc.onRelease=function(){
trace("the child was clicked");
}
what can i do to make it work?






























Edited: 03/16/2008 at 12:58:38 PM by elic05

Referring To Many Things At Once
Just learning actionscript. (I'm a better programmer than visual artist)
I have a question in 2 parts.
Is it possible to either
refer to all m.c.s at once
or
dynamically (additively) group m.c.s
essentially, I am trying to replicate radiate accretive growth in Flash.

however, I need to add objects dynamically and be able to check the bounds of all objects.

ANy help will be appreciated.

Referring To Different MC's With Variables
What's the syntax to use objects, like a movieclip, with variables that increment. For example:

movieClip_counter_mc._visible = true;

where counter is a variable that changes throughout the script. So sometimes movieClip_1_mc will be visible, and other times movieClip_4_mc will be visible, and so on.

Any help is much appreciated.

Simple ; Referring To Another MC... HELP
Really simple question but I'm really rusty with flash;

I've got this setup; One MC with a text box to load external txt into... another MC ontop with a drop down menu to select the title of what is to be loaded...

Basically ; I need to know how to use the following...


Code:
on (release) {
loadText = new loadVars();
loadText.load("ourartists.txt");
loadText.onLoad = function(success) {
if (success) {
// trace(success);
newsBox.html = true;
newsBox.htmlText = this.plass;
}
};
}
but to load the data into the 'newsBox' on the MC named "CONTENTartists"

I'm sure it's as simple as doing


Code:
CONTENTartists.newsBox.html = true;
or something, but can't for the life of me even remember what this is called so can't even search for an answer!!!

Referring To A Movieclip
Code:
var l = 2;
duplicateMovieClip(button, "button"+l, this.getNextHighestDepth());
"button"+l._x = 300;
The last line of code is faulty... how to fix it ?

Referring To A Mc Inside An Mc
Well, the title really states what I want to know. If you have a Movie clip inside another Movie clip. Can you refer to that one from another movie clip on the screen.
eg.
1. A MC called "Player"
- inside "Player" is another MC called "weapon"

2. Player is placed onto the screen and another MC is placed on the screen called "sword"

3. When the player touches the MC called "sword". The movieclip called "weapon" - gotoAndPlays frame 2 inside it.

Note: I haven't really made a flash like above. It's just an example.

I refer to _root.sword from inside the MC called "weapon" but how can I refer to the MC called "sword" from inside the MC "weapon".
Does it use a file path? eg. _root.Player/weapon?
Does anyone know?

Referring To Many Things At Once
Just learning actionscript. (I'm a better programmer than visual artist)
I have a question in 2 parts.
Is it possible to either
refer to all m.c.s at once
or
dynamically (additively) group m.c.s
essentially, I am trying to replicate radiate accretive growth in Flash.

however, I need to add objects dynamically and be able to check the bounds of all objects.

ANy help will be appreciated.

Referring To Different MC's With Variables
What's the syntax to use objects, like a movieclip, with variables that increment. For example:

movieClip_counter_mc._visible = true;

where counter is a variable that changes throughout the script. So sometimes movieClip_1_mc will be visible, and other times movieClip_4_mc will be visible, and so on.

Any help is much appreciated.

Referring Variables In AS 3.0
Hi,
I'm learning AS 3.0 and little familiar with AS 1.0 and AS 2.0. I'm really confused when i try to refer a variable which I defined in a root layer, frame one inside a movie clip which is coming after the 40 frame.
this is a bit of my code in the root:
Code:

var randomListMsg:String = msgListGroup[xmlListRand(msgListGroup)];
trace (randomListMsg);
and it traces well.
but if I try to trace or put it in a text box inside a movie clip with this code: Code:

text1.msg_txt.text = MovieClip(parent).randomListMsg; // fails
text1.msg_txt.text = parent.randomListMsg;  // fails
trace(stage.randomListMsg);  //fails
trace(MovieClip(parent).randomListMsg);   //fails


Can anybody guide me how to refer it inside a movieclip? and what is the normal referring system in AS 3.0 ?
Thanks in Advance.
Regards.

Referring To Loaded Swf In A Movie
Hi,

I have loaded a swf into a movie clip in my movie using the loadMovie function.

Now I have a button which is in my movie clip and when it is clicked i would like the loaded swf to movie to frame 50, for example.

If have tried: (empty is the empty movie clip i loaded the swf into)

with ("../empty") {
gotoAndPlay (50);
}

but it doesnt do anything.

What would be the correct actionscript for this?

Referring To Time In Actionscript
I need to refer to time in actionscript

basically

I have defined variables for the currenthour and currentmin

I want to say basically

if (time = x) {loadmovie1}
else if (time = y) {loadmovie2}

etc.

the times have both an hour and minute property...

eg. it will be if the time is from 5:30 - 7:30 then x

i know this is hard...

but you guys can do it

Referring To The Last Element Of An Array
I want to refer to the last Element of an Array

Is there another syntax then:
existingCells[existingCells.length-1]

Like a special word:
existingCells[last]

Or something...

Referring To Main Timeline Within Mc?
(Flash MX)

Is there a way to refer to the main timeline from within a Movie Clip? Like find out what the current frame of the main timeline is from inside an MC?

Referring To AttachMovie During Movie
Hi, please help!

I have two script-holding MCs outside the stage. One uses an "attachMovieClip" command to give my MC named "hero" an instance name of "kevin" and places it on level "0".

I am trying to make a script in the second off-stage MC that lets me control "kevin" with arrow keys, but I can't seem to get it to work. My question is, how should I be referring to the MC that was loaded from the first off-stage MC?

Thanks, I hope this is clear.
-KEvin

Referring To Cilps Using Variables
can I refrence a clip using a variable, say..

load of clips created using duplicate

made each one called clip1, clip2, -- clip100...

obviously its easier to refer to them as
{
"cilp"+i;
i++;
}(while i < 101);

Certainly this is how they are created but is this a way of reffering to them, e.g if i wanted to change clip number x's _alpha value can I do this...

x = 4
repeat{
"clip"+x._alpha = 100;
x ++}
(while x <9)


If not can I put them in an array as refrences to movieclips?

Anyhelp much appreciated.

Variable For Referring Domain
Hi all. I know this is a property for this in Java, but is there a Flash variable that captures the referring domain a visitor is coming from, i.e. www.google.com?

Your help is greatly appreciated.

Referring To A Target Using A Variable
Hi Folks,

Basically this is the script in a button to open various text windows. What I want to do is refer to a specific movie clip using 'tell target' or 'with' but to improve the efficiency of the script I want to be able to refer to it using a variable. ie. to refer to _root.open1, _root.open2, _root.open3 etc.

As you can see I have declared the global variable showingtarget. This definitely works because I can display it in a text field. The problem comes in line 9 where I want to refer to a target using the showingtarget variable I have created.

I'm sure this must be really straightforward but it's totally got me! Please help!

on (release) {
var destination = "1";
showingtarget = "_root.open"+showing;
if (showing != "destination") {
with (_root.open1) {
gotoAndPlay(5);
}
if (showing == 2) {
with (showingtarget) {
gotoAndPlay(20);
}
}
}
showing = "1";
}
.....................................

This code works fine (ie. when the 'with' (line 9) refers to a definite target). In my example there are 2 buttons. This is the code from button one, button 2 is just the reverse. ie. 2s are 1s and 1s are 2s.

on (release) {
var destination = "1";
showingtarget = "_root.open"+showing;
if (showing != "destination") {
with (_root.open1) {
gotoAndPlay(5);
}
if (showing == 2) {
with (_root.open2) {
gotoAndPlay(20);
}
}
}
showing = "1";
}
.....................................

Thanks,
Doug
Scotland

Referring To Dynamically Created Mc's
Hi,
I have the following code:

code:
for (i=1; i<50; i++) {
duplicateMovieClip(gLetter_mc, "gLetter_mc" + i, i);
["gLetter_mc" + i]_x = (Math.random() * 400);
duplicateMovieClip(aLetter_mc, "aLetter_mc" + i, 50+i);
["aLetter_mc" + i]_x = (Math.random() * 400);
}


I know it is not worded right, as it returns an error. How exactly should I refer to a dynamically created movie clip in order to change it's _x position?

TIA,
aaroneousmonk

Variables Referring To Timeline
I'm trying to set up a script to refer to an element on the timeline using variables set through function arguments, like this:


Code:
btnName = [sub]+"_"+[num];
menuName = [main]+"Menu";
_parent.menuName.btnName.up.gotoAndPlay("clicked");
This reference does not work properly, but when I replace the variables with the actual mc names, it works just as it should. Ex:


Code:
_parent.designMenu.andi_1.up.gotoAndPlay("clicked");
I traced both btnName and menuName and they come out just as they should.

Why am I having this problem?

Referring To A Dynamically Name Movieclip ?
Hi there

I'm trying to refer to a dynamically named movieclip within a dynamically named movieclip.

Does anyone know how to do this?

_root["mc"+(counter1)].mc2 = "testing"; works as i'm only referencing through one dynamically named movieclip. But for two, i'm getting an error.

here's my code so far:

_root["mc"+(counter1)].["mc2"+(counter2)] = "testing";

This obviously is creating an error... any suggestions?

Thanks

Referring To Dynamic Instances
ok, here's the problem - i'm creating a bunch of empty movie clips, based on a random number (let's say 5-10). The movie clips themselves will be names "attach"+(the random number) (i.e., "attach05")

how can i refer to it later to manipulate it's properties? I can't type

"attach"+randNum._x = 150

and saying

this._x = 150

seems confusing. Maybe it's the only way, but all i know is that replacing all of the "attach"s in my script to "this" just mussed things up further.

Referring To Variables Dynamically
Hi

I'm just starting out with action script so forgive me if any of this is obvious.

I am currently working on a simple logic puzzle involving a punch card.

Currently I have a graphic for the card which contains six buttons, for the punch holes.

What I want to do is have a pre set combination of punches which will solve the puzzle.

To this end I have created six variables for the current status (punched or unpunched) of each button, and six varriables containing the correct status of each button.

here is the solution I have been working on

code:

function punch (buttonNo) {
trace ("hole " + buttonNo + "was punched");
if ("punch" + buttonNo + "Status" == true) {
set("punch" + buttonNo + "Status", false);
} else {
set("punch" + buttonNo + "Status", true);
}
}



as you can see what I have done is to define a function which simply coverts between true and false, the problem being the way i reference my varriables.

The status variables are named punch1Status thru punch6Status, so in my function's 'if' and 'else' statments, I have attempted to reference them dynamically by cocatenating the buttonNo (a property which contains the number of the button punched) with the text elements from my varriable name.

This method seems to work when using the set() function but what I need is away of using this dynamic reference format without altering the value of the varriable.

Being a begginner I would appreciate any feedback, please let me know if I'm going about this completely the wrong way.

Many thanks in advance

P.S.

As I write it has just occurred to me that it would make sense if there was an operator which would simply convert between true and false, can anyone tell me what that operator might be?

Referring To MovieClip Instance With A Var
How do I refer to a movieClip instance with a Variable in the name.

For Example if I

Code:
var i = 1;
duplicateMovieClip("box", "box" + i, i);
how do i reference the new "box" + i instance with gotoAndPlay?

"box" + i.gotoAndPlay("frame");
doesn't work

var instanceName = "box" + i;
instanceName.gotoAndPlay("frame");
doesn't work.

what is the proper syntax to reference the clip for gotoAndPlay?

Thanks.

Embedded Swf Referring To _root
Hello there,
I have created a photo slideshow to be used on a website I am building. This slideshow contains actionscript referring to the root, as in the example:

loadMovie("welcome.swf", _root.DisplayAreaIN);
//
_root.DisplayAreaIN._alpha = 100;
_root.CounterNumber = 0;

FadeOut = false;
Display = false;
FadeIn = false;
}

Once exported, this works as a standalone swf, but when I call this swf from my homepage only the first picture is being displayed and the navigation system of the photoalbum does not appear. I guess this might have to come from the fact that it refers to a root but I am stuck here.

Does anyone have an idea of how I could solve this?

many thanks in advance

LO

Instancing / Referring To A MC Not Currently On The Stage
Hi all, how do you give an instance name to a movie clip that is not currently on the stage?

I'm exporting my movieclips for ationscript linkage and i would like to have this particular MC invisible until triggered by a mouse event. - But as there is no physical reference to it on the stage, i don't know how to give it an instance name, and without this i can't get the paths correct for toggling _visible true and false.

Thanks!

Problem With Referring To The Right Object
I want to call another function in my class Buttons.as. However using the event handler, tween.onMotionFinished, associates all "this" and parent child relationships to the tween class. So the program doesn't excecute line 11 properly



Code:
01 class Buttons {
02
03 var mC:MovieClip;
04
05 function Buttons(mC:MovieClip) {
06 this.mC = mC;
07 }
08 function firstFunction() {
09 tween = new mx.transitions.Tween(mC, ...);
10 tween.onMotionFinished = function() {
11 nextFunction();
12 }
13 }
14 function nextFunction() {
15 //never gets here
16 }
17 }
after trying "this.nextFunction();" and "trace(this);" I found that within the event handler the program looks for the function, nextFunction, within the tween class, not Buttons.

The only way I can get the code to work is to use "_root.nameOfButtonInstance.nextFunction();"


Code:
/*********** in frame 1 of the main timeline ***********/
import Buttons.as

myButton = new Buttons(buttonMovieClip);
//buttonMovieClip is a movieclip of the button so it can be tweened

_____________________________________________________________________

/*********** In Button.as **********/
... //same as above
function firstFunction() {
tween = new mx.transitions.Tween(mC, ...);
tween.onMotionFinished = function() {
_root.myButton.nextFunction();
}
}
function nextFunction() {
//now it gets here
}
the same is true if I try to create a new tween, after another tween is finished.


Code:
function firstFunction() {
tween = new mx.transitions.Tween(mC, ...);
tween.onMotionFinished = function() {
tween = new mx.transitions.Tween(mC,...);
//now the program cannot find "mC"
}
}
I'm looking for a more general way, for going to _level0 (_root) and working my way down is to specific, if I create many Buttons.


thanks

Trouble Referring To MovieClip Using This
I've created a bunch of movieclips on the stage, using a for loop. They all contain different text which all works fine.
I later - in a different function - want to refer to each individual movieclip in order to change that text, however it doesn't seem to work. The text remains the same.
The relevant (I hope) parts look something like this:



ActionScript Code:
function stacks() {
for (var m:Number = 0; m<Tcounter; m++) {
this.attachMovie("bubble_mc", "bubble_mc"+m, m+10);
//the bubbles get nicely positioned here   
this["bubble_mc"+m].content_txt.text = Tstack_array[m];
changeText();
}

function changeText(){
for (var z:Number = 0; z<Tcounter; z++) {
trace("text should now change");
this["bubble_mc"+z].content_txt.text = "whatever";
}

Any ideas?
Many thanks in advance!

Referring To An Instance Using A Variable
I'm drawing a blank on this seemingly simple question.

I have about 20 unique items on the screen, and need to change their blendMode like this:

this.bb03.blendMode = "invert";

The instance names are bb01 to bb20. Nothing fancy. Calling each individually as above works fine.

I need to change the blendMode based on a current variable (essentially a counter, call it x).

How do I refer to the instance using a variable? Something like:

theInstance = "bb" + x; //I'm ignoring the initial zero, that's easy
this.theInstance.blendMode = "invert";

I know I can do a slew of if's like this:

if (x==1) {this.bb01.blendMode = "invert";}
if (x==2) {this.bb02.blendMode = "invert";}
etc. But I suspect there's a far more appropriate answer.

This is CS2 Pro.

Help appreciated. Thanks!

Referring To A Swf In A Movieclip Holder
Hi,

I have created a Movie Clip Loader and loaded a swf movie into in called 'gallery.swf' using the code below.

myMCL.loadClip("gallery.swf", 5);

Within the gallery.swf I have a movie clip called 'contact_mc'

From my original file I want to refer to the 'contact_mc' in the gallery.swf, but I can't get the coding right? Can anyone help?

I tried......
myMCL.contact_mc.enabled = false;

thanks in advance

TIm

Ps I am using Flash 8

Dynamically Referring To Clips?
Okay! I'm having a thing where there are multiple clips generated with duplicateMC, that are all named circles1,circles2, etc. Then, I am using another for statement to try to referr to the circles in a hitTest. How would I do this?
(x is the for variable)
hitTest("circles"+x.toString())
that won't work

So how is it done?

Referring To Movieclip In Button
hi,

i was using this function


Code:
this.onEnterFrame = function() {
if (picture._alpha>50) {
picture._alpha -= 10;
}
};
for a movieclip on the parent level, and it was working fine.

However i need this movieclip to be in a button.

What do i have to change in the coding for that to work?

thanks!

Referring To Instances Using A Variable
I want to be able to edit an instances properties using a variable not the instance name, for example:

instead of...
_root.instance_mc._alpha = 100;

I would like to use...
variable_name._alpha = 100; // like in javascript

I tried setting the variable to the instance name..
variable = _root.instance_mc;

...but that didn't work.

Any ideas? I have a flash book and nowhere did they talk about this being done. It would make my life a whole lot easier.

Thanks,
Trey

Referring To A Button That Is Not In The Same Scene.
Hello everyone.

Im new to actionscript and I have been all day trying to find my way through a particular issue. Now I need someones help because I am going round in circles without achieving anything.



This is my scenario

Layer : actions (attaches a scrollbar and a mask to the textfield at the bottom)

layer : movieclip - layer : Buttons. (Some animations here with buttons)

layer : mask (mask for the textfield)

layer : movieclip - layer: text field
--------------------- layer:actions (here I want to refer to them buttons in order to make links into some external text files but I can't simply with an instance name)

Help would be really appreciated.

Thank you all!

Syntax For Referring To MovieClip
I'm not getting this quite right - I need to check and see if the last item in the loop "termSprite_7" has its visibility turned off. If so, an animation can start:


Code:
var lastItemNumber = Glossary.glossaryArr.length - 1;

glossarySprites = new Sprite;
for (var i:int=0; i < Glossary.glossaryArr.length; i++) {
var term:String = Glossary.glossaryArr[i].term;
var termSprite:MovieClip = new MovieClip;
var termTextField:TextField = createText(term,linkFormat,termSprite,0,0,275);
termSprite.name = "termSprite_" + i;
termSprite.x = 50;
termSprite.y = 57 + i * 23;
termSprite.itemNum = i;
termSprite.addEventListener(MouseEvent.CLICK,clickAnswer);
termSprite.addEventListener(MouseEvent.ROLL_OVER,termRollOver);
termSprite.addEventListener(MouseEvent.ROLL_OUT,termRollOut);
termSprite.buttonMode = true;

termSprite.visible = false;// Set visibility to false for animation
glossarySprites.addChild(termSprite);
// If last item is now invisible, start animation
if (MovieClip(getChildByName("termSprite_" + lastItemNumber)).visible == false) {
trace("Yes");
init();
}
}
addChild(glossarySprites);
The IF conditional is never reached so my syntax is wrong. Anyone see the problem?

AS3: Referring To A Button In A Different Scenario.
Hello everyone.

Im new to actionscript and I have been all day trying to find my way through a particular issue. Now I need someones help because I am going round in circles without achieving anything.



This is my scenario

Layer : actions (attaches a scrollbar and a mask to the textfield at the bottom)

layer : movieclip - layer : Buttons. (Some animations here with buttons)

layer : mask (mask for the textfield)

layer : movieclip - layer: text field
--------------------- layer:actions (here I want to refer to them buttons in order to make links into some external text files but I can't simply with an instance name)

Help would be really appreciated.

Thank you all!

Referring To Clip In Loop
I'm trying to perform hitTest on multiple clips using a loop, problem is I'm having trouble properly referring to the clip making contact.

This is what I have:


ActionScript Code:
for (var i=1; i<9; i++) {
if(_root["mc"+i].hitTest(this._x, this._y, true)) {
this.doSomething;
}
}


This seems to work just fine when I want to control the clip this is attached to. What I want to do is get the other clip to do something as well, but I know I can't refer to the clip like:


ActionScript Code:
_root["mc"+i].doSomething;


So, how would I refer to the clip?

Referring To Instance Name As String
Before I go into the longwinded version in words, here's what I'm trying to do:

say one instance of multiple mc's is named "main1";
is there a way to script a btn inside of said mc to say something like

on (release){
_root.loadMovie("<<DynamicallyGeneratedNameHere>>.jpg", "emptyClip_mc");
}

where the string inside the carrots, for this example, would be "main1", and of course for all the others would refer to their own mc's instance name ("main2", "main3", etc.)

So now for the longwinded version (if it's even necessary to understand where I'm coming from): I need to have all of my buttons' contents be editable in one fell swwop (and the scripts as well), so the actual scripts will all be the same since all the buttons will be multiple instances of symbols. I would like to make the script within the symbol dynamically refer to different movies (or jpgs) to load. The only way to make that happen would be to use the individual instance names of the buttons in the reference to individual movies. Am I clear? Thanks for any help you may be able to offer

[as2]referring To Instances In .as File
Hi people,
I'll try to explain this clearly. I'm creating a new class that extends MovieClip. It is a clickable item that will be used over and over again. This item has a couple of flags: on to show if the item is locked, and another to show if there are comments associated with the item.

Here's what I've typed into the external .as file:
ActionScript Code:
function set locked(l:Boolean):Void {
        ilocked = l;
        lockFlag._visible = ilocked;
    }
    function get locked():Boolean {
        return ilocked;
    }
    function set notes(n:Boolean):Void {
        inotes = n;
        noteFlag._visible = inotes;
    }
    function get notes():Boolean {
        return inotes;
    }

I want the movieclip instances "lockFlag" and "noteFlag" to be visible if these variables are set to true. I'm sure it's not a good idea to refer to instances from within a class definition, but I'm not sure how else to do it. I keep getting this error:

**Error** GRAPHICS:Sources:_Lessons:_Lesson_Builder:PageItemBTN.as: Line 48: There is no property with the name 'lockFlag'.
lockFlag._visible = ilocked;

**Error** GRAPHICS:Sources:_Lessons:_Lesson_Builder:PageItemBTN.as: Line 55: There is no property with the name 'noteFlag'.
noteFlag._visible = inotes;

I want to avoid having the movieclip check for these variables all the time.

Any ideas?

Thanks.

Copyright © 2005-08 www.BigResource.com, All rights reserved