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




Passing Variable To OnRollOver Function In A Loop



Code:
//this is where the array 'list' is
function buildList(){
spacing = 30
var i = -1;
while(++i <= list.length-1){
name = "infobar"+i;
y = i * spacing;
display.list.attachMovie("infobar",name,i);
display.list[name]._y = y;
display.list[name].linkText.text = list[i][0];
display.list[name].onRollOver=function(){
trace(list[i][0]);//this trace returns undefined
}
trace(list[i][0]);//this trace returns correctly
}
}
buildList();
it seems when i try to use the variable 'i' in the onRollOver function, it doesnt work, because if i replace i with, say, 1... it works fine.

thank you for the help



ActionScript.org Forums > ActionScript Forums Group > ActionScript 1.0 (and below)
Posted on: 05-25-2004, 05:44 PM


View Complete Forum Thread with Replies

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

Passing Variable To OnRollOver Function
I have this cycle.

for(var p=0; p<k; p++){
eval("Butt"+areaList[p]).onRollOver = function() {
clipZoom(this, 150, 0.8, null, null);
this.swapDepths(1000);
eval(enterList[p])._visible=true;
};

eval("Butt"+areaList[p]).onRollOut = function() {
clipZoom(this, 95, 0.8, null, null);
this.swapDepths(1);
eval(enterList[p])._visible=true;
};
};

The onRollOver function zoom the movieclip and display another movieclip.
I use two arrays that contain the names of the movieclips.
The problem is that p inside the onRollOut is always = k.

I don't understand why.
Is there a workaround?
Thank you,
Marco

OnRollOver Function Within A For Loop Not Working.
I am trying to call button names from an array. I can get the button names to work but from within the function it calls onRollOver my i value does not work (See code below)

buttons = new Array(blog, contact... etc);

for(i=0; i<buttons.length; i++){
this.buttons.onRollOver = function(){
hover_on = "btn"+i; //this is where my i value doesn't appear
}

this.buttons.onRollOut = function(){
hover_on = "none";
}

if("btn"+i == hover_on){
this.button.gotoAndPlay(_currentframe+1); //animates button when rolled over
}

Is there a way to make my i value transfer into the onrollover function or another way to replicate what I'm doing? Thanks!

Mc.onRollOver = Function() {} Doesn't Work In A Loop?
Hello:

I have a couple of movie clips and want to loop through them in an array for some event handlers. However it doesn't work. Can you please tell me why?

********************************************************
var arr_USstates:Array = new Array(CA,OR,WA,ID,WY);

for (var k = 0; k<=arr_USstates.length-1; k++) {
arr_USstates[k].onRollOver = function() {
arr_USstates[k].gotoAndStop(40);
}
arr_USstates[k].onRollOut = function() {
arr_USstates[k].gotoAndStop(40);
}
}
******************************************************
When I trace(arr_USstates[k]), it says undefined.





























Edited: 04/05/2007 at 08:44:12 AM by lvbao

Passing Function Parameters In A Loop?
Hey guys,
i am creating a flash product catalogue using an xml file to store the data. The catalogue has a few categories and a few products in each category.
I have written the script to put the categories into a array and now I am writing the script to make the category buttons. I want the category buttons to call another function which will place the products from that category on the screen.
The problem is that in the “for Loop” the function parameter is not being set or passed for some reason. Can anyone see what im doing wrong here?
thanks for your help!!!
Joe


PHP Code:




//For loop to place a button instance
for (var i = 0; i <aCat.length; i++) { {
    
    //Place the button instance
    attachMovie("mcCatButton", "mcNewCatButton"+i, i, {_x:xPos, _y:yPos});

    //add the label
    this["mcNewCatButton"+i].catTitle.text = aCat[i][0];

    // add an onRelease which calls the displayProducts funciton
    this["mcNewCatButton"+i].onRelease =  function():Void {
        displayProducts(catID[i][1]);
    }

    // This trace works fine
    trace(catID)
}

//This is the function where the products will be displayed on stage
displayProducts function(cat:String) {

    // Why does this trace return undefined??
    trace(cat)
}

Passing Parameters To A Function In A For Loop
how do i pass the values of a for loop (for example the increment count) to a onRelease function inside that loop? in the example below the movie clip will always go to "whatever.php?var=10" because the value of i when you click it is 10. i want the value of i to be included for each run of the loop. how do i do that? i'm guessing maybe a listener, but i can't get anything to work.









Attach Code

var home:MovieClip = this;

for (i=1; i<10; i++) {
var t = home.attachMovie("myMovie", "myMovie"+i, i);
t.onRelease = function() {
getURL("whatever.php?var="+i);
}
}

Passing A Variable Into A Function?
I simplified my original code as much as possible to show what I need.
From the code below, I need to trace (x) so that it doesn't show the top value of 5.
Actually, I need to be able to recognise which of the attachedMovieClip s have been pressed so's to do a getURL based on it.
Can anyone help? Thanks.

myButt.onRollOver = function() {
var a = 0;
for (var x = 0; x<5; x++) {
var myClip = _root.attachMovie("Clip", "Clip"+a, a++);
myClip._x = myClip._width*x;
myClip.onPress = function() {
trace(x);
};
}
}

Passing A Variable From Within A Function
1. I have successfully parsed either an XML files using the XML object
or variable=value pair using LoadVars in ACTIONSCRIPT 2 (I am using Flash8)

2. However the scope of the variables' value is limited to inside the scope of the success function
(pseudo code)

if (success) {
variable1=value;
}

Now outside this function block I want to be able to access this value whenever I reference the variable1 within the rest of the actionscript.

3.Within the function block, I have tried using:
a) return variable1;
b) _global.variable1=value;
c) _root.variable1=value;
d) this.variable1=value;

