OnRollOver = Function() --> Return Dynamic Button Name
I've got a set of dynamically created listElements wich are Buttons. When I roll over them I want them to trace thier names(numbers). The following script doesn't work, the last value of "i" is alway returned instead of the number corresponding to the aktual listElement. Any ideas??
thx Alex
PHP Code:
this.onEnterFrame = function(){ for(i=0;i<numElem;i++){ this["listElement"+i].onRollOver = function(){ trace("listElement"+i); } } }
FlashKit > Flash Help > Flash ActionScript
Posted on: 05-04-2004, 12:45 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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?
Calling Function From OnRollOver In Dynamic MovieClip
I'm having some trouble calling a function from the "onRollOver" event of a dynamically created mc.
In the code below, I've created a mc inside another mc in the function "makeMyMovie". This works fine. Problem is in the "onRollOver" I'm trying to call "testFunc()" but it doesn't reach there.
I know the "onRollOver" works because 'trace("A")' works.
code:
myClass.prototype.makeMyMovie = function() {
this.mymainMov = createEmptyMovieClip("mainMov", 2);
this.mymainMov.createEmptyMovieClip("mc1",i+10);
// content of mc is created here
this.mymainMov["mc1"].onRollOver = function() {
this.testFunc();
trace("A");
}
};
myClass.prototype.testFunc = function() {
trace("testing");
};
Any ideas would be greatly appreciated...
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
[F8] Disable/enable Then Return To OnRollOver?
I have searched through the forums for a solution to this but came up empty handed. Here is my issue... I have 3 movieclips as buttons. When I click on one it becomes disabled and leaves the other 2 enabled. When I click on another button, the first one clicked becomes active again (this is what I want it to do) HOWEVER, once a button becomes enabled again it remains on its RollOver state. How can I reset it to become active AND THEN animate back to its original state (following the onRollOut animation)?? Any ideas? My head hurts from beating it against the desk.
Code:
function enableBtns(){
print_txt.enabled = true;
web_txt.enabled = true;
digital_txt.enabled = true;
}
print_txt.onRollOver = function() {
this.print_txt.colorTo(0xFAF9F6, .5);
this.print_txt.tween("_x", 0, .2, "easeOutBack");
};
print_txt.onRollOut = function() {
this.print_txt.colorTo(0x86846E, .5);
this.print_txt.tween("_x", 8, .2, "easeOutBack");
};
print_txt.onPress = function() {
enableBtns();
loadMovie("print.swf","container_mc");
this.enabled = false;
}
web_txt.onRollOver = function() {
this.web_txt.colorTo(0xFAF9F6, .5);
this.web_txt.tween("_x", 22, .2, "easeOutBack");
};
web_txt.onRollOut = function() {
this.web_txt.colorTo(0x86846E, .5);
this.web_txt.tween("_x", 31, .2, "easeOutBack");
};
web_txt.onPress = function() {
enableBtns();
loadMovie("web.swf","container_mc");
this.enabled = false;
}
digital_txt.onRollOver = function() {
this.digital_txt.colorTo(0xFAF9F6, .5);
this.digital_txt.tween("_x", 1, .2, "easeOutBack");
};
digital_txt.onRollOut = function() {
this.digital_txt.colorTo(0x86846E, .5);
this.digital_txt.tween("_x", 9, .2, "easeOutBack");
};
Return Movie Clip Instance Name OnRollOver
Hi All,
Sorry if this is a stupid questions but I am relatively new to actionscript.
I have a movie clip on the main timeline that contains a large number of clips that I am storing different pieces of information against.
I want to dynamically return the movie clip instance names of the clips in the container with a rollover function so I can pass the instance name into custom class.
I am wanting to use a function that will treat the returned instance name as a variable that I can pass into the custom class as to avoid having to code the class function against each individual movie clip.
Is this possible as I have been searching for ages and have not found anything that accomplishes this.
Many thanks in advance
AS2: What Datatype Should A Function Return, If It May Not Return *anything*?
The title of this post may not make much sense, let me explain...
I have a function:
findSurface(origin:Point, vector:Point, attempts:Number):Point {...}
The function has an obscure use, but the idea is thus: given those three arguments, returns a point IF the 'line' (created by the origin and vector arguments) intersects the object the function is called on. [but that is another story...]
More importantly, if there is no point of intersection at all, what should the function return? Void? Null? Undefined? Object? Or can I use one of those return types instead of Point incase the function does not encounter an intersection?
I'd be glad to try explaining better if anyone might know, thanks.
_root["button"+i].onRollOver = Function()
_root["button"+i].onRollOver = function()
can anyone explain to me why theres no "." between the array and _root? cos isnt it supposed to be something like, _root.buttoni.onRollOver = blabla, just with a dynmaic entry for the button?
thanks!
Christoph
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!
Return Function Name (Function => String)
I keep coming across problems where it would be really convenient to get the name of a function in string format - like arguments.callee only a string instead of [Function, Function].
I haven't thought of a way to do this but in my head the keywords 'prototype' and 'override function' keep coming up - albeit that seems like a horrible horrible idea, but Function does extend Object so...thoughts?
Return From Function Called Within Function
How do I return the output from getTrialsHandler to getTrials when calling getTrials?
// THE CALL
trace( getTrials(1,16) );
// THE FUNCTIONS
function getTrials(day, userID){
var pc:PendingCall = service.getTrials(day, userID);
pc.responder = new RelayResponder(this, "getTrialsHandler", null);
}
function getTrialsHandler(re:ResultEvent, day){
if(!re.result){
trace("ERR: load trials for day"+day);
} else {
trace("SUC: load trials for day"+day);
if(re.result[1] > _root.currentDay){
goto = "closed";
} else if(re.result[0] < 5){
goto = "open";
} else if(re.result[0] == 5) {
goto = "full";
}
out = (re.result[0]+"::"+re.result[1]);
}
return out;
}
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
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 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
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!
A Little Help With Fuse:Adding An OnRollOver Function
I have followed the Fuse tutorials here and got them working just fine. However I have been tweaking things to experiment and get to know it better.
I am trying to get an onRollOver function to fire off a tween but it's not working. A mouse over of the 'Leader' mc is not even changing the cursor to suggest there is an event there.
Here's the .as
Code:
import com.mosesSupposes.fuse.*;
ZigoEngine.register(Fuse, PennerEasing);
this.createEmptyMovieClip("leader", 1);
function moveLeader():Void
{
var f:Fuse = new Fuse();
f.push({target:leader, x:80, y:550, controlX:90, controlY:150, time:1.5, ease:"easeInOutQuad"});
//f.push({func:moveLeader});
f.start();
}
function roll():Void
{
var r:Fuse = new Fuse();
}
moveLeader();
this.onEnterFrame = function()
{
var t:MovieClip = this.attachMovie("circle","c"+this.getNextHighestDepth(), this.getNextHighestDepth());
t._x = leader._x;
t._y = leader._y;
var f:Fuse = new Fuse();
f.push({target:t, scale:50, tint:Math.random()*0xFFFFFF, alpha:0, time:1, ease:"easeOutExpo"});
f.push({func:function(){t.removeMovieClip();}});
f.start();
}
this.leader.onRollOver = function()
{
var f:Fuse = new Fuse();
f.push({target:leader, x:80, y:550, controlX:90, controlY:150, time:1.5, ease:"easeInOutQuad"});
}
I have tried wording the onRollOver function a few ways (leader.onRollOver, this.onRollOver, this.circle.onRollOver, circle.onRollOver)
But none seem to work.
What am I missing ?(apart from a basic understanding of AS :? )
Crowds
Problem With Dynamically Assign OnRollOver Function
Got a small problem with assigning onRollOver / onRollOut functions to movieclips in a for loop.
Code sample:
Code:
for(i = 0; i < num_squares; i++){
clip = "window"+i;
this.attachMovie("window",clip,100+i);
this[clip].onRollOver = function(){
eval(clip).resize_me(200,200,.2);
}
}
This always makes the last instance number resize when i mouse over any of the clips. (if num_squares = 6, it makes window5 resize)
Another thing i've noticed is if I use
Code:
this[clip].resize_me
it doesnt do anything, not even a mouseOver pointer.
Thanks
Making Text Selectable Though It Has OnRollOver-function?
Hi!
I've got a text inside a movieclip that has an onRollOver-function (the function basically says: display me on mouseover, hide me on mouseout).
My problem is that I still want the text to be selectable! I've tried setting the .useHandCursor = false without success (the cursor changes but the text is still not selectable). Is there anyway I can have an interactive text that responds to the mouse cursor, but that is still selectable?
Any help greatly appreciated!
Thanks a lot /Tove
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
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
Asign OnRollOver Function To Movie Clip
is there any vay to assign functions to MCs after I load externel jpg
into them?
This is what I mean.
var mclListener:Object = new Object();
var thb_mcl = new MovieClipLoader();
function ld_mov1() {
for (i=1; i<=16; i++) {
thb_mcl.loadClip("./paintings/"+i+".jpg", "thb"+i+"_mc");
eval("thb"+i+"_mc").onRollOver = function(){
trace(something)
}
}
}
well, this works fine before I load the JPGs.
is there any solution for this?
LoadClip Letting Me Attach OnRollOver Function
var container:MovieClip = createEmptyMovieClip("container", getNextHighestDepth());
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(this);
mcLoader.loadClip("zelda.jpg", container);
_root.container.onRollOver = function(){
trace('ZELDA!');
}
/*Now this SHOULD trace back 'ZELDA!' when I click on the picture of Zelda... Right? It doesnt, what am I doing wrong? Please help.
OnRollOver = Function Wont Use Alpha Fade In
So iam am trying to get my movie clip to recognize that on rollover i want the invisible clip to appear but , i set an animate function that tells it to slowloy appear by using alpha but it wont work can u guys check my code and correct it for me so it will work properly.. Thanks US!!!
ActionScript Code:
mcBut.mcEffect._visible = false;
mcBut.onRollOver = function () {
mcBut.mcEffect._visible = !mcBut.mcEffect._visible;
animate();
};
function animate() {
mcBut.mcEffect._alpha+=5;
updateAfterEvent();
}
mcBut.mcEffect._alpha = 0
var Interval:Number =setInterval(animate,1)
Return Function
Can somebody tell me how can I use return function for my film:
I have a large movie with 20 scenes and in every scene I have a webservice from where can user going to sitemap. But if user choos nothing, can he click return button, and appear again in the same scene and in the same position(I mean keyframe) from where he went.
If someone know return function, please tell me....
Function =>return Value ?
hey,
I wonder if anyone has any ideas how to do this :
I have a function written
Code:
javascript.openConfirm = function(message_str){
responsSet_bol ="false";
getURL("javascript:var respons = confirm('" + message_str + "');void(0);javascript:window.document.popup.SetVariable('respons_str',respons);javascript:window.document.popup.SetVariable('responsSet_bol','true');");
return respons_str;
}
what i want to accomplish is a confirm window(ok, cancel) and I want the answer to be returned
I call this like so:
Code:
respons = javascript.openConfirm("wilt ge dit?");
the problem is that the string is returned, before an answer is set by the confirm window.
does anyone have any ideas how to do this?
Return Value From Function
Hi,
this should be easy:
I have a little text function that works fine when I have it on frame one of a root MC that loads other MCs at runtime.
ActionScript Code:
function xvStrng(sText:String) :String {
var revText = "";
// code modifying sText
return revText;
}
I also have classes included in the root MC. The classes' functions work fine from all MCs, but non of them has to return anything.
When I put the "xvStrng" function into a class and call:
ActionScript Code:
someVariable = className.xvStrng("someString");
all I receive in "undefined".
Any ideas?
Thanks
David
How To Return In This Function?
Hi guys, hope you can help me on this one.
I have a class to load an XML file. I’m trying this:
Code:
package {
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.events.*;
public class retornaXML{
private var _xml:XML;
public function retornaXML() {
cargarXML();
}
private function cargarXML():void {
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, xmlLoaded);
loader.load(new URLRequest("LocalData.xml"));
}
private function xmlLoaded(e:Event):void {
_xml = new XML(e.target.data);
trace(_xml);
//THE TRACE HERE WORKS PERFECT AND RETURNS THE XML
}
public function get elXML():XML {
return _xml;
//THIS RETURNS null
}
}
}
I want something like this:
var mivariable:retornaXML = new retornaXML();
trace(mivariable.elXML);
but this trace returns null, since the xml file (I think) is not loaded yet. What should I do?
Thanks in advance.
HELP-Why Won't This Function Return A Value
I want to get this XML data OUT of the function, but it just won't work. What I am doing wrong??? Tracing "xmlList" gives me the output i want IN the function, but if I can't get it OUT. If i set the function to "String", I still can't get the function to return a value or anyway to get this data OUT of the function. Please help.
var xml:XML;
var xmlList:XMLList;
var xmlLoader:URLLoader = new URLLoader;
xmlLoader.load(new URLRequest("data/imagesT.xml"));
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
function xmlLoaded(event:Event):String
{
xml = XML(event.target.data);
xmlList = xml.children()[0].child(2);
}
How To Return A Value From A Function, Maybe
Hello, first post :)
Here is my problem: In the attached .fla, I have a wheel of fortune style game which stops at a random point.
I've been able to test where the wheel stops using hitTest, and would like to output the result to the trace (for now).
My if statement which does the hitTest(s) is nested inside the function which slows and stops the wheel spinning (slowdown).
The problem is that function uses onEnterFrame, so my trace messages go into an endless loop.
So my question is how to test that the wheel has stopped spinning from outside the function, where to put the hitTests? My guess is it could involve getting the function to return a value, but I'm not sure.
Thanks in advance.
AS3 - Return Value From A Function.
Hey i am having a problem getting a value out of a function. It has been driving me crazy tried many ways of doing this... found a way to accomplish it in the .FLA file and it worked fine. But when i am working in .AS it just doesnt seem to work. Please help!
PHP Code:
public function parseUsers(usrInput:XML)
{
var userType:String = usrInput.Users.userType.toString();
trace("Username: " + usrInput.Users.userName + " User type: " + usrInput.Users.userType);
return userType;
}
The xml loads find parses fine everyting works inside the function... now how do i get those values out??? and how would i use them in a .swf ? Thanks in advance!
Function And Return
Hello,
I'm pretty newbie to actionscript 2, so my question might sound easy.
I can't understand the use of 'return' in a function.
If I write
ActionScript Code:
function some(num:Number) {
number = num * num;
}
some(8);
trace(number);
well, it works.
I could also have written
ActionScript Code:
function some(num:Number) {
var number = num * num;
return number;
}
some(8);
trace(number);
It works also, but I'm wondering why not using the first case?
Is 'return' used only where variable names might conflict with the rest of the code?
And, if I use methods within the code, the results of which are global, why should I use the return keyword, which is to resolve the 'locality' of functions?
thank you very much
m.
Function Return
hey,
I'm trying to make a function in flash to call a confirm dialog box through javascript. I wrote this function to open the confirmdialogbox and then storing the value in a variable respons and then sending this variable to the swf. At the end I return the value.
Code:
javascript.openConfirm = function(message_str){
responsSet_bol ="false";
getURL("javascript:var respons = confirm('" + message_str + "');void(0);javascript:window.document.popup.SetVariable('respons_str',respons);javascript:window.document.popup.SetVariable('responsSet_bol','true');");
return respons_str;
}
Now if I call this function doing this :
Code:
respons = javascript.openConfirm("ben je zeker dat je dit wil?");
the returned value isn't stored in the respons variable.
The reason I think is because the value is returned before you click one of the 2 buttons(ok or cancel).
does anyone have any idea how to avoid this. or an other method so the return value is the same as the button clicked
I really need some help, cause I'm stuck
[MX04] Workaround To Pass Argument To OnRollover Function
Hi,
I have this loop:
Code:
for (i=0; i<links; i++) {
_root.ballSet["ball"+i].ball.onRollOver = function() {
_root.angle=.5;
_root.myLinkText.text = _root.myLinks[i];
};
}
i need a way to pass 'i' to the onRollOver function, but it seems like it's not possible. Is there a workaround?
thanks
Can The OnRollOver Function Register As Soon As I Roll Over The Movie Clip?
I have some simple ActionScript going where it creates an empty movie clip and adds some dynamic text as well as attaching a movie called thistle to via the library.
The problem I am having is since the thistle movie clip in the library is not fully square the mouse can only click on it when it hovers over the graphics exactly. I would prefer that it just used the boundary of the movie clip rather than the outer edges of the graphic.
Is there anyway in ActionScript that would allow me to have the onRollOver function register as soon as I roll over the attached movie clip rather than when it actually meats some from of drawn line inside the movie clip.
Here is my code that creates the empty movie clip and adds in a text field and a movie clip called thistle:
ActionScript Code:
for (var i:String in menuArray) {
txt = "txt_"+i; mc_txt= "mc_txt_"+i; thistle_mc = "thistle_mc"+i;
this.createEmptyMovieClip(mc_txt, this.getNextHighestDepth());
this[mc_txt].attachMovie("thistle", thistle_mc, 2, {_x:startMenuX, _y:startMenuY+10});
var trans:Transform = new Transform(eval(mc_txt+"."+thistle_mc));
trans.colorTransform = new ColorTransform(0, 0, 0, 0, 0, 0, 0, 100);
this[mc_txt].createTextField(txt, 1, startMenuX+20, startMenuY, 150, textHeight);
eval(mc_txt+"."+txt).text = menuArray[i];
var my_fnt:TextFormat = new TextFormat();
my_fnt.font = "Rage Italic";
my_fnt.bold = true;
my_fnt.size = 22;
eval(mc_txt+"."+txt).setTextFormat(my_fnt);
startMenuY+=textHeight;
this[mc_txt].onRollOver = clickHandler;
}
Thanks
[Type Function] Return? Wtf Is This?
I have script that creates an array of numbers, randomly choses one from that list, assigns this number to one of the MC's depth, removes it from the array, then moves on to next MC. The purpose is to randomly generate Depth levels.
v_?? are variables
a_?? array
c_?? Clips (MC's)
i_?? interger counters
f_?? functions
when I "trace" the result for the FishA, it displays [Type Function], OR reports the depth is -16383 (or some ridiculous #)
what have i done wrong? What does [Type Function] mean?
onClipEvent(load){
v_Depth = 0;
a_Depth = new Array();
for(i_Count = 0; i_Count < 30; i_Count ++) {
a_Depth [i_Count] = i_Count;
}
function f_SetupDepth(fv_MC) {
v_Depth = random(a_Depth.length);
trace(v_Depth);
_root[fv_MC].swapDepths(Number(v_Depth));
a_Depth.splice(v_Depth,1);
}
f_SetupDepth(c_Column1);
f_SetupDepth(c_Column2);
f_SetupDepth(c_Column3);
f_SetupDepth(c_Column4);
f_SetupDepth(c_Column5);
f_SetupDepth(c_Column6);
f_SetupDepth(c_FishA);
}
HELP Need A Function To Return 2 Values
ok, i've written a function and im trying to get it to return 2 different values
example of what i need
Code:
thisArray = myFunction(args)
----output----
thisArray[0] = first value
thisArray[1] = second value
is there a way to do this?
or do i return 1 string value which is a concantenated string of 2 values with an identifier in between?
Code:
thisVariable = myFunction(args)
thisArray = split(thisVariable, ":")
----output----
thisArray[0] = first value
thisArray[1] = second value
where the : is the identifier
im trying the second method now, but for some reason it returns 'undefined' all the time...
Return As Function Parameter
how to return true/false (or anything at all), when the parameter is a function?
code:
function f(g, arg) {
g.call(this, arg);
}
//simple working example
function move(mc) {
mc.onEnterFrame = function() {
this._x += 5;
};
}
f(move, ball);
//not working
function returnV(v) {
return v;
}
trace(f(returnV, true));//outputs undefined
function returnV2() {
return true;
}
trace(f(returnV2));//outputs undefined
Return Array From Function?
hi,
i have a function that takes an xml file as an arguments, reads the data and puts it into an array.
how do i get that array returned outside of the function?
i've tried " return array; " to no avail.
code:
function loadList(filename) {
audiolist = new XML();
audiolist.ignoreWhite = true;
audiolist.load(filename);
trackArray = new array();
audiolist.onLoad = function(success) {
loaded = true;
totalNodes = audiolist.firstChild.childNodes.length;
for (a=0; a<totalNodes; a++) {
thisCD = audiolist.childNodes[a]
tracklist = thisCD.childNodes.length;
for (i=0; i<tracklist; i++) {
trackArray.push(thisCD.childNodes[i].childNodes[0].nodeValue + ":" + thisCD.childNodes[i].attributes["id"]);
}
}
return trackArray();
}
}
onEnterFrame = function() {
if (!loaded) {
myArray = loadTrackList("tracklist.xml","")
for (i=0;i<myArray.length;i++) {
trace(myArray[i]);
}
}
What Does The CreateTextField() Function Return?
Hey everyone,
I've tried tracing a number of createTextFeild() functions and keep recieving 'undefined.' I suspect my problem is that the function doesn't actually return anything. Can anyone confirm this?
Thanks,
Greenham.
Return XMLNode From Function
Why is it that the trace from within the readXML function traces the XMLNode as expected, but the trace from within the onLoad returns undefined?
Shouldn't they trace out the same thing. Why doesn't the readXML function return the XMLNode?
ActionScript Code:
var myXML:XML = new XML();
var itemsNode:XMLNode;
var imageNode:XMLNode;
submitBut.onRelease = function() {
myXML.load("thisXML.xml");
}
myXML.onLoad = function(success) {
if (success) {
trace("From Load: " + readXML(myXML, "Items");
myText.text = readXML(myXML, "Items");
} else {
myText.text = "There was an error loading.";
}
}
function readXML(startNode:XMLNode, targetNode:String):XMLNode{
if (startNode.hasChildNodes) {
for (var i = 0; i < startNode.childNodes.length; i++) {
if (targetNode == startNode.childNodes[i].nodeName) {
trace("From read: "+startNode.childNodes[i]);
return startNode.childNodes[i];
}
readXML(startNode.childNodes[i], targetNode);
}
}
}
Thanks.
_t
Return Loaded XML From Function?
Hey everyone
I'm trying to figure out how to do this. I'm making an XMLLoader class, that I want to be able to use like this:
Code:
var myXML:XML = XMLLoader.load("SELECT * FROM table");
trace(myXML); // traces the loaded XML
I just can't figure out how to make the load function inside XMLLoader return the XML object... I can easily register an evenlistener that calls another function when the XML is loaded.. but how do I then make the load function return this XML? I want to do this:
Code:
package
{
public class XMLLoader
{
public function XMLLoader()
{
trace("Constructor called");
}
public function load(sql:String)
{
// Call a php site to recieve XML
// add listener to notice when XML is loaded
// return the loaded XML
}
}
}
The thing is, that I want to keep all event-stuff inside my XMLLoader, so I can use the class like the first example.
One way around it is to make a while loop inside the load function that checks whether a boolean is tru or false. When the XML is loaded, I set that boolean to true and the laod function returns the XML. But it's really taking up all the CPU power, and NOT a nice solution..
In a bunch of other programming languages you have the sleep function, that let's you sleep e.g. a part of a functions code until a variable is set, and then you can return it only when it is set.
How do I do it?
How To Return The XML Data From Function.
hi,
I am new to ActionScript. i need help from you. how to return and get the xml Data from function. this is my coding.
package {
import flash.events.*;
import flash.net.*;
import fl.data.DataProvider;
public class LoadXml
{
static var xmlData:XML =new XML();
public function LoadXmlFn():XML
{
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("DomainDetail.xml"));
xmlData=xmlLoader.addEventListener(Event.COMPLETE, LoadedXML);
return xmlData;
}
public function LoadedXML(e:Event):XML
{
xmlData = new XML(e.target.data);
return xmlData;
}
}
}
Please help me..
Advance thanks.
Different Return Values For A Function?
Hey,
I have a function which could return different types of possible datatypes,
depending on the input. What should i set to be the return value of the function in the definition?
Isn't this ok:
ActionScript Code:
public function getSubData(inDataType:string):Object {
var obj_to_return:object;
if (inDataType == "arr") {
obj_to_return = global_array; //An array with some sprites in it.
}
else if (inDataType == "sprite") {
obj_to_return = global_array[0]; //A sprite
}
return obj_to_return;
}
When using the function in my code:
var sprite_obj:sprite = getSubData("sprite");
i get:
"1118: Implicit coercion of a value with static type Object to a possibly unrelated type..."
Is this possible?
Thanks,
Guy
Return Function W/ SetInterval
I want to have a function that returns a value...this function will be called by setInterval.
The problem is...the function will return a value. I want to make sure that value goes to the proper variable. How can this be done?
Code:
EX:
function test(someInput){
return (someInput = 'dork');
}
interval_ID = setInterval(test, 10000, someInput);
// let's say i have a variable call "show"
// show should contain the return variable
Now, I tested out to see if I can pass a variable by address or reference to avoid 'return'...but it doesn't work. However, arrays can be used b/c it can be passed by referenced.
For example:
function test (theArray){
theArray[0]='dork';
}
var myArray = new Array();
myArray[0] = 'not a dork';
zeroArray(myArray);
trace (myArray[0]);
If you know how I can accomplish the same concept w/out using arrays, let me know.
thx in advance
|