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




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



FlashKit > Flash Help > Flash ActionScript
Posted on: 12-13-2001, 11:15 AM


View Complete Forum Thread with Replies

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

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"?

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,

Button Referencing
Ok, this is definitely a newbie question. For some reason I always get mixed up on "this" or "_root".

I have a movie that loads a smaller movie using the loadMovieNum method. The loaded movie is called cwpTile.swf. I would like to add the onRelease function to a button in the cwpTile.swf file but I can't figure out how to reference it.
The button in question is in a movie clip on the stage in cwpTile.swf and the movie clip is called "symbol 1" and the instance name is "mySymbol" .

Now the "mySymbol" movie clip has a button in it called "myBtn".

In the main movie I wanted reference that button but I cant figure out the proper syntax.

I tried _root.mySymbol.myBtn but that didn't work.

Any suggestions?

Thanks.

Button Referencing?
how do you reference a button (or movieclip) that exists on the main stage of an external swf that was loaded into a movieclip of the parent movie?

does that make sense?

thanks!

Referencing A Button
Would anyone happen to know of another way to reference a button which is inside a movie clip on a keyframe in the main stage besides this:



Code:
_root.Name_of_movie_clip.buttonName.onRelease=function(){
variable="some string";
//call function;
}

Referencing Movieclip Within Button
I basically want to create a button that changes appearance once it has been clicked once, rather like a hyperlink changes colour once you've visited it.

I have a generic button. Inside the button is a second layer containing a movieclip named 'visited' which has two frames, for visited and not visited. The first frame of the embedded movie clip is blank, the second changes the appearance of the button.

I create an instance of the button and call it 'button1'. Now in the actionscript I want to move the visited movieclip to the second frame if the button is pressed, in other words:

on (press) {
button1.visited.gotoAndPlay(2);
}

However, this doesn't work. I have to refer to it using an instance name like this:

button1.instance2.gotoAndPlay(2);

Obviously I don't want to do this because the instance name changes if I make changes to the movie.

My question is, how do I refer to the movieclip in the button?

Cheers,

James

Referencing Button Elements.
How can I reference elements inside a button through actionscript? Do I have to specifically reference a up/over/down/hit frame?

I am trying to change the size of the hit area at runtime. I have a movie clip in the hit frame (actually stretched across all four frames) that keeps coming back as 'undefined', although I can reference the button itself with no problem.

Problem: Referencing A Button's Name
So I'm trying to set some button functions like:

Button.prototype.onPress = function(){
trace("I am a button");
}

Only I want the trace message to include the Button's name.
However, I can not figure out the correct reference to the Button's name.

Any one know and care to help?

Thanks.

Referencing A Button Instance Name?
Hi im using Flash MX with actionscript 1 and wondering if the following is possible?

I have an overhead site plan of an area with over 100 buttons mapped out that will trigger an effect when each button is rolled-over.

Everythings working fine but i've coded it all the long way by having seperate code on each button. What i want to do however it place all the relevant code to run at rollover within a function that can the be simply dumplicated on each button. Each button is labelled (b1, b2 .. b100 etc.)

What im struggling to do is reference the instance name of the button that is currently rolled-over within the actionscript for that button! I need this information to call in the appropriate information for that particular button.

Anyone with any ideas? Many thanks, hope that makes sense!

Help Referencing A Radio Button
I have a radio button that I created like this:

this.createObject("RadioButton", "rb"+i, i, {label:"test button"+i,_x: myX,_y:myY, groupName:"myrbGroup"});

The second parameter is the instance name.
Now say I decide to move this button with the move command, how would I do this?

I have tried:

["rb" + i].move(10,10);
("rb" + i).move(10,10);
this.move(10,10);
this.RadioButton.move(10,10);

Does anybody know what I need to do?

Referencing A MovieClip Within A Button
Here's my issue:

I have a MovieClip within a Button that's within a MovieClip.

Like this:

ActionScript Code:
container_mc.myButton_btn.btnMC_mc.alpha = .2;

I receive this error:
ReferenceError: Error #1069: Property btnMC_mc not found on flash.display.SimpleButton and there is no default value.

It seems as though I'm not able to reference a MovieClip that sits within a Button. Is this correct?

Referencing A Movieclip In A Button
can you reference a movieclip in a button?

Referencing A Movieclip In Button...
Hello,

I am trying to control a movie clip with a button, the movieclip is located within a _root.movieclip, and the button is also located at _root. level... how is the movieclip in question referenced in the button...?