4.How do I use a screen name here in the forum? I feel dorky having "screennameisnotavailble" displayed?

Thanks.

Passing Variable In A Function
I think this is a simple problem. I want to pass a Variable to a function when a button is clicked. I am used to just passing a Variable like so: FuncTest(CustomVarible); But that doesn't seem to work. Here is an example of what I trying to do; I know it won't run in actionscript, but at least it will give you an idea.







Attach Code

btnUserButton.addEventListener(MouseEvent.CLICK, ButtonClicked(varFrame));

function ButtonClicked(e:Event):void {
gotoAndPlay(varFrame);
}

Passing Variable To A Function
Hi all,

I have this script that reads pictures and links of the pictures from the an xml file, display the picture and then put the link for the image, but I can't seem to pass the link to the onRelease function anyone can help me on this, below is the code:









Attach Code

Photos = new XML();
Photos.ignoreWhite = true;
Photos.onLoad = function(success) {

numimages = this.firstChild.childNodes.length;
spacing = 120;
var _link:Array = new Array();

for (i=0; i<numimages; i++) {
this.picHolder = this.firstChild.childNodes[i];
this.photosHolder = photos.createEmptyMovieClip("photos"+i, i);
this.photosHolder._x = i*spacing;
this.picHolder._URL = this.picHolder.attributes.link;
trace(this.picHolder._URL); //Tracing image link
var _link[i] = this.picHolder._URL;
trace(_link[i]);//Tracing the link inside the array

this.photosHolder.onRelease=function(){
trace(_link[i]);//Tracing link inside function (still not being passed)
getURL(_link[i], "_blank");
};

this.photosHolder = this.photosHolder.createEmptyMovieClip("photos_image", 0);
this.photosHolder.loadMovie(this.picHolder.attributes.pic);
}
};
Photos.load("xml/hosp.xml");

























Edited: 07/28/2008 at 07:44:01 AM by ehajj

Passing A Variable Into A Function
why is my variable not being passed into my function?


Code:
dealerLocate.urlButton.linkButton.onRelease=function(webAddress){
web=webAddress
trace("this is web "+web);
fullUrl="http://"+web;
trace("full url="+fullUrl);
getURL(fullUrl, "_blank");
}
the webAddress variable is from the exact same timeline making it one level up from this function. it traces out correctly too so I know the variable is there... just not getting passed!

now i've got a bunch of goofy trace stuff in there but you get the idea... help!

Passing Variable To A Function
Hi all,

I have this script that reads pictures and links of the pictures from the an xml file, display the picture and then put the link for the image, but I can't seem to pass the link to the onRelease function anyone can help me on this, below is the code:


Code:
Photos = new XML();
Photos.ignoreWhite = true;
Photos.onLoad = function(success) {

numimages = this.firstChild.childNodes.length;
spacing = 120;
var _link:Array = new Array();

for (i=0; i<numimages; i++) {
this.picHolder = this.firstChild.childNodes[i];
this.photosHolder = photos.createEmptyMovieClip("photos"+i, i);
this.photosHolder._x = i*spacing;
this.picHolder._URL = this.picHolder.attributes.link;
trace(this.picHolder._URL); //Tracing image link
var _link[i] = this.picHolder._URL;
trace(_link[i]);//Tracing the link inside the array

this.photosHolder.onRelease=function(){
trace(_link[i]);//Tracing link inside function (still not being passed)
getURL(_link[i], "_blank");
};

this.photosHolder = this.photosHolder.createEmptyMovieClip("photos_image", 0);
this.photosHolder.loadMovie(this.picHolder.attributes.pic);
}
};
Photos.load("xml/hosp.xml");

Passing A Variable To A Function
hi guys

I haven't posted here for a while but i've come across a problem that you might be able to answer

I've boiled the whole thing down to this:

How do i pass a variable to an onLoad() function?

here is my script: .....

Passing A Variable To A Function
hi guys

i haven't posted here for a while but i've come across a problem that you might be able to answer

i've boiled the whole thing down to this:

how do i pass a variable to an onLoad() function?

here is my script:

