Simple Referencing Problem
Having a problem getting data to display in my dynamic text fields. have a movieclip and onRollOver it laods a movie clip to the stage which has the dynamic text fields in it. but at the moment it just displays: _level0.popout1.add1 However if i put the movieclip on the stage and give it the same instance name ("popout") it then displays the values and not the above. At the moment it has been assigned an identifier of "popout" in the library. Can anyone explain why?
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 06-14-2007, 08:43 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Referencing Buttons (simple)
I feel like chump at the moment... you guys are the only ones i can turn to for a quick answer.
All i need to know is how to referrence buttons and assign actions to them. I don't want to put the code directly on the button instance, but rather referrence the button from an actions layer.
Here is what I had.
HTML Code:
DRW.onRelease=function() { trace ("Hello")}
DRW is the instance name of the button.
Eek!
Simple Question About Referencing Forms
I have what I hope is a simple question. Could someone please provide a primer on how to reference forms (and things contained in forms) in AS2? Specifically, I am having trouble referencing a form loaded into another form. Here is my form structure:
Application
Form1
Form2
Loaded into Form1 is an swf containing another set of forms, with this structure:
NewApplication
NewForm1
NewForm2
So, how do I reference NewForm1 from Application and vice versa?
Thanks.
-Brian
Simple StartDrag() Referencing Problem?
Ok, this is simple stuff, I'm pretty sure I'm just being a complete nonce here but I just cant work it out....
Pretty simple, I have a function that's called from one point in the movie (I put a trace in this function so it is being called correctly). This function amongst other thing contains a startDrag() for a button. This button, when you click it, is what calls the function and also is the button that I want to make draggable.
The setup is like this:
_root -> MC1 -> MC2 -> button
So _root has in it MC1 which has in it MC2 which in turn has in it the button. the function code is on the _root timeline, and is called when you click the button and the button is also the subject of the startDrag() content of the function.
I use a with() command in the function to save a bit of code, in this case:
with(MC1.MC2){}
The startDrag() command in this with command this is then set like this:
button.startDrag(false, var, ious, para, meters);
Pretty straightforward huh? The problem is the button just wont drag! I cannot for the life of me work out why, its starting to drive me round the bend! I have also tried the old way of referencing:
startDrag("button", false, var, ious, para, meters); and also
startDrag(button, false, var, ious, para, meters);
I have also traced the boundary parameters to make sure they are right and even taken them away completely to no affect. My conclusion is I must be referencing the button incorrectly, but to me the code all looks good, can anyone else spot anything?
What Is The Simple Equivalent For Referencing The _root Timeline?
I've got a .swf (movie B) that gets loaded into a clip in my main movie(movie A). Movie B needs to control another clip within movie A.
In AS2, i would simply start off with a _global var on the main _root timeline, like this:
_global.home=this;
then, later in my seconday movie (movie B) i would reference that timeline simply like: home.myClip.gotoAndStop("whatever");
What is the simple equivalent for referencing the _root timeline? I've tried _parent with no results.
I'm looking forward to utilizing classes more, but for now I've got timeline code (on a single frame at least), with aspirations of moving toward a 'class-based' development style.
thanks for any help!
Simple Problem - Referencing Objects By Variable Name
I have a simple function that dynamically creates text fields. My text field name is referenced by var thisTextField. Problem is, when i try to do things with my text field, actionscript shoots back an error as such:
There is no property with the name 'text'.
How am i supposed to apply properties to my object if my objects name is a variable?
Code:
function showProducts() {
var products:Number = 0;
var thisTextField:String = "product" + products + "_txt";
for (var itemID in _global.rtsData[_global.rtsPos]["products"]) {
this.createTextField(thisTextField,1,25,75,350,50);
trace(thisTextField);
thisTextField.autoSize = true;
product+products+_txt.text = _global.rtsData[_global.rtsPos]["products"][itemID]["products_name"];
products++;
}
_root.products_mc.gotoAndPlay("fadeIn");
}
Simple Problem - Referencing Object Array Properties
Sure this is dead straightforward. My flash creates a bunch of objects with x and y properties. These all get pushed into an array and then my .NET aspx page gets the array as an argument. This seems to be an ArrayList (although the documentation seemed to say it would be a HashTable) of ASObjects. How do I then refereence the x and y properties of the ASObject - is this what is now referred to as a Key?
Referencing DLL's
Is there a way to reference a DLL from actionscript? If so, can you use ADO to connect to a MSSQL Server DB through actionscript? If anyone has any sample code please post it in a reply.
Thanks
Mo Referencing
Hi, I have a series of movie clips on the main stage called, t1,t2,t3 etc.
Each has the stop action on it's first frame.. so I want the following code to make a random one play..
i = random(15);
eval("_root.t"+i+".gotoAndPlay(2)");
I know the second line is not working but can't work out why..it doesn't need another part to the equation or anything does it?
Thanks
Referencing
Hi,
I have a scrollpane (from the component menu) which is supposed to scroll through a movie clip (called roller_icons) that consists of several icons. the scrollpane is in a movie called build. This movie has several frames: general, wind and solar. I have put a stop() in the first frame of general, which is frame 1. I would like the movie to play the wind frame when a specific button is pressed. So, in that button, I put:
on (rollOver) {
this.gotoAndStop("over");
}
on (rollOut) {
this.gotoAndStop("up");
}
on (press) {
this.gotoAndStop("down");
_parent._parent.gotoAndStop("wind");
}
I am not sure why i am not able to get into the wind frame at all. What am I doing wrong? PLS HELP!
Referencing Different .txt's
So-- I have(thanks to the tutorials) a new dynamic text box. However, the Flash site I'm making is going to have to refer to several different texts in order to be functional. For example, I have a box with a .txt in it. The user clicks on a section and the textbox(which can go to a different scene or whatever, doesn't matter) switches to the other .txt file. So... I gave a shot at changing the "news.txt" expression in the script to a variable. An example with 'gist' of the code:
on event(load){
loadVariables(contentFile);
And then I'd put the code in the corresponding buttons:
on MouseEvent...
gotoAndStop("other scene");
contentFile=("otherpage.txt")
First problem I discovered was that the instances don't like me changing their actions independently. When I changed one, the others would apply the same changes. I'm pretty sure I'm not editing the symbol. The other problem is that I'm not sure the link button is the best place to initialize a variable. I may have to do it in the preloader. Of course, I'm pulling all these theories out of my ass; you guys would know the logic behind it better than I would. I'm using Flash 5, by the way.
MC Not Referencing
Code:
L1_goto = function (currentSection) {
trace(currentSection);
_root.mainNav.currentSection.gotoAndPlay("Hover");
};
L1_goto("L1_1");
I made a function which takes "currentSection" as the argument.
The gotoAndPlay part doesn't work. The "L1_1" clip is not playing.
Var Referencing
Say, on the stage, I have code that creates thumbnails from a loop, which takes a container clip from the library and then that preloads an image. I'm thinking of having those containers each add the the stage it's bytesTotal and bytesLoaded so that I know the percent of all the total thumbnails loaded.
So I was thinking I would reference a var on the stage from the container. So when I create the container I would say:
container.refVar=thisVar;
so then in the container I could just say refVar+=image.bytesLoaded and then that would change thisVar on the stage, so that all thumbnails could add to it.
If that makes sense, does anyone know how to do that?
[CS3] Referencing A MC
I have a bunch of MCs on the stage (not placed dynamically) with names like "branch123_mc", "branch395_mc", "branch412_mc", etc. Each follows the format:
branch+some 3-digit number+_mc
Those three digit numbers are all held as sub-sections called "branch" within an array called "totals"...
Using AS2.0, I want to go through each item in the totals array, and grab that item's 3-digit branch number, then I want to reference each MC with a "onRollOver" function. Here's what I have that isn't working (but should give you an idea of what I'm trying to do):
Code:
for (var i:Number = 0; i < totals.length; i++) {
var thisClip:MovieClip = ("branch" + totals[i].branch + "_mc");
thisClip.onRollOver = function() {
doSomething();
}
}
That syntax isn't working at all. "totals[i].branch" traces out acurrate numbers, so that's not the problem. Can anyone help?...
Referencing A MC...
I have a bunch of MCs on the stage (not placed dynamically) with names like "branch123_mc", "branch395_mc", "branch412_mc", etc. Each follows the format:
branch+some 3-digit number+_mc
Those three digit numbers are all held as sub-sections called "branch" within an array called "totals"...
Using AS2.0, I want to go through each item in the totals array, and grab that item's 3-digit branch number, then I want to reference each MC with a "onRollOver" function. The code below is what I have that isn't working (but should give you an idea of what I'm trying to do):
for (var j:Number = 0; j < totals.length; j++) {
var thisClip:MovieClip = ("branch" + totals[j].branch + "_mc");
thisClip.onRollOver = function() {
doSomething();
}
}
That syntax isn't working at all. "totals[j].branch" traces out accurate numbers, so that's not the problem. Can anyone help?...
Referencing An .mc
HI
i have a main timeline with an .mc. named ztop.mc
on this main timeline i have another .mc named mainContent_mc inside which i have placed some actions.
im not sure how to correctly call them. im trying to make each .mc interact or animate with eachother but i cant even corectly measure or work with them (the ztop.mc appears at one position on the stage and correctly alligned, but when i test it, the same ztop.mc is maybe 30-80px off position.
i have included the .fla so you might see, but really maybe need tute to show me the way, if only i knew what the name of the tute might be ....so does anyone know what it is i need to understand cos im up against it now.
-dj
(for anyone who checks the .fla : i want to animate the ztop / zbot .mcs across the mainContent_mc, but at the moment cant do it)
[] Referencing
I'm doing some work which involves square grids.
I've used sprites to display the individual squares.
Now my question is how can i refer to the sprites like we used to refer to movieclips in AS2 like following?
this['block_'+j]For time beging, i'm just pushing all the square boxed into an array to refer them by array index.
Referencing
Hi There,
I have odd problem here
I´m not able to reference property "prop" in class Level.
FLA file:
Code:
var mainLogic:Level = new Level();
Level.as:
Code:
package {
import flash.display.Sprite;
public class Level extends Sprite {
public var prop:int = 5;
public function Level():void {
var h:Tetris_Shape = new Tetris_Shape();
}
}
}
Tetris_Shape.as:
Code:
package {
import flash.display.MovieClip;
public class Tetris_Shape extends MovieClip {
public function Tetris_Shape():void {
trace(parent.prop);
}
}
}
I don´t know why, but it throws error 1119.....
1119: Access of possibly undefined property prop through a reference with static type flash.displayisplayObjectContainer.
Thank you for your responses.
Referencing A MC
Does actionscript only need the instance name to use as a reference, or does it also need the name of the movie clip in the library form which it originated?
EX.
MC Movie Clip1
Movie Instance name of MC
MC1 Movie Clip2
Movie Instance name of MC1
Does actionscript differentiate the differnce between the instance name Movie created from MC or MC1 ?
MC Referencing
Hi,
I want to load small thumbnails in my project, and each thumbnail presents a button. When I click on thumbnail bigger picture should show.
I put information about picture in each thumbnail movie clip but when I click on thumbnail flash can’t see that information?
Here is a small example what I’m trying to do. (mxTxt is information which I’m trying to catch).
Make three smal pictures named Picture1.jpg, Picture2.jpg, Picture3.jpg.
Please help.
Cheers
Code:
var caption:Array = new Array();
var path:Array = new Array();
caption[0] = "One";
caption[1] = "Two";
caption[2] = "Three";
path[0] = "Picture1.jpg";
path[1] = "Picture2.jpg";
path[2] = "Picture3.jpg";
showThumbnails(caption, path);
function showThumbnails(caption:Array, path:Array):Void
{
var t:MovieClip = _root.createEmptyMovieClip("thumbnails_mc", 1);
var picNumber:Number = caption.length;
t._x = 10;
t._y = -10;
for (var i=0; i<picNumber; i++)
{
var thumbnail:MovieClip = t.createEmptyMovieClip("Thumbnail" + i, i);
thumbnail.myTxt = caption[i];
thumbnail._y = (i+1)*45;
loadThumbnail(thumbnail, path[i]);
}
}
function loadThumbnail(targetMC:MovieClip, path:String):Void
{
trace("Here he can se myTxt: " + targetMC.myTxt);
var mcLoader:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();
listener.onLoadInit = function(target:MovieClip):Void
{
target.onRelease = _onReleaseThumbnail;
}
mcLoader.addListener(listener);
mcLoader.loadClip(path, targetMC);
}
function _onReleaseThumbnail()
{
trace(this._name);
trace("OnRelease he doesn't see myTxt: " + this.myTxt);
}
OOP Referencing Question
To practice OOP in Flash 5, I would like to write a program that creates a large number of objects/movie clips, that do something simple, like follow the mouse around the screen.
I have written code to create an array that contains references to the objects I create. This works fine. The objects are created, they have variables that retain their state, and they have methods that I can call to act on the objects. For example calling the prototype function
"myArray[2].coords();" works fine.
But when I try to change the property of the movie clip, say the _x property, I have to reference the clip by name. In my code I am referencing the movie clip by name, ie "clip0", "clip1" and "clip2". But I need the object to be smart enough to reference itself so that I can tell it to move *ITSELF* around the screen.
in my code:
_root.clip0._x = this.xLoc;
but it needs to be something like
_root.this.clipID._x = this.xLoc;
or
_root.eval("this.clipID")._x = this.xLoc;
Any ideas? Am I going about this the wrong way? The manuals do not offer a lot of advice in this department.
----------------------
my object constructor
----------------------
function myObject (x, y, clipID) {
this.xLoc = x;
this.yLoc = y;
this.clipID = clipID;
_root.attachMovie("ball movie clip", clipID, 1);
_root.clip0._x = this.xLoc; // works but WRONG!
_root.clip0._y = this.yLoc; // works but not self referencing!
}
myObject.prototype.coords = function () {
trace (this.xLoc + " "+ this.yLoc + " " + this.clipID);
}
Referencing A Variable
Hi,
I'm having trouble referencing a variable. I have a movie clip containing another two movie clips and I need to set the width of one of the movie clips equal to the length of a text variable (to create a dynamic shadow) so I'm using this code:
onClipEvent (load) {
this._xscale=../text.length*50;
}
but this doesn't work, how do I move up the heirachy one movie clip before drilling down into it?
Thanks
Referencing Functions
how do i reference a function from within a movie?
i have a function on my main timeline and I'd like for it to be global, but I can't call it from within any movies successfully. If i copy the function within the movie and call it, it works fine.
Thanks.
Referencing Mc Within A Button
can you reference a ovie clip within a button
if i name an instance of a movie clip to "mymovie" and place it in root- I can control is via _root.mymovie etc
however ig that mvoie is not in root but in the first frame of a button (and you dont seem to be able to name an instance of a button) then how can you referende the movie?
Thanks in advance
A Pem Referencing A Variable
The following line in my code works just fine:
k = _root.answer4.substr(1,4)
The problem is, the number "4" is a variable that is generated using the following code:
_parent._name.substr(1, 1)
I can't find a way to use this code in the "k =" line so that it works. I have tried:
k = eval("_root.answer" + _parent._name.substr(1, 1) + ".substr(1,4)")
but of course, "eval" doesn't work the same way in Actionscript as it does in Javascript.
Anybody know how to make this work?
MC Referencing W/ DuplicateMovieClip
When I address dynamic duplicate movies, this is how I do it using Flash5 notation:
_root.myclip["mc"+x]._y=ypos;
Obviously, I'm referencing from the root and the movieclip where the duplicating takes place. What I need to know is, how do you reference the clip on the same timeline inside the mc where the target mc is located? I tried this:
["mc"+x]._y=ypos;
but that doesn't seem to work. What is the correct way to address this clip? In Flash4, I've seen examples that use this:
setProperty(eval("mc"), _y, ypos);
but I began learning Flash in v5, so I don't want to start doing it this way (or is this the only way?)
Any help would be great!
Chris
Variable Referencing?
ok i have numerous mc and in each mc it has the same variable so my question is how do i change that variable in each mc the variable is "k" so how would i label that in other words how would i specify in each change in each variable-- and in each mc i want to change the variable to be different in every one
any help is greatly appreciated
***REFERENCING ARRAYS***
Once again I'm trying to apply C++ practices to ActionScript. I'm trying to create a variable that references an array. For example:
(root)
myArray = new Array("a","b","c");
(inside a movieClip placed on the root)
refernceToMyArray = _root.myArray;
The reason I'm trying to do this is because I have a function on the root that requires an Array. However, the function is being called by a movieClip on the root. One of the properties (set as a variable in the first frame) is parentArray. The variable refers to the myArray as shown above. In C++ referncing an array is quite simple using the & when creating the variable. This tells the compiler that the information stored in this variable is the address to a memory block not a value. And this is what I am ultimately trying to achive.
Referencing A Button Name
Question from a bewildered newbie--
How do you retrieve at run-time the name of the button instance that's currently being pressed by the user? I originally thought about using "this._name" in the code associated with the release event handler for the said button. But when I traced this._name, it always returned an empty string. According to the Flash help documentation, "inside an on event handler action attached to a button, 'this' refers to the Timeline that contains the button," rather than the button itself. So how do you refer to the button itself, if not using "this"?
Referencing Movieclip
I need to set the width and hieght of a movie clip "pic".
I want "pic"
width = 340
height =170
Questions
1) What are my options to do this.
2) "pic" displays dynamically loaded .jpgs from a .txt file. How could I make the image enlarge to the following sizes when "pic" is pressed?
width = 460
height = 360
Referencing Problem
I've got a bit of a referencing problem, _root.etc.etc thingy.
I've got my main swf, which has a preloader for loading external swf's. in the main swf i have a 'cover' mc with a 'loading' mc in it. When you select an item from the menu it loads an external swf, the first frame in the external swf tells _root.cover.loading to go to the frame determined by the percentage loaded.
Now that all works fine, however, in the external swf's, i may have a button to load another swf, in the 1st frame of this 2nd external swf everything is the same.
But the preloader bit doesn't work, it doesn't show how much has loaded, so obviously it's a problem referencing _root.cover.loading.
I've been trying everything for the last day or so and got nowhere.
http://roycegraciesheffield.com/help.zip
that contains the main.swf, the 1st external swf loaded, and then the 2nd external swf.
Hopefully you can follow it and know what's going on.
Look in the actions for the button over the Gallery menu option in the main swf, then the actions in the button over the red link in the gallery.swf file to see how it's working.
Thanks for any help!
Robsco!
Referencing In MX2004
heya guys, hope someone can help me here, my jobs on the line!
I have a movie clip that needs to reference the main timeline to then jump to a specific scene.
what is the basic code??
i have been using _root.gotoAndPlay ("sceneName", 1) as it just doesnt work
please please can someone help me???
big thanks for anyone who can :>
ross!
Scene Referencing
Hi All,
I have a movie with 2 scenes. On the first (Menu) is a button with action to open the second scene (MovieScreen), then I want it to load a flv file into the movie component (myPlayer). At the momement when clicking the button the scenond scene appears but the movie does notload into the component. The component is not the problem as if the line to load it is on the same page the movie loads and plays.
This Works on a single scene
on (release) {
myPlayer.loadVideo("../movies/womenatwar.flv");
}
This does not work when I put the movie component on a separate screen
on (release) {
gotoAndStop("MovieScreen",1);
MovieScreen.myPlayer.loadVideo("../movies/womenatwar.flv");
}
Its probably something stupid I have done as I am just starting out in Flash. Hope You can help
Array Referencing
please help
I'm playing around with buttons moving an object on the stage, I can get this working fine but I want to use an array to indicate the amount of pixles that the object moves.
this is the coding on the stage for the first frame:
MyPos = new Array("10", "20", "30", "40", "50", "60", "70", "80", "90", "110", "120");
var current:Number = 0;
the variable "current" I'm using as a counter to indicate what index of the array is to be requested.
here is the code on the button:
on (release) {
trace(current)
if (current < MyPos.length) {
trace(MyPos[current]);
sygArrow._x += MyPos[current];
current++;
trace(current);
}
}
I can get it working if I use the number '10' instead of 'MyPos[current];'
good luck and thank you for taking a look.
post a message of send as email to intract_6@hotmail.com
MC Referencing Problems :(
Hi - i have to provide this banner to a site - but they only accept relative MC referencing.
I have an empty mc on the main timeline (that will have amovie loaded into it) that i want to reference further down a nested set of MCs.
my problem is that when I come to target the mc within the actions panel it cant see it in relative mode -only absolute! :-(
why is this?! i can only see it when from the main timeline
thanks for your help
Referencing A Symbol
I think by default any symbol created in flash is referenced using the coordinates on the top left corner of the symbol.
Is there anyway to change that reference so that it is in the center of the object?
My reason for asking is because my symbol is round and referencing using a square makes it difficult to control its location when I change its size. If I could reference using the center then I wouldn't have to worry about changing the reference point when the symbol changes size.
I hope this makes sense.
Someone please help
Regards
D
Referencing Objects In A Different SWF
I'm attempting to create my first all-Flash web site. I have a master SWF that will load other SWFs into movie clips or levels.
One of the SWFs I plan to load is a complex menu system. When certain buttons in the menu are selected, I want things to happen in the master SWF file (i.e. other SWFs and text files load). Is there a way to reference objects in the master SWF from the menu SWF? Or is there a way to reference objects in the menu SWF from the master SWF? If both are possible, which way is better?
Referencing Timelines
I just started creating an interactive tutorial in Flash MX 2004. I have a fairly simple movieclip placed in a frame of my main timeline and am having problems with some of the actions in the movieclip. I have buttons in the movieclip that, when clicked, I would like to take the user to another frame in the main timeline.
Any idea about what sort of scripting I would do to accomplish this? I have tried reading through the Absolute and Relative Referencing section of Flash's help section, but haven't been able to get it to work.
Thanks in advance for any help.
Keyboard And Referencing
I've actually got two questions I'm trying to figure out. The first is I would like to display a keyboard in my Flash file that reacts the same way a regular keyboard does when the mouse clicks on letters and numbers. Is there a basic code or program for this or do I need to make every letter into a button?
The other question is is there anyway to reference a past button selected in a later screen? That probably sounds confusing, but the problem is I'm creating an interactive module and if the user clicks 'yes' on one of the early questions, when the summary page at the end comes up I need it to display 'yes' again. And I can't go through the quiz templates because those are too confining for what the program need to do. Thanks in advance
Referencing Outside Web Root
Hi people,
I'm looking to call an XML file that is located outside of my web root, for security reasons.
Problem is that Flash doesn't seem to want to go anywhere further back than my web root and ignores it when I try a relative path back and an absolute path from my server.
I'm thinking there's a security block in Flash Player to stop me doing this, would I be right?
Cheers.
Referencing A Scene Without A Name
I have an array that carries the names of scenes that I would like to jump to as and when.
I have arranged for the correct flow of code up until the point at which I wish to jump to my randomized scene.
I make a call to my array which will return as an example "blue1" into my variable, myRandom.
I need to somehow arrange for that variable (myRandom) to be used in the scene calling process.
ie . gotoAndPlay (_root.myRandom, 1)
Problem is, flash requires that the scene name be arranged in quotation marks and I can't get _root.myRandom to follow that concept........
Is there a workaround, I don't really want to have to do a shedload of if statements to cover every random eventuality.........Imagine if my array is 30 or more scenes in length, sod writing that many if statements.....
Any help appreciated on that matter, or viable alternatives to this issue.
Thanks in advance.
Koit
Referencing A Generated Name
i have this code:
for (a=0; a<schools.length; a++){
var x=this.createEmptyMovieClip("sbutton" + a, a);
var y=x.loadMovie("images/flash_off_" + schools[a] + ".jpg");
var t=this.attachMovie("sbutton" + a, "button_on_" + a, a);
.....does more stuff.......
now I need to call the sbutton+a clip created, which would have the instance name of sbutton1 or sbutton 2.... and so fourth
how do I call it here while still in the for loop?
"sbutton" + a._x=number; doesnt work
thisIMG="sbutton" + a;
thisIMG._x = number; also doesnt work
the solution for this is fine, thanks
however, i still have this issue: here is my code
var theDoc = new XML();
theDoc.ignoreWhite = true;
var words = new Array();
var urls= new Array();
theDoc.onLoad=function(){
var theWords=this.firstChild.childNodes;
for (i=0; i < theWords.length; i++){
words.push(theWords[i].attributes.name);
urls.push(theWords[i].attributes.urls);
}
loadButtons(urls);
}
theDoc.load("school.xml");
function loadButtons(schools){
prevX=0;
for (a=0; a<schools.length; a++){
var x=this.createEmptyMovieClip(["school_" + a], a);
var y=x.loadMovie("images/flash_off_" + schools[a] + ".jpg");
vart=this.attachMovie(["school_" + a], ["button_on_" + a], a);
x._x=prevX;
prevX=prevX + this["button_on_" + a]._width;
}
}
My problem is that I need to offset the new image's _x by the last image's _width.
x._x is fine
however, i cant retrieve the width for the new image no matter what I do
x._width I guess wont work because there is nothing loaded on it
y_width returns empty
so does t._width.
i'm trying to do this["button_on_" + a]._width or this["school_" + a]._width or ["button_on_" + a]._width / ["school_" + a]._width which all come back empty.
how do I get the new image's width , what would I call it from.
Referencing Objects
Is there any way to refernce multiple objects with similar names using a loop?
eg button1, button2, button3
code:
for (i=1; i<=3; i++ ) {
button(i)._visible = false;
}
Button Self-referencing
Hi.
I'm trying to use action script on a button to move the button by it's _x value.
I've tried doing this:
Code:
on(release){
this._x=-40;
}
but that moves the whole movie for some reason.
Any help would be gratefully received.
Ta,
Children Referencing
I am making a Jewelry Builder, where there is a certain number of slots created at runtime, these movie clips are created in a sprite called "frames". There are two other sprites called "jb" for jewelry box, and "bracelet".
basically what needs to happen, is if you drop a bead on a slot that a bead already occupies, if the next slot over (next movieclip in the "frames" sprite) is unoccupied, the bead slides over. the problem im having is checking the ".assigned" variable assigned to the slot next to it in "frames"
With this:
trace(frames.getChildByName(event.target.dropTarge t.parent.dropTarget.parent.name).x);
i am able to get the x cord value for the slot under both both beads, but a variable declared earlier in the script ".assigned" cannot be called.
the bead you drop is the event.target, and bead you dropped it on is the dropTarget.parent, and then the frame underneath that bead is the second dropTarget.parent.
there has to be a better way to call child movie clips and access all the variables assigned to them can anyone help?
Referencing Instances
Hey, I can't understand why the following error is occuring, I think I'm not right in my thinking about targetting instances:
"ReferenceError: Error #1069: Property cat not found on Main and there is no default value."
I have this code in my document class called Main:
var cat:Animal;
cat = new Animal(this);
cat.x = 100;
cat.y = 100;
cat.name = "cat"
stage.addChild(cat);
I also have an Animal class linked to a movieclip, this recieves the stage sent as a movieclip, and attempts to target the 'cat' instance just created:
public function Animal(stage:MovieClip)
{
this.xstage = stage;
//here i try to target the cat instance
xstage.cat.x = 50;
}
This is where the problem occurs, the movie runs but the compiler constantly outputs the above saying it cannot find the "cat" property in "Main". Perhaps that's the problem? It doesn't seem to be seeing it as the instance, it sees it as a property.
As I said, I've probably got my mind wrong as to how AS3.0 targets instances. That cat instance is still drawn on the stage, and I'm pretty sure it has the instance name "cat".
Can anyone suggest what the problem is?
Thankyou.
[CS3] Dynamically Referencing MCs In AS3?
Hi-
I'm new to AS3 and trying to get my head around a particular issue. In AS2 (as I recall), you could dynamically reference movie clip instances by something like:
["nav" + someVariable]nextClip.nextClip._x = 300;
...where the expression inside the brackets once evaluated was seen as an instance name.
Can I do this in AS3 somehow? I have 4 movie clip instances on the stage (navEnlighten, navShowcase, navDiscover, navConnect) and I want to change a property of a nested clip (bg) in only one of them depending on what a variable (someVariable) is currently set to when the playhead lands in the frame they're sitting on.
Am I missing something here or is this approach just fundamentally wrong? It seems that there should be some way to target an instance through the use of variables.
Any help would be greatly appreciated!
Thanks,
Mike
Question On Referencing
I want to have 2 classes (in addition to the document class) that will help me create a video player. It would be easier to have the video for one class and the buttons to control the video in another class (for a few reasons which I won't get into here...it's more than a typical video player).
So in Class 2 (where the buttons are) I'll need to add event listeners to stop and start the stream in Class 1. Would I create the event listeners from the document class? Or is there another way to communicate from one class to another?
Would the best way to do it be by creating a custom event in the document class that is linked to Class 2 and calls a function on Class 1 in response?
Referencing Mc In External SWF
I know the answer to this is probably very simple but here goes:
I'm loading an external SWF into an empty movie clip. The external SWF has multiple objects (specifically movie clips) that I'd like to reference individually. The code below is what I've been trying and it's not working.
Code:
_root.createEmptyMovieClip("loaded_mc", 9);
loaded_mc.loadMovie("test2.swf");
loaded_mc.square_mc._alpha = 25
anyone got any suggestions?
Referencing Another Timeline
i've got 2 movieclips "primaryMC" and "secondaryMC". secondaryMC is inside primaryMC and is brought about by a button that is also inside primaryMC.
i need primaryMC to _root to the MAIN timeline and secondaryMC to reference the primaryMC timeline.
How is this done without making the primaryMC reference itself with the _lockroot command?
|