Hope it makes sense...thnx

Referencing A Button In A Movie Clip
I think i have the right idea, and i'm pretty sure i've done this before but can't remember how.

I have a button symbol (button-restore) in a movieclip (movie-topbar), and the movieclip is on the main timeline.

When the button-restore button is clicked I want it to disappear, and another button symbol (button-maximize) to appear (the button-maximize symbol is already present in the movie clip, but just has a visiblity of 0)

I've been trying this action for the button-restore button:

Code:
on (release) {
setProperty ("button-restore", _visible, false);
setProperty ("button-maximize", _visible, true);
}
--> I've also tried referencing the buttons by doing: _root.movie-topbar-button-restore, and this doesn't seem to work either.

Any ideas?

Button Issue, A Matter Of Referencing I Think
hi hi, i always get in diffuculty with referancing in flash, this is no exception lol,....

got this code on main timeline:


Code:
loader._visible = false;
function preLoader(mc) {
_root.onEnterFrame = function() {
lBytes = mc.getBytesLoaded();
tBytes = mc.getBytesTotal();
if (percentLoaded<100) {
_root.loader._visible = true;
} else {
_root.loader._visible = false;
}
percentLoaded = Math.floor((lBytes/tBytes)*100);
_root.loader._xscale = percentLoaded;
if (lBytes>=tBytes) {
link._width = 800;
link._height = 600;
_root.loader._visible = false;
}
};
}
newDepth = 1;
leaf2.onPress = function() {
newDepth++;
var h = link.createEmptyMovieClip("holder"+newDepth, newDepth);
h.loadMovie("IMG01.jpg", "_root.holder"+newDepth);
preLoader(h);
};
leaf3.onPress = function() {
newDepth++;
var h = link.createEmptyMovieClip("holder"+newDepth, newDepth);
h.loadMovie("IMG02.jpg", "_root.holder"+newDepth);
preLoader(h);
};
on the same layer are the buttons "leaf2" and "leaf3". everything works good.

problem is that this was just for testing and these buttons will eventually be inside a moviclip called "bar" that rolls up on stage to show the buttons, my question is how do i referance and call the leaf functions above if the buttons are in this part of my movie? would this be something like

_root.bar.leaf3.onPress....etc etc

is that anywhere close? btw the above didnt work.

Referencing Button Frames In Flash
I would like to use a tellTarget or something similar to move a button to the over state.

for example:

on(rollover){
tellTarget(mybutton){
gotoAndStop(2);
}
}

where frame 2 is the over state of the mybutton button.

any suggestions?

[F8] Referencing A Button In A Movie Clip
I know this is an easy one, but I can't figure this out for the life of me. I have a button called mute_btn inside a movieclip muter on the main timeline. I want to write this script

mute_btn.enabled = false;

but how would i write it for the mute button since it's inside the movie clip because as it this doesnt work.

Thanks for you time and patience.

Cheers!

Button Transparency And Referencing FLA Object From AS3.
I'm using the following graphic and animating the mouth when clicked. Problem is I don't want the CLICK event to dispatch when the transparency is clicked. I know using the flash file I can draw a graphic the shape of my image and place it behind the image and dispatch the click event for the drawn shape, but here's my question.

Is there a better way of doing this for buttons with transparencies?

If not how do reference a drawn graphic in my fla file from my as3 file?

Thanks

Referencing Button Inside A Loaded SWF
Hey everyone,

I'm completely new to ActionScript and have been learning what I can in bits and pieces today. I'll try to keep my problem simple. In my main movie, I have a button that loads a second swf (small window) file into the main movie. The second file "flies" in from the bottom using motion easing. I've accomplished everything fine so far except that when I press close on the popup, it abruptly disappears.

I thought I could use yoyo() to reverse the animation when close is clicked to hide the popup off screen until I need it again. I just don't know how I'm supposed to reference the close button in the second movie from the first one.

The button in the second movie instance is Exit while its class is ExitButton. To accomplish what I'm trying to do I should set up an event listener in the main movie and remove the one from the second correct?

ActionScript Code:
wbutton.buttonMode=true;
wbutton.addEventListener(MouseEvent.CLICK,onClick);
function onClick(event:MouseEvent):void {
    var box:Loader= new Loader();
    var urlrHome:URLRequest = new URLRequest("popup.swf")
    addChild(box);
    var myTween:Tween = new Tween(this, "y",Exponential.easeOut, 600, 0, 1, true)
    box.load(urlrHome);
}