ActionScript Code:
function loadDescriptions() {
    for (var i=0; i<_root.menuItems_array.length;i++) {
        var thisTextLoadVars = new LoadVars();
        thisTextLoadVars.onLoad = function(success) {
            trace (_root.menuItems_array[i]);
        };
        var thisDoc = _root.menuItems_array[i];
        trace ("thisDoc: "+thisDoc);
        var textDoc = _root.menu[thisDoc].description;
        thisTextLoadVars.load(textDoc);
    }
}

the trace in the the onLoad function returns "undefined". Can anyone tell me how to get around this please?

thanks
alz

Passing Variable Inside Function
Can you tell me how to pass variable into _root["menu"+a].onRollOver = function (). See following piece of code and find "<--HERE"
When I roll over mc function is called but nothing returns

Code:
function menuObject() {
if (a<_root.menuGlowne.length) {
_root.attachMovie("menu", "menu"+a, 1100+a);
_root["menu"+a]._y = 0;
if(a==0){
_root["menu"+a]._x = 0;
} else {
_root["menu"+a]._x = _root["menu"+(a-1)]._x + _root["menu"+(a-1)]._width+10
}
_root["menu"+a].onRollOver = function () {
_root.subm(a) // <--HERE
};
a++;
} else {
delete this.onEnterFrame;
}
}

function subm(a){
trace ("called")
trace ("this is" + a)
}

Passing Variable Inside A Function
Hello all,
here is the source of my question:

Code:
id = "1";
function somefunct(){
trace(id);
}
and the "trace" prints undefined ... does anybody know how i can pass the id variable inside the function ?? Thanks in advance

Problem Passing Variable To A Function
Good day all:

I am having a problem getting a variable to pass to a function and then running a tween.

On the stage I have a movie clip called imageGroup_mc. Inside that clip I have another movie clip named t01_mc. I have code within the imageGroup_mc clip that adjusts the alpha of the t01_mc clip.

If I write the code as follows all works fine:

this.t01_mc.onRollOver = function () {
new Tween(this,"_alpha",Regular.easeOut,70,100,5,false );
}

Problem is there are 12 clips like t01 that will all use the same code so I wrote a function, but the following code is not working. I am not sure if the eval is wrong or something else:

function imageRollOver (image) {
new Tween(eval(image),"_alpha",Regular.easeOut,70,100, 5,false);
}

this.t01_mc.onRollOver = function () {
imageRollOver(“t01_mc”);
}

I have tried different variations of putting t01_mc in quotes, writing it as the full imageGroup_mc.t01_mc and nothing is working.

Any assistance would be greatly appreciated.

Thanks in advance.
Mark

Passing A Variable To OnLoad Function
i haven't posted here before so wotcha

i've come across a problem that you might be able to answer

i've boiled the whole thing down to this:

how do i pass a variable to an onLoad() function?

here is my script:

PHP Code:



function loadDescriptions() {
        for (var i=0; i<_root.menuItems_array.length;i++) {
                var thisTextLoadVars = new LoadVars();
                thisTextLoadVars.onLoad = function(success) {
                        trace (_root.menuItems_array[i]);
                };
                var thisDoc = _root.menuItems_array[i];
                trace ("thisDoc: "+thisDoc);
                var textDoc = _root.menu[thisDoc].description;
                thisTextLoadVars.load(textDoc);
        }





the trace in the the onLoad function returns "undefined". Can anyone tell me how to get around this please?

thanks
alz

Passing Variable Outside Of A Function Block
1. I have already read the Adobe docs and a gazillion Flash forums about the scope of variables within a function block. This is driving me mad!

2. I am using a function to assign values from a parsed XML file to variables within the function block. I am successful at parsing the XML file and displaying the variables from within the function block. However, they expire outside of the function block.

3. I would like these assigned values available globally outside of the function block.

The pseudo code:

_global.newVariable1
_global.newVariable2
_global.newVariable3

function init () {

//parse script here
//assign parsed field values from xml file to variables - fields come from ChildNodes in the XML file - this ISN'T the issue here - the fields are parsed correctly!)
Variable1 = field1;
Variable2 = field2;
Variable3 = field3;
_global.newVariable1 = Variable1;
_global.newVariable2 = Variable2;
_global.newVariable3 = Variable3;

}

var my_xml = new XML ();
my_xml.onLoad = init;
my_xml.load("filename.xml");
my_xml.ignoreWhite = "true";

trace(_global.newVariable1) should NOT be "undefined" but have the value of Variable1 (the XML field value)

[AS1/2] Passing An Object As A Variable In A Function
I have a movieClip prototype that calls another function once it has finished.
The other function could be one of many.
I want to be able to pass the variables of the second function to the first function:

Code:
MovieClip.prototype.func1=function(varA,varB,func2name,func2args){
// do something
// once done call second function:
this[func2Name](func2args.join(','));
};
// called using:


Code:
myMC.func1(varA,varB,"func2Name",{func2Arg1:value, func2Arg2:value})
Any idea how this should be written?
At the moment only the first variable of func2 is populated....

Thanks for helpin me out on this 1

Ed

Passing Instance Name To Function As A Variable
hello friends

the idea is that the site keeps tracks of whatever page is current and passes this variable to the alpha function which will target that movie instance to fade when moving to another page - then that page's name will be assigned to current.

this is the code that i have now..

#include "alpha.as"
evolution.onRelease = function() {
this[current].gotoAndPlay(2);
this[current].alpha(5, 0);
};

evolution and solo exist in the same timeline..

the hierachy is like this there is a movie called pictures on the root timeline - this contains all the buttons and all the scripts that you see (except the external script for the alpha function) - plus the variable current is declared in it too.

it's a one frame movie which contains another movie solo which is what i am trying to target when a button is clicked.

any help very much appreciated..

Si

Passing Instance Name To Function As A Variable
hello friends

ok the idea is that this movie keeps tracks of whatever page it's on using the variable current. when the button evolution is clicked it should jump to frame 2 of the movie whose instance name is contained in the variable current and also pass this variable to a function called alpha which fade that movie's instance when moving to another page - then that page's name will be assigned to current.

this is the code that i have now..

#include "alpha.as"
evolution.onRelease = function() {
this[current].gotoAndPlay(2);
this[current].alpha(5, 0);
};

all these buttons and movie instances are contained in the same movie clip and the variable current is declared in it too.

any help very much appreciated..

Si

Quick Fix: Passing A Int Variable Into A Function
I can't seem to get this to work:

var i:int = 0;

function count(a:int):void
{
a++;
}


count(i);
count(i);
count(i);

trace(i);//traces 0


Is there a way I can make it do it's math, to the variable itself, without some crazy solution or using objects to hold the variables?

[AS1/2] Passing An Object As A Variable In A Function
I have a movieClip prototype that calls another function once it has finished.
The other function could be one of many.
I want to be able to pass the variables of the second function to the first function:

Code:
MovieClip.prototype.func1=function(varA,varB,func2name,func2args){
// do something
// once done call second function:
this[func2Name](func2args.join(','));
};
// called using:


Code:
myMC.func1(varA,varB,"func2Name",{func2Arg1:value, func2Arg2:value})
Any idea how this should be written?
At the moment only the first variable of func2 is populated....

Thanks for helpin me out on this 1

Ed

Passing A Variable In A GetURL Function To An HTML Page With JavaScript
This is probably a stupid question, but here goes:

I want to open external windows with high quality jpegs, and I don't want toolbars, scrollbars, etc...

So what I have made a blank html page called "launch.html"
On this page is some simple javascript set up to take the variable passed from Flashs getURL function, and open up a new window with the correct file.

But when I use a javascript alert to find out if the variable is being passed correctly the alert box says my variable is undefined.

The flash getURL function is scripted as such:

getURL("launch.html&openWindow=" + _root.myTarget, target="_blank", "GET")

_root.myTarget variable is set when a user presses a thumbnail image on my webpage.

Well thats my problem, hope I explained it well. Thanks ahead of time for any help you can provide

btw, using Flash 5

Function/loop Variable Problem
Inside my imagePull_Result function I have a for loop. I am trying to make a variable "s" which starts as 0 and is used by the for loop and then modified by the for loop. For some reason it stays as 0 no matter what I do. I put in red ever place i've tried to locate "s=0." I hope this is a simple problem. Any help is apriciated.

*
function imagePull_Result(result){
_global.imgString = result;
imagePull_Display();
imgArr = result.split(",");
imgArr.shift();
imgArr.shift();
_global.s=0;
for(i=0,*; i<(imgArr.length-1); i++){
var img_container:MovieClip = mc_container.createEmptyMovieClip(i, i);
img_container._x = _global.s+22;
img_container._y = 80;
var img_mc:MovieClip = img_container.createEmptyMovieClip("img_mc", 0);
img_mc.loadMovie(imgDir2+imgArr[i]);
img_container.onEnterFrame = function () {
if (this._width !== 0) {
this._width = Math.floor(this._width/(this._height/60));
this._height = Math.floor(this._height/(this._height/60));
_global.s = _global.s + this._width + 22;
delete this.onEnterFrame;
}
_root.mc_container._x = 640 - mc_container._width/2;
}

Duplicate Movie Function Won't Access Loop Variable
Hi guys,

I have created some thumbnails using a for loop and duplicateMovieClip. I have assigned a on.Press function to each duplicate movieclip, but I am having problems with assigning the variable "i" (from the loop) to the function.

Here is the code:

------------------------------------------------------------------------

//setup thumbnails
for (tn=1 ; tn<6 ; tn++) {
duplicateMovieClip(thumbholder, "thumb"+tn, tn);
eval("thumb"+tn)._x = (tn*35)+148
loadMovie(section+"image"+tn+"_tn.jpg", eval("thumb"+tn).thumbimage);
this["pic"+tn] = tn

eval("thumb"+tn).onPress = function() {
imagechoice = "image"+eval("pic"+tn)+".jpg"
targeta = 0
loadimage = 1
showtext = 0
speed = 4
infotext = info[tn]
infobox._visible = false
logo._visible = false
}
}

------------------------------------------------------------------------

As you can see I have placed an eval("pic"+tn) to reference the loop variable, but it doesnt work.

Anyone got any ideas ?

Thanks

Steve

Loop Variable Not Working Inside OnRelease Function
Hello,

I've been lurking around these boards for quite a while and have found them to be invaluable help when I'm stuck on a problem, since someone has usually already had the same frustration as I have, and I can usually get the answer I need just from reading other posts... but not this time.

I'm having a problem with a photo album I am making in Flash. I have successfully gotten the thumbnails to load and display correctly by using a "for" loop (as seen below) but I run into trouble when I try to make the thumbnails clickable. It seems as though the "onRelease" function that I apply to each thumbnail MovieClip cannot read the "i" variable used in the for loop.

My code is as follows:

ActionScript Code:
/////////////////////////////////////////////////////////
archiveIn = new LoadVars();
archiveIn.load("readArchives.php");
archiveIn.onLoad = function(success) {
    if (success) {
        numOfDirs = archiveIn.numOfDirs;
        archiveDir = archiveIn.archive.split("|");
        archiveDir.reverse();
        width = archiveIn.thumbWidth.split("|");
        width.reverse();
        height = archiveIn.thumbHeight.split("|");
        height.reverse();
        firstClipPositionX = 0;
        firstClipPositionY = 0;
        highestThumb = 0;
        // Create all the thumbnail clips in a loop.
        for (i=0; i<numOfDirs; i++) {
            createEmptyMovieClip("archiveThumb"+i, _root.getNextHighestDepth());
            _root["archiveThumb"+i].createEmptyMovieClip("holder", this.getNextHighestDepth());
            _root["archiveThumb"+i].holder.loadMovie("weeks/"+archiveDir[i]+"/001_thumb.jpg");
            _root["archiveThumb"+i].createTextField("week", _root.getNextHighestDepth(), 0, height[i], width[i], 20);

--HERE IS WHERE THE PROBLEM LIES----------------------------------
            _root["archiveThumb"+i].onRelease = function() {
                getURL("viewer.php?dir="+archiveDir[i], "_blank");
            };

The "archiveDir[i]" returns "undefined."
----------------------------------------------------------------------------

            weekFormat = new TextFormat();
            weekFormat.font = "Arial";
            weekFormat.size = 10;
            weekFormat.align = "center";
            _root["archiveThumb"+i].week.text = "Week "+archiveDir[i];
            _root["archiveThumb"+i].week.setTextFormat(weekFormat);
            _root["archiveThumb"+i]._x = firstClipPositionX+10;
            _root["archiveThumb"+i]._y = firstClipPositionY+10;
            firstClipPositionX = Math.round(_root["archiveThumb"+i]._x)+Math.round(width[i]);
            if (height[i]>highestThumb) {
                highestThumb = height[i];
            }
            if ((i+1)%5 == 0) {
                firstClipPositionX = 0;
                firstClipPositionY = Math.round(_root["archiveThumb"+i]._y)+Math.round(highestThumb)+10;
            }
        }
    }
};
/////////////////////////////////////////////////////////
Everything works beautifully except for the onRelease function. If anyone out there has any advice for me, that would be great (or a solution... that would be even better ). At any rate, I'd really appreciate some help.

Thanks!
James

Function Nested Inside For Loop Looses Scope Of I Variable
Once agian I lost scope of my Var i. So far everything works except in the onPress function at the bottom of the code

I have tried to create a second var iVar = i but they both output as 7 regardless of what button insance it is attached to.

What do I need to do to keep the var i different for each instance created rather then the last number i is after my for loop is finished.



ActionScript Code:
function generateNav():Void {
    //
    var i:Number;
    var thumb;
    var xPos:Number = 259;
    var yPos:Number = 10;
    for (i=1; i<=6; i++) {
        thumb = attachMovie("hero"+i, "myHero"+i, this.getNextHighestDepth());
        thumb._x = xPos;
        thumb._y = yPos;
        xPos += thumb._width+10;
        if (xPos>550) {
            xPos = 259;
            yPos += thumb._height+10;
        }
        _root.holder["myHero"+i].onRollOver = function() {
            var s:Number = 5;
            //
            iVar = i;
            this.onEnterFrame = function() {
                if (this._alpha>=40) {
                    this._alpha -= s;
                }
            };
            this.onRollOut = function() {
                this.onEnterFrame = function() {
                    if (this._alpha<=100) {
                        this._alpha += s;
                    }
                };
            };
            this.onPress = function() {
                //
                trace(this.iVar+" Pressed");
            };
        };
    }
}

Passing I Value To A OnRollover Funcion HELP
I am trying to make a row of buttons depending on how many a person wants using flash and xml. But for some reason the rollOver function isnt working and the thumbnail images are not being set. Can some one hep me please.

for (i=0;i<_root.ThumbnailsImages.length;){
var t = _root.LowerSection.Thumbnails.attachMovie("LowerSection_Thumbnail_Container", "LowerSection_Thumbnail_Container"+i, i);

t._x = t._width*i;

t.ThumbPic.contentPath=_root.ThumbnailsImages;

t.Testimonial.text = caption;
var TestimonialColor:TextFormat = new TextFormat();
TestimonialColor.color = ColorCoding+_root.captionColor;
t.Testimonial.setTextFormat(TestimonialColor);

t.Thumbnail_Button.onRollOver = function(i){
_root.LowerSection.Video_Info.ClickedTitle.text = _root.clickedtitle;
_root.LowerSection.Video_Info.ClickedCaption.text = _root.clickedcaption;
}

i++;
}

OnRollOver Loop
is there any simple way to loop this???

the regular for loop doesnt work

book_1.onRollOver = function() {
var aumentaltura:Tween = new Tween(_root.book_1, "_y", Regular.easeOut, _root.book_1._y, _root.book_1._y-espaco, 0.5, true);
};

book_2.onRollOver = function() {
var aumentaltura:Tween = new Tween(_root.book_2, "_y", Regular.easeOut, _root.book_2._y, _root.book_2._y-espaco, 0.5, true);
};


ty

Loop With LoadMovie OnRollOver
i have a script that loads xml movies in a loop the only proplem is i want to have tooltips on it i am using this..


ActionScript Code:
function loadXML(loaded) {
    if (loaded) {
        xmlNode = this.firstChild;
        total = xmlNode.childNodes.length;
        for (i=0; i<total; i++) {
            swf = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
            isname = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
            tooltiptext = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
            cX = xmlNode.childNodes[i].attributes.xpos;
            cY = xmlNode.childNodes[i].attributes.ypos;
            _root.createEmptyMovieClip("Holder_" + i, i);
        _root["Holder_" + i].loadMovie(swf, isname);
            _root["Holder_" + i]._x = cX;
            _root["Holder_" + i]._y = cY;
            _root["Holder_" + i].onRollOver = function()
            {
            _root.showTip(_root.tooltiptext);
            trace("i like pie");
            };
        }
    } else {
        content = "file not loaded!";
    }
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("data.xml");

as you can see i use
ActionScript Code:
createEmptyMovieClip
so it should work, but it does not i have tryed events, and listners but still does not work can any one please help

[F8] Function Loop Takes Only Last "for" Statement Variable
I got an issue with my actionscript in flash 8.
I got a function that i need her to do this steps:
1. make and Array
2. push into the array from position 1 the values: "j+0", j+1","j+2"..."j+nrIntrodus"
3. in that for statement i need also to place a onPress function button(s).
4. it should generate the buttons based on the for stament above.
5. it should generate the contant of the onPress button function based on for statement.

The issue is like this. The array works to be created and to push variables from 2 in it. The for statement workd to dynamic create the bt1,bt2,bt... buttons on Press function......... but the
Code:
varReceiver["data"+arieLinkExt[temp]];
does not take dynamic data from the for statement. If var nrInceput:number=2... it takes only 2... not... 0 and then 1 and then 2.
and it will appeas if I press on bt1, bt2 or bt3 ony the
Code:
varReceiver["data"+arieLinkExt[2]];
.

How can I do to make it dynamic and not to wirte the code n times for onPress button functions?


Code:
var nrInceput:number=2
function btLinkPress(LinkExt3:Number) {
var arieLinkExt:Array = new Array();
for (var i3:Number = 0; i3<=nrIntrodus; i3++) {
arieLinkExt.push(j+i3);
temp = i3;
temp2 = eval("bt"+arieLinkExt[temp]+"NewsL");
trace(temp2);
temp2.onPress = function() {
popupC();
widget_popup.dynData.text = varReceiver["data"+arieLinkExt[temp]];
widget_popup.dynInfo.text = varReceiver["desc_mare"+arieLinkExt[temp]];
cssStyle();
};
}
}

OnRollOver() Applied To Multiple MCs Using For Loop
i have dynamically created text fields inside a movie clip.

i want to apply onRollOver and onRollOut events to all of them using a for loop.

here is the code:

Code:

for (var c = current; c<=total; c++) {
this["item"+c].onRollOver = function() {
this["item"+c+"Txt"].backgroundColor = 0x000000;
this["item"+c+"Txt"].textColor = 0xffffff;
this["item"+c+"Txt"].borderColor = 0xffffff;
};
this["item"+c].onRollOut = function() {
this["item"+c+"Txt"].backgroundColor = 0x0099ff;
this["item"+c+"Txt"].textColor = 0x000000;
this["item"+c+"Txt"].borderColor = 0x000000;
};
}



for some reason, everything in my file works except for the above code.

i have attached the file so it can be seen in context with the rest of the file. it's in flash mx format.

Simple Prob: Can't Get A Loop To Run With .onRollOver
I am trying to learn fadin of buttons using only actionscript - i have something working that eventually fades, but I have to repeatedly roll on and off it to fade (it doesnt loop by itself)


Code:


arrowR_btn.onRollOver = function()
{
if (arrowR_btn._alpha>30)
{
fade_btn();
}
}

fade_btn = function()
{
if (arrowR_btn._alpha>30)
{
arrowR_btn._alpha -= 5;
//fade_btn();<<IF I PUT that here, then it works, but
//will look like an instant change, but will go thru the code
}

}



I think the anwer has to do with onEnterFrame, but I played around with so many variations and looked at many help things on the net, but nothing could do it.

What am I missing?

Xml Menu: Onrollover Declared In Loop Not Working
Can somebody please help me with the following 'cause I'm confuesd, or overlooking something completely...

I'm building a small XML menu where I want to call a function for each subitem's onrollover

part of my code:


ActionScript Code:
//*** build submenu items ****for (j=0; j< numSubItems; j++){  curSubItemName = my_XML.firstChild.childNodes[i].childNodes[j].firstChild.nodeValue;  curSubItem = _root["item"+i].createEmptyMovieClip("subItem_"+i+"_"+j, myDepth);  curSubItem._y = (j+1)*-spacing;  myDepth++;  curSubItem.onRollOver = function(){    this.subHighLight();  }}

and the subHighLight function for now just looks like this:

ActionScript Code:
MovieClip.prototype.subHighLight = function(){  trace("test");};


The menu gets populated from the XML file, no problem. However, the onRollOver simply isn't working, but why???

Thanks.

Xml Menu: Onrollover Declared In Loop Not Working
Can somebody please help me with the following 'cause I'm confuesd, or overlooking something completely...

I'm building a small XML menu where I want to call a function for each subitem's onrollover

part of my code:


ActionScript Code:
//*** build submenu items ****for (j=0; j< numSubItems; j++){  curSubItemName = my_XML.firstChild.childNodes[i].childNodes[j].firstChild.nodeValue;  curSubItem = _root["item"+i].createEmptyMovieClip("subItem_"+i+"_"+j, myDepth);  curSubItem._y = (j+1)*-spacing;  myDepth++;  curSubItem.onRollOver = function(){    this.subHighLight();  }}

and the subHighLight function for now just looks like this:

ActionScript Code:
MovieClip.prototype.subHighLight = function(){  trace("test");};


The menu gets populated from the XML file, no problem. However, the onRollOver simply isn't working, but why???

Thanks.

Problems Duplicating MovieClip & Setting OnRollOver In A Loop
I can't seem to give the Duplicate Movie clips different onRollOver code.

Here is what I have so far


Code:
for (y = 2; y <= 10; y++) {
duplicateMovieClip("button_user", "button_user" + y, y + 1);

var movie = this["button_user" + y];

movie.onRollOver = function() {
changingVariable = 50*y;
};
}


You would think this would work but it give all the buttons the same value for changingVariable... Does anyone know what I can do to fix this problem and give each duplicated movie clip a different value for changingVariable in the onRollOver State?

Loop That Duplicates Items & Sets OnRollOver Probl
I want to create a loop that duplicates a MovieClip and also sets the onRollOver for that MovieClip... I am having a little trouble with setting the onRollOver for the Duplicates:

Here is what I have:


ActionScript Code:
for (y=2; y<=4; y++) {
    duplicateMovieClip ("button_user", "button_user"+y, y+1);
   
   
               //This is what I am having trouble setting...  The only thing I could think of (I posted it under this code) was using an array for the name but neither way work.  Using the array doesnt give an error though.   
               button_user+y.onRollOver = function() {
           gotoAndPlay(2);
    }
}




ActionScript Code:
for (y=2; y<=4; y++) {
    duplicateMovieClip ("button_user", "button_user["+y+"]", y+1);
   
   
                button_user[y].onRollOver = function() {
           gotoAndPlay(2);
    }
}

Getting Behind The OnRollOver Function
I'm have a component which is only to be shown when the mouse rolls over the component. For example an "edit" button. This basic idea works with:

component.onRollOver = function() {
component._visible = true;
}

However this cancels all other possibilities of interaction with the component, it is now impossible to press the "edit" button. Is there anyway to get around this?

OnRollOver Function Within A OnRollover Function
Hi all,

I have a movieClip that which is acting like a button. Once the user rolls over the movie clip, it will attach movieClip which again will act like buttons. The problem i'm having is that i cannot get the button events to work for the attached buttons. Here is my code:

PHP Code:



        phMC.onRollOver = function(){            
            for (var i:Number = 0; i<2; i++) {
                var posY:Number = phMC.mcInfo.ph._height;
                phMC.mcInfo.ph.attachMovie("mcBtnInfo", i, i);
                phMC.mcInfo.ph[i].txtInfo.text = "Test: " + i;
                phMC.mcInfo.ph[i]._y = posY;
                phMC.mcInfo.ph[i].btnBg.onRollOver = function(){
                       //this function is not working!!!
                        trace("over");                    
                }
            }





Thanks!

OnRollOver Function For Non-button MC?
Hey, this seems like there would be an easy solution, but I obviously am not aware of the syntax.

I am loading an external MC underneath a series of MCs in the main swf. I want the main MCs to fade to 50% when the mouse goes over them (to see what's under) but I can't use buttons to accomplish this, because the underneath layer has buttons in it that need to function at the same time.

Suggestions for an onRollOver method for non-button MCs?

QUESTION For OnRollOver = Function()
I have 3 questions as below, appreciate if someone could help~! thanks!

(1)inside a movieclip there is a statement like this.

ActionScript Code:
for (i=0; i<=8; i++) {
    _root['all_thumbnail_holder.' + i].onRollOver = function() {
        tellTarget ('_root.all_thumbnail_holder.' + i) {
            gotoAndPlay(1);
        }
    };
}
Does it mean the path become
_root.all_thumbnail_holder.0
_root.all_thumbnail_holder.1
...
_root.all_thumbnail_holder.8
?
don't why it doesn't work.... I think the path is incorrect??

(2)in addition, I have found another question on the function...
I have a mc called "holder" in root and there is a mc "1" in the "holder"
Why would this one contain syntax error?

ActionScript Code:
_root.holder.1.onRollOver = function()

while this one is correct....? (however, all my mc inside the "holder" are in numbers not in alphabets...)

ActionScript Code:
_root.holder.a.onRollOver = function()

(3) What's wrong with this statement?
'_root.holder' + i = function()
click here
while this one is correct??
_root['holder.' + i] = function()

what is the meaning of "[" and "]" here??

sorry about all these stupid questions.
Thanks!!

Delete OnRollover Function
how do i delete a onRollover function for a mc?

if i have this AS for a mc:

movieClip.onRollOver = function() {

movieClip.glow._visible = 1;

};

and then later on down the timeline don't want the (movieClip.glow._visible = 1;) action anymore, how do i delete it without using:

movieClip.onRollOver = function() {

};

thanks in advance

Help With OnRollOver Stop Function
I have a slideshow made up of about 21 photos and each one is on a different layer and each has a fade in and out transition applied to them. I want to be able to stop the slideshow when a rollover occurs. I've tried various types of code and none of them get close. I was wondering if anyone could possibly help me with this. Thanks.

Urgent Help With OnRollOver Function...please...
Ok...I have a written 2 functions, 'over' and 'out'...these are used to control the rollover and rollout states of multiple buttons. That all works fine. YOu will also see from the example that each button also controls a movie and onRelease loads it into a movie clip holder. Again...that all works fine.

However, I want the movie clip to be loaded in the holder during the onRollover state now and not the onRelease...how to I rewrite the below function to achieve this, remembering that every button loads a different movie clip on the onRelease state but uses the same functions, 'over' and 'out'......

Please help...urgent help required.

side_btn.onRollOver = over;
side_btn.onRollOut = out;
side_btn.onRelease = function() {
loader._visible = true;
mcl.loadClip("side_shoe_big.swf", holder);
}

function over () {
this.gotoAndPlay(2);
}
function out () {
this.gotoAndPlay(7);
}

PLease help...thank you.

TheButton.onRollOver=function()
Hi all,
I have a button that when I roll over it I would like the script to automatically place the menu name on the button.  So, the button would be blank until you go over it and then it would say "Profile" or something like that.  

Is this possible to do in the actions frame?

Thanks,
Hailey

How To Get The Button Name In A Variable Using OnRollOver?
I want to capture the button name when someone rolls over the button - and then use it to activate a sound. Can someone help me out? This is the idea - but I'm not sure if AS can do what I want:


Code:
onRollOver=function(){
var buttonName = this._name;
var buttonName_sound = (this._name+"_sound");
playing=true;
var buttonName_sound:Sound = new Sound();
buttonName_sound.setVolume(100);
buttonName_sound.loadSound("_sounds/"+buttonName+".mp3",true) //streaming
}

buttonName.onRelease = function() {
buttonName._alpha = 50;
}

buttonName.onRollOut = function() {
buttonName._alpha = 0;
}
I'll use the buttonName for everything.

Thanks again!

Ben

OnRollOver For 2 Sec Then Execute A Function Or Tweening
Hi,

I made a menu with buttons.
When i go over a menu a submenu will appear. I just play a tweening.
The submenu slides from left to right.


Code:
menu_mc.m_info_btn.onRollOver = function(){
_root.menu_mc.gotoAndPlay("over_info");
}

Then i created a button with only hotspot in HIT.
So when someone goes over the invisble button the submenu will dissapear.

But i'd like a delay.
So when the person hits the invisible buttons during 2 seconds then the submenu should dissapear.

Cause right now I have the menu on top left.
And you go over it. The submenu appears under the menu. But when you want to quickly go the right side of the submenu you might touch the invisble hotspot and then the submenu dissapears.
Thats why im looking for a way that you have to be atleast 2 sec on the invisble button before it should starting dissapearing(tweening)

Hope you guys can help me out.

Gosa

Button.onRollOver = Function (argument)
hello,

is there a way to pass an argument to a function that's being assigned to a button event.

i have a function

Code:
function scroll(direction,speed)
{
//
}

thumb.scrollUPslow.onRollOver = scroll(1,1);
that doesn't work. is there a way around this problem?

thank you

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