Referencing A Movie Clip Within A Button?
i have a button that has a movie clip in it. I would like to play the movieClip on the rollOver event, but I can't get it to play. Here is what I hae got

on(rollOver) {
_root.myProjects_btn.folderZoom_mc.gotoAndPlay("st art");
}

I have also tried but it didn't work either

on(rollOver) {
this.folderZoom_mc.gotoAndPlay("start");
}

Thanks for the help

Referencing A Movie Clip Within A Button?
i have a button that has a movie clip in it. I would like to play the movieClip on the rollOver event, but I can't get it to play. Here is what I hae got

on(rollOver) {
_root.myProjects_btn.folderZoom_mc.gotoAndPlay("st art");
}

I have also tried but it didn't work either

on(rollOver) {
this.folderZoom_mc.gotoAndPlay("start");
}

Thanks for the help

Referencing Dynamic Text Field On Button
I have a button which has a colored square as well as a dynamic text field (buttonText). The over state inverts the color of the text and square.

I place the button in a MovieClip(ButonMC) and put an instance on the timeline (Button1). I put other copies on the timeline as well (Button2, Button3).

How do I refer to the dynamic text field in each instance?

_root.Button1.buttonText does not seem to work. I guess I could take the text field out of the button symbol and place it in the ButtonMC movie clip. But then I would lose the 'over state abilities'

TIA

Referencing Button Names To Call Txt Files
I am working on a timeline project in Flash and I have everything working where you click on a button which loads an external text file for that year in a movie clip that scrolls.

The timeline has 75 years = 75 buttons. Is there a way to call the text file based on the button clicked without specifically using actionScript to load "1928.txt", "1929.txt" and so on. For example, my button name is b19XX and I would like to call b19XX.txt without having to explicitly load b19XX.txt for each and every button I know you can call movieClip names, how about buttons. It's not the end of the world, but instead of updated the script for each button, I can use the same script for all the buttons.

Thanks

Button Referencing A Movie Clip Instance
Ok, I haven't used flash in a long time and this once seemed easy to me, but for some reason i can't remember how to have a button, on release - go to a particular movie clip instance on the same timeline.

PLEASE HELP!

thanks!

Setting A Link In A Button By Referencing A Txt File
I have a couple of projects where the clients would like to be able to edit the links in flash files without opening flash. So I need to be able to reference a txt file and have that txt file populate the getUrl link in a button.

I tried doing a search on this several times but the server seems to be timing out. So I apologize if this was posted before.

Thanks

Referencing Loaded External Swf For Button Behavior
Howdy

How does one reference an external swf file that has been loaded into a targeted blank movie clip? Here's the deal. I have several buttons that load external swf and that works fine. I would like to disable and fade back the button if the button's movie has loaded. I can get the buttons to fade and disable but I'd like for them to "come back" after another button is pressed. I just can't figure out how to check if the loaded movie is there.

Any help would be great.
Thanks.

Referencing A Button On Frame 2 Of MC From Main Timeline
I have these two addEventListener's on my main timeline.


ActionScript Code:
// back1_btn is on frame 1 of loadWindow_clip
loadWindow_clip.back1_btn.addEventListener (MouseEvent.CLICK, clickedgoBack1);

// back2_btn is on frame 2 of loadWindow_clip
loadWindow_clip.back2_btn.addEventListener (MouseEvent.CLICK, clickedgoBack2);


When I test the movie, I receive the following error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.

If I remove:

ActionScript Code:
loadWindow_clip.back2_btn.addEventListener (MouseEvent.CLICK, clickedgoBack2);

I don't receive the error.

The movieclip, loadWindow_clip, has 2 frames. Frame 1 and frame 2.

On frame 1 of loadWindow_clip I have a button, instance named: back1_btn
On frame 2 of loadWindow_clip I have a button, instance named: back2_btn

What it looks like to me is that I cannot make reference to any other frame other than frame 1 of another movieclip, from the main timeline.

Am I correct?

Referencing A Movie Clip From Button Click?
Here's my dilemma. I have about 15 buttons on the stage, and I'm trying to keep my code nice and simple, so I'm looking to have one function that works for all of them, instead of 15 unique functions.

So let's say I have a button called aboutUs and also a movieclip called aboutUsMovieClip. When aboutUs is clicked, I want aboutUsMovieClip to play. Is there a way to reference it using something like:


ActionScript Code:
function playMovieClip(e:Event):void{
e.target.name+"MovieClip".play();
}

Now, I would be about 99% sure that way will not work, but I tried to give you guys the gist of what I wanna do. That way, I can name all my movie clips the same name as my button, just with "MovieClip" appended to the instance name, and only have to write one function.

Referencing A Button In An Attached Movie Clip
I am trying to code an onRelease function for a button located in a movie clip I've attached to another movie clip. It works for one button, but not for another, eventhough I think I've done them the same way. Here's the code:


Code:

his.stop();

//THIS PART WORKS
map_button_holder.map_anim_mc.btn_get_map.onRelease = function(){
map_holder.attachMovie("mapclip", "map_mc", map_holder.getNextHighestDepth());
map_button_holder.removeMovieClip("map_anim_mc");
map_button_holder.attachMovie("mapclose", "map_close_mc", map_button_holder.getNextHighestDepth());
trace("get map clicked");
}

//THIS PART DOESN'T WORK
map_button_holder.map_close_mc.btn_close_map.onRelease = function(){
map_holder.removeMovieClip("map_mc");
map_button_holder.removeMovieClip("map_close_mc");
map_button_holder.attachMovie("mapanim", "map_anim_mc", map_button_holder.getNextHighestDepth());
trace("close map clicked");
}
The movie clip "map_anim_mc" was attached (using attachMovie) to map_button_holder a few frames earlier, and btn_get_map works. Can anyone see what's wrong with my code, or what might be the problem?

Referencing A Var Within A Dynamically Created Button Via An Attached Function
I'm having a issue using a var within a button.
I create the button and add the var to the to button:

addChild(answerButton);
answerButton.thisX = ii; // temp value that changes with each addchild

The Question is how do I get the buttons to trace (to start with) the value of the var contained within them?

So easy in as 2


Here is my code below:



PHP Code:




//matchingSetUp.as
package {
    import flash.display.Sprite;
    import flash.text.*;
    import flash.events.MouseEvent;
    import flash.display.MovieClip;

    public class matchingSetUp extends Sprite {
        private var choiceButton:choice;
        private var allAnswers:Array;
        private var answerButton:answer_box;
        private var tempString;//my movieclip name
        private var myThis:MovieClip;//my movieclip
        private var sortMethods:Array = [1,2,8];// 3 diverse types of sorts
        var sortInt:int=0;
        private var _matchingObj:Object;
        public function matchingSetUp(_matchingObj) {
            init(_matchingObj);
        }
        private function init(_matchingObj) {
            // setting up drop zones
            for (var i:int=0; i < _matchingObj.problemCodes.length; i++) {
                choiceButton=new choice  ;
                addChild(choiceButton);
                choiceButton.x=_matchingObj.targetsX;
                choiceButton.y=_matchingObj.targetsY[i];
                choiceButton.name="mc" + _matchingObj.problemCodes[i];
            }
            //setting up Correct answer buttons
            //// putting all answer into 1 array
            allAnswers = _matchingObj.choiceBank;
            for (var k:int = 0; k< _matchingObj.extraChoices.length; k++) {
                allAnswers.push(_matchingObj.extraChoices[k]);
            }
            //// pseudo-randomizing the answers boxes based on sorts
            sortInt = (Math.random() * 3);
            allAnswers.sort(sortMethods[sortInt]);
            //// adding the boxes to the stage
            for (var ii:int=0; ii < allAnswers.length; ii++) {
                answerButton=new answer_box  ;
                addChild(answerButton);
                answerButton.x=757;// this needs to be in the fla struct
                if (ii == 0) {
                    answerButton.y=108;// this needs to be in the fla struct
                } else {
                    tempString =allAnswers[ii-1];
                    myThis=answerButton.parent.getChildByName(tempString)  as  MovieClip;
                    answerButton.y=myThis.y + 29;
                }
                answerButton.name=allAnswers[ii];
                answerButton.thisX = ii;
                trace(answerButton.thisX);                myThis=answerButton.parent.getChildByName(answerButton.name)  as  MovieClip;
                myThis.my_name.text = allAnswers[ii];
                answerButton.addEventListener(MouseEvent.CLICK,myMouseDown2);


            }
        }

        private function myMouseDown2(event:MouseEvent):void {
            trace(thisX); // how do I access the var here ??????????????????????????
        }
    }
}

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.

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

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