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








Calling Javascript Functions From Actionscript 2


Hello

I am having trouble calling a function in a separate .js file using actionscript 2.

Is this actually possible?

I have a Flash 8 login form and I need it to pass the username and password to an AJAX function in a separate file.

Thanks anyone




Adobe > ActionScript 1 and 2
Posted on: 12/21/2007 05:00:18 AM


View Complete Forum Thread with Replies

Sponsored Links:

Actionscript Not Calling Some Javascript Functions In IE
Hi guys,

I've been having some problems in Flash MX 2004 with regards to calling Javascript functions in IE.

I've got two actions assigned to a button. The first one calls a Javascript function in the HTML page, sending it some variables which update the contents of the HTML page.

The second action then changes the visibility of the DIV that has just been updated.

All works hunky-dory in FireFox, but only does the show/hide DIV bit in IE. Anybody come across any quirks with calling a Javascript function with variables in IE (6 on Win2k)?

Code example...

on (release) {
getURL("javascript:MM_setTextOfLayer('calculator', '','calculator');void(0);");
getURL("javascript:MM_showHideLayers('calculator', '','show')")
}


After seeing some advice that maybe adding the void(0) to the end of the call may help it, I've tried that, but to no avail.

I know that the JS function isn't being called because I've replaced my original function with a simple JS function that just makes an alert window that says "OK". As I say, it works fine in Firefox, but not IE...

Any help is hugely appreciated

View Replies !    View Related
Adv Actionscript: Calling Functions From Array Or XML
The question is twofold. I've written a group of functions. I want to call the functions based off of entries in an xml file. So, XML 1 will call function 4. XML 2 will call function 1, etc...

What happens is this, the string in the xml file relates to a function in my actionscript, however Flash is only recognizing the string as a string, and not as one of the functions in my code. I've tried strict datatyping the xml text to a variable...

Code:

var functionname:Function = xmlNode.childNodes...nodeValue


I then push the variable to an Array, and call the element in the array on a button click. If I trace my variable, it has the same name as my function, but my function isn't running

...2nd part, Other languages have what's called "collections"...for example, when compiling in .Net, or a similar language, I can use a global "collection" reference to access any of the function written in the code. Does Actionscript have a similar reference? (not only for functions, but for say Movie Clips, images, sounds, etc)

thnx,
-j

View Replies !    View Related
External Actionscript And Calling External Functions
I have not been able to figure out or find a good tutorial on how to use external actionscript or how to call functions located externally. What I have found in flash help and livedocs has not proved to be helpful and I have not managed to make it work. Has anybody seen anything?

Even a simple thing, such as creating an external function that tells a button to go to the next frame and how to call that in my flash file would be greatly helpful.

View Replies !    View Related
[F8] Calling Functions Within OnEvent Functions.
Ive just stumbled upon an annoying problem, Im writing a custom class which, in its constructor attaches a movie clip to a main one (passed in as a parameter).
this all works fine.
My problem arises when i try to, also in the constructor, create an onRollOver event on the movieclip i attached earlier (its stored in a field).

The onRollOver event works fine, calling the trace statement ive been using, but it won't call any function which i ask for.


this is the code where im having issues:


Code:

function Corner(xPosition:Number, yPosition:Number, circ:Circle, deep:Number, baseClip:MovieClip)
{
this.image = baseClip.attachMovie("Corner","CornerX",deep);
this.image._x = xPosition;
this.xPos = xPosition;
this.image._y = yPosition;
this.yPos = yPosition;

this.circle = circ;

this.image.onRollOver = function()
{
trace("debugOne"); //this trace statement works fine

this.otherFunction(); //Problem is here, The code wont call this function for some reason
}

this.depth = deep;
}

function otherFunction()
{
trace("debugTwo");
}
any ideas why its not calling my function?

View Replies !    View Related
Calling Functions
I have a movieclip that calls a function which in turn calls another function, but the code is executing more than once a frame. How do I have the code execute once every frame? Thanks.

View Replies !    View Related
Calling Functions
Hi there,

I was wondering if the following is possible, and if so, how.


I've declared 11 functions for 11 different levels of a game, called level1 to level11

when calling the different level-functions, i want to use a variable, like so:



function level1() {
what it does
}

function level2() {
what it does
}

etc.

levelcounter++

["level" + levelcounter]() //this being the function call


...or something like that

but this doensnt work,
anyone any idea?

View Replies !    View Related
Calling Functions
How is it possible to call functions in a path set dynamicly?

thanks for advanced

View Replies !    View Related
Calling Functions In MX
Hi I am trying to call this very simple _root-based function from an MC instance "Daddy", which contains another Mc instance "Sonny":



function ShakeIt (ParentMC,ChildMc,valX,valY){
_root.ParentMC.ChildMc._x=random(valX);
_root.ParentMC.ChildMc._Y=random(valY);
}



This is the call for the function attached to the "Daddy" instance:


onClipEvent (enterFrame){
_root.ShakeIt ("Daddy","Sonny",10,20);
}



The movie does not throw any errors, I have fired the function to see the values do exist and they do. But the function is simply not executed and I do not understand why. The only way it works is if I scrape the function and execute de actions straight from the "Sonny" Mc which destroys the whole purpose of the ShakeIt function being a re-usable function.

I have also tried to make the ShakeIt function global and this still doesn't work. I am new to flash MX so I would expect it being something really simple to do with paths that I cannot see. So if anyone could please tell what I am doing wrong I would be grateful!

Cheers.

View Replies !    View Related
Calling Functions
i have six sunbeams. they all need to do a function every frame. so i define the function in the clip which all the sunbeams are in. i then have
sunbeam1.onEnterFrame = function() {
beamfade();
}
and so on up to sunbeam6. the problem is, the function beamfade wants to change the _alpha of the sunbeam. but i can't seem to make it change that _alpha - it goes and changes the _alpha of the clip where the function is defined.
i can't work out how to call the function so it will do the function "within" the sunbeam and so change the sunbeam's alpha.

thanks

View Replies !    View Related
Calling Functions, Without Exactly Saying The Name
Hi,

You normally call a function like this: function_name(), and movieclips can be called like this: _root["1stpart"+second_part+"third_part"]._x += 50 (you can have any name in there, so long as it ends up equaling the name of the movieclip).

I want to call a function like that, anybody know how to do it?

Regards,

View Replies !    View Related
Calling Functions One By One
i ve a simple problem, but not able to find solution. i have this small flowchart. and each part of flowchart appears one by one with different effects to them . i ve written fuctions for each of these effects. and now i want to call these fuctions for each of these parts one bye one.
one way of doin it is by putting each part(they are all movieclips now) in seperate frame. but how the same thing can be done in one frame and i just call all the fuctions in one frame only, but each fuctions shud load in series .. like one by one.

i am attaching a fla file.
in root the first frame i defined all fuctions.
and movie clip named as nrmchart contains all those parts of flowchart. rt now it is working fine. but i have too many flowcharts. cant just keep on making so many frames for each one of them
ples help.

UDit

( i am now realising the power of actionscripting)

View Replies !    View Related
Calling Functions From URL's.
Hello,

I cannot figure out a way to do the following. When a user navigates from one HTML page to another, I'd like to run an AS function once the user lands on that page. I have a main SWF that loads other SWF's deeper in the site and in order to get the user linked back to those deeper areas need to various functions.

One thought was doing it via the URL, but I have no idea if this works. Something like:

http://www.mysite.com/index.html?do=functionA

where functionA in an ActionScript function. Can something like this work, and if so, how. Otherwise, what about have the URL execute a Javascript within the HTML that in turn runs the function in the AS.

There's gotta be an easy way to do this. Let me know if I need to explain further. Thanks!

View Replies !    View Related
Calling Functions
Hi,

Will try to explain in simple :-)

I have an FLA file with Lots of movie clips

One of the movie Clip on the Scene is named "mcPortfolio"

One a click of a button I swap this with "mcProfileMain"

mcPortfolio.swapDepths(mcProfileMain);

There a some functions in "mcPortfolio".. How do I call it?

View Replies !    View Related
Calling Functions
I know this may seam strange but I am new at actionscript 3 and have a tiny bit of java experience (too bad it isnt helping that much).

My question is how do you call functions that you have made in actionscript files in the main stage of the .fla file?

if want to run something like this:

if(Duck1.flewAway == true){
do something....
}

Duck1 is defined in the Duck class and declared as an Object.
flewAway is a function inside the duck class with "return isNotShot"

If it helps I can include my .fla and all of my .as files.

View Replies !    View Related
Calling Functions
This is probably a stupid easy problem for most of you on here, but I'm at my wits end. I'm trying to call a function that's in my Main Document class from another class. I've done this in other classes before, but I think my problem is that the class I am calling from is itself being called by another class.

package{ //This is the main document class
public class Fort extends MovieClip {
public var bulRay:Array = new Array;
public function pushBul(tempOb:Bullet) {
bulRay.push(tempOb)
}
}
}

package{ //This is the class that ends up calling Bullet
public class Gun extends MovieClip {
public function shootGun() {
var p:Bullet = new Bullet()
}
}

package{
public class Bullet extends MovieClip {
public function Bullet {
// I want to call pushBul(this) in the "Fort" class here
// I was trying "MovieClip(parent).pushBul(this)" and
// "MovieClip(parent.parent).pushBul(this)" to no avail
}
}
}

Any help would be appreciated, thanks!

P.S. Apparently I don't know how to indent on this forum either, sorry

View Replies !    View Related
Calling Functions
Howdy guys,

Having a small problem and can't seem to find the answer anywhere.

Is it possible to call a function from a parent movie clip? The movie clip is on the timeline with this actionscript in the frame:

stop();
function play1(){
do stuff
}

And then in the movieclip I have a button which I wanna call the function:

on (release) {
play1();
}

What I'm pretty much looking to do is this:

/play1();

but that doesn't work. Any ideas?

View Replies !    View Related
Calling Functions
Hello,

I am making the jump to AS3 from AS2. I am wondering the most effective way to pass variables to a function within a function. Looking at the attached code, what is the easiest way to achieve this?

Any help would be greatly appreciated!

Thanks :)

Doug









Attach Code

function testOne()
{
function send()
{
var myNum:Number = 10;
receive(myNum);
}
}

function receive(someNumber:Number)
{
trace(someNumber);
// I know thats not right, but that is what I'm looking to do.
}

View Replies !    View Related
Calling In Functions
Hi
In the following code I am trying to call the function pressMc when movieclip myMC_mc is pressed and the apply the drag action to it. However the drag action is being applied to the whole of level0 and therefore all of the moviclips. I am not sure why. Am using the this key word as I would expect this to be identified as myMC_mc when the myMC_mc.onPress is evoked.
I want to write this as a function because I want to apply this drag action to lots of different movieclips
Anyone got and ideas
much appreciated

function pressMc (){

delete this.oldX;
delete this.oldY;
this.onEnterFrame = function() {

if (_xmouse>this.oldX || _xmouse<this.oldX) {
this.startDrag(false, 25, this._y, 125, this._y);
delete this.onEnterFrame;
} else if (_ymouse>this.oldY || _ymouse<this.oldY) {
this.startDrag(false, this._x, 25, this._x, 125);
delete this.onEnterFrame;
}
this.oldX = _xmouse;
this.oldY = _ymouse;
trace (this);
};

};
myMC_mc.onPress = function() {

pressMc();
};

View Replies !    View Related
Calling Functions In Another Swf
Hi. I'm trying to do something very simple and I've searched the forums but the answer to my question doesn't seem to work for me...

I'm trying to call a function that is on another SWF that I am loading into a container on the root of my main swf. The function I will call will be


ActionScript Code:
intervalId = setInterval(this, "executePixelation", duration, photoNum);


But for now I can't seem to pass anything over to the loaded swf.

I am using this method to load the swf:


ActionScript Code:
on (release){    loadMovie("project1.swf",_root.Content);             _root.Content.happyVar = "niceness";}


And this method to call a variable in the first frame of project1.swf:


ActionScript Code:
trace(_root.Content.happyVar);


Before I start calling functions I'd at least like to be able to trace a simple variable...

This has got to be so easy ... !!

View Replies !    View Related
Calling Functions
Does anyone one know if it is possible to call a function from a different movie clip than the one it is in.

For example, a function named loadData()
which is on the first frame of a movie clip instance named thumbNail
which is on level 0 on the stage

i was thinking that it should work to call the function from frame one on the stage with...
thumbNail.loadData();

so yeah, any help would be greatly appreciated.

nol

View Replies !    View Related
Calling Functions From XML
Hi,

I'm building an XML accordion menu as an external class, and I want to be able to include a function reference in the external XML file, with the function body sitting in a class file. I want to be able to call that function say with a click on one of the menu items.

I've tried various approaches, but generally get type errors or a "Function Body" not supported error if I cast the XML data as a function.

Is there anyway to have a function call say, "testFunction" in an XML file, then with a click on a button, call that function which has its body sitting on say the main timeline?

View Replies !    View Related
Calling Functions..
I was having problems with loading a swf into a parent movie through a target and having it work correctly, and then i noticed that the setMenu function wasnt being called when i did a trace.. how can i fix this.


ActionScript Code:
function setMenu(value) {
    trace("set menu scope: " + this);
    selectedName = textName;
    loadMovie("http://www.blahblah.com"+value+".jpg",_global.section1root.photoContainer);
}


This is the complete Version.

ActionScript Code:
pic._x = 238;
pic._y = 151;
//
importXML = new XML();
importXML.ignoreWhite = true;
importXML.onLoad = function(success) {
    if (success) {
        var xmlContent = this.firstChild;
        menuContent = new Array();
        for (var i = 0; i<this.firstChild.childNodes.length; i++) {
            nextEntry = xmlContent.childNodes[i];
            menuContent[i] = [nextEntry.attributes.name, nextEntry.attributes.value];
        }
        menuLength = menuContent.length;
        elementspacer = -3;
        var menuItem, yPosition = 0;
        createEmptyMovieClip("clipContainer", 0);
        clipContainer._x = 100;
        clipContainer._y = 150;
        attachMovie("mask", "mask", 10);
        mask._x = 100;
        mask._y = 150;
        clipContainer.setMask(mask);
        for (var i = 0; i<menuLength; i++) {
            clipContainer.attachMovie("menuItem", "m"+i, i);
            thisClip = clipContainer["m"+i];
            textName = menuContent[i][0];
            thisClip.menuname = textName;
            thisClip.destination = menuContent[i][1];
            thisClip.info = menuContent[i][2];
            thisClip._y = yPosition;
            yPosition += Math.floor(thisClip._height+elementspacer);
        }
    } else {
        trace("Error loading xml");
    }
};
//photo address
function setMenu(value) {
    trace("set menu scope: " + this);
    selectedName = textName;
    loadMovie("http://www.blahblah.com"+value+".jpg",_global.section1root.photoContainer);
 
importXML.load("photo.xml");
}

View Replies !    View Related
Calling Functions
Last edited by graphter : 2004-05-11 at 16:50.
























I'm just starting to get my head round functions so bear with me if this is daft...

I've created a function with parameters to grab a text file and populate a dynamic text box:
This sits in frame 1 of the main timeline


ActionScript Code:
// lv is the loadVars within flash
// loc is the location of the external txt file
// txtName is the identifier within the txt file
// fieldName is the dynamic text box instance name
_global.loadTxt = function(lv, loc, txtName, fieldName){
 lv = new LoadVars();
 lv.load(loc);
 fieldName.autoSize = true;
 fieldName.multiline = true;
 fieldName.wordWrap = true;
 fieldName.htmlText = lv.txtName;
}


Then inside a mc containing a dynamic text field I call the function:

ActionScript Code:
loadTxt(profile, external.txt, Profile, profile_txt);


...and in the 'external.txt' text file:
Profile=This is the profile section text blah blah blah

Flash can't find the txt file and reports back as 'undefined'. Do I have to convert 'external.txt' to a string somehow? Am I even on the right track?

View Replies !    View Related
Calling Functions Between MCs
Hi all...
How would one go about calling a function in another movieclip?

I have a function in one MC and a button in another - I want the button to send a value to the function for it to "do it's thing".

Code:

function setMainTac(x:Number) {
   for (i=0; i<25; i++) {
      if (myLineUp[x][i] == 0) {
         this["mcShirt_"+i]._visible = false;
         this["mcShirt_u_"+i]._visible = false;
      }
   }
}

Code:

useBtn.onRelease = function() {
   setMainTac(1)
};

The function uses the relative path, but I'm sure that could be changed to the absolute one.

-Wickal

View Replies !    View Related
Calling Functions?
Alright, so I have a movie in Flash MX. Within this movie is an array with just over 40 elements to it. My problem: I would like a button for each of these elements (I do no mind creating these by hand--it doesn't need to be dynamically done) and when you click it, it calls a certain function, gets the number set by the button click, and selects the array value. Now, I know perfectly well how to do this in, say, PHP, Perl, and Javascript, but Actionscript gets me confused. Help?

-Evan

View Replies !    View Related
Functions Calling Other Functions
what i need to do is call a set of functions several times in sequence with different parameters each time. here's what i've got

Code:
/////photoload code////
this.fadeSpeed = 10;
this.fadeSpeed2 = 10;
var picToLoad = "";
var whereToLoad = "";

MovieClip.prototype.changePhoto = function(ddd,whatwhat) {
this.picToLoad = ddd;
this.whereToLoad = whatwhat;
trace("this.picToLoad = ddd **** "+this.picToLoad+" + "+ddd);
trace("this.whereToLoad = whatwhat ***** "+this.whereToLoad+" + "+whatwhat);
this.onEnterFrame = fadeOut;
};
MovieClip.prototype.fadeOut = function() {
if (this.whereToLoad._alpha>this.fadeSpeed) {
this.whereToLoad._alpha -= this.fadeSpeed;
} else {
this.loadPhoto2();
}
};
MovieClip.prototype.fadeOut2 = function(xox) {
trace("fadeOut2 function called");
this.whichToFade = xox;
if (this.whichToFade._alpha>this.fadeSpeed2) {
this.whichToFade._alpha -= this.fadeSpeed2;
}
};
MovieClip.prototype.fadeOut3 = function() {
trace("this.whichToFade = "+this.whichToFade);
if (this.whichToFade._alpha>this.fadeSpeed) {
this.whichToFade._alpha -= this.fadeSpeed;
}
};
MovieClip.prototype.loadPhoto = function() {
// specify the movieclip to load images into
var p = _root.sectImg;
//------------------------------------------
p._alpha = 0;
p.loadMovie(this.pathToPics+this.pArray[this.pIndex]);
//this.onEnterFrame = loadMeter;
};
MovieClip.prototype.loadPhoto2 = function() {
// specify the movieclip to load images into
var p = this.whereToLoad;
//------------------------------------------
p._alpha = 0;
p.loadMovie(this.picToLoad);
this.onEnterFrame = loadMeter;
};
MovieClip.prototype.loadMeter = function() {
var i, l, t;
l = this.whereToLoad.getBytesLoaded();
t = this.whereToLoad.getBytesTotal();
if (t>0 && t == l) {
this.onEnterFrame = fadeIn;
} else {
trace(l/t);
}
};
MovieClip.prototype.fadeIn = function() {
if (this.whereToLoad._alpha<100-this.fadeSpeed) {
this.whereToLoad._alpha += this.fadeSpeed;
} else {
this.whereToLoad._alpha = 100;
this.onEnterFrame = null;
}
}
and then i've written the following to run the above functions:


Code:
MovieClip.prototype.controlPhoto = function(props) {
var ddd;
var whatwhat;
trace("arguments.length = " + arguments.length);
trace("props = "+props);
trace("arguments = "+arguments);
for (var cpi = 0; cpi<arguments.length; cpi++) {
trace("------ "+ cpi + " ------");
trace("arguments[cpi] = "+arguments[cpi]);
var my_array:Array = arguments[cpi];
my_array.slice();
trace(my_array[0]+" *** "+my_array[1]);
ddd=my_array[0];
whatwhat=my_array[1];
this.changePhoto(ddd,whatwhat);
}
}
and i'm calling this function like this:

Code:
curr_item.onRelease = function() {
_root.controlPhoto([this.img1,sectImg],[this.img2,leadImg]);
}
but what happens is only the last set of parameters actually get loaded. everything else seems to be skipped over. any help is appreciated!
thanks,
david

View Replies !    View Related
Functions Calling Other Functions
what i need to do is call a set of functions several times in sequence with different parameters each time. here's what i've got

Code:
/////photoload code////
this.fadeSpeed = 10;
this.fadeSpeed2 = 10;
var picToLoad = "";
var whereToLoad = "";

MovieClip.prototype.changePhoto = function(ddd,whatwhat) {
this.picToLoad = ddd;
this.whereToLoad = whatwhat;
trace("this.picToLoad = ddd **** "+this.picToLoad+" + "+ddd);
trace("this.whereToLoad = whatwhat ***** "+this.whereToLoad+" + "+whatwhat);
this.onEnterFrame = fadeOut;
};
MovieClip.prototype.fadeOut = function() {
if (this.whereToLoad._alpha>this.fadeSpeed) {
this.whereToLoad._alpha -= this.fadeSpeed;
} else {
this.loadPhoto2();
}
};
MovieClip.prototype.fadeOut2 = function(xox) {
trace("fadeOut2 function called");
this.whichToFade = xox;
if (this.whichToFade._alpha>this.fadeSpeed2) {
this.whichToFade._alpha -= this.fadeSpeed2;
}
};
MovieClip.prototype.fadeOut3 = function() {
trace("this.whichToFade = "+this.whichToFade);
if (this.whichToFade._alpha>this.fadeSpeed) {
this.whichToFade._alpha -= this.fadeSpeed;
}
};
MovieClip.prototype.loadPhoto = function() {
// specify the movieclip to load images into
var p = _root.sectImg;
//------------------------------------------
p._alpha = 0;
p.loadMovie(this.pathToPics+this.pArray[this.pIndex]);
//this.onEnterFrame = loadMeter;
};
MovieClip.prototype.loadPhoto2 = function() {
// specify the movieclip to load images into
var p = this.whereToLoad;
//------------------------------------------
p._alpha = 0;
p.loadMovie(this.picToLoad);
this.onEnterFrame = loadMeter;
};
MovieClip.prototype.loadMeter = function() {
var i, l, t;
l = this.whereToLoad.getBytesLoaded();
t = this.whereToLoad.getBytesTotal();
if (t>0 && t == l) {
this.onEnterFrame = fadeIn;
} else {
trace(l/t);
}
};
MovieClip.prototype.fadeIn = function() {
if (this.whereToLoad._alpha<100-this.fadeSpeed) {
this.whereToLoad._alpha += this.fadeSpeed;
} else {
this.whereToLoad._alpha = 100;
this.onEnterFrame = null;
}
}
and then i've written the following to run the above functions:


Code:
MovieClip.prototype.controlPhoto = function(props) {
var ddd;
var whatwhat;
trace("arguments.length = " + arguments.length);
trace("props = "+props);
trace("arguments = "+arguments);
for (var cpi = 0; cpi<arguments.length; cpi++) {
trace("------ "+ cpi + " ------");
trace("arguments[cpi] = "+arguments[cpi]);
var my_array:Array = arguments[cpi];
my_array.slice();
trace(my_array[0]+" *** "+my_array[1]);
ddd=my_array[0];
whatwhat=my_array[1];
this.changePhoto(ddd,whatwhat);
}
}
and i'm calling this function like this:

Code:
curr_item.onRelease = function() {
_root.controlPhoto([this.img1,sectImg],[this.img2,leadImg]);
}
but what happens is only the last set of parameters actually get loaded. everything else seems to be skipped over. any help is appreciated!
thanks,
david

View Replies !    View Related
Defining And Calling Functions
Hi,

I'm not quite clear on exactly what defining a function does. Correct me if I'm wrong:


When you define a function on a given timeline, the function is available only on that timeline--either as an object action, frame action, or method of the timeline.

So, let's say I have a movie clip called "functionsMC" on the main timeline. Inside "functionsMC" I define all the functions I'll be using in my movie. Now then, I've got a button I want to use myButtonActions() on the timeline "_root.menu". Before I can do that, I need an action like this:

Code:
_root.menu.myButtonActions = _root.functionsMC.myButtonActions
Is that right, or am I totally mixed up?

View Replies !    View Related
Using Arrays In Functions And Calling Them
if you had a function which created an array called bob with 4 values contained therein, what would be the proper syntax for calling one of those values and applying it to a property of an object? i know howto return values, but just not with using a value in an array.

ie:

_rotation = _root.bob(2);
_rotation = _root.bob.yummyArray(2);

??


TIA

View Replies !    View Related
Calling Functions Indirectly
Hi there !
Is it pssible to call a function indirectly? For example
if f1(), f2()...and so on are functions and "state" is a variable that holds the name of the function that I want to call.
Then I have tried with things like eval(state+"()"), but it doesn't work. Can anyone help me? Thanks

Ketil

View Replies !    View Related
Calling Functions From OnClipEvent ()
I'm having problems calling a function from my onClipEvent (). Has anyone had this problem before. I can't even call a simple funtion with a trace in it.

//I used this script on a movie clip in frame 1 of the main timeline.

onClipEvent (mouseDown) {
testFunc();
}

//to call this function in frame 1 of the main timeline

function testFunc () {
trace ("hello");
}

Please help!

Adam

View Replies !    View Related
Calling Functions Randomly
I would like to know how I could call different functions randomly. Here is what I am thinking. I am having a website with fish on it, and I want the fish to move randomly. Sometimes I want them so swim fast and sometimes I want them to swim slow. Somtimes I want then to swim up more than down. I was planning on creating different functions for each action then have the fish pull a function at random. Is this possible, or is there a better way. Also how would I make the fish hit a boundry (side of the movie clip, then turn around and go back the opposite direction?

Thanks,
MikeMadMan

View Replies !    View Related
Calling Functions From External Swf?
This is my first attempt at using functions. I don't think I'm too far away!

I have a movie on the main timeline that declares the fuinctions in the first frame. I then load in a file called news.swf that tries to call thse functions but it always seems to relate it to the main timeline (i.e. goes and plays frame 4 of the maintimeline instead of the news.swf.) Here's the code:

1st frame of main timeline:

function preloader() {
loadedBytes = this.getBytesLoaded();
totalBytes = this.getBytesTotal();
if (loadedBytes == totalBytes) {
this.gotoAndPlay(4);
}
}
function barlength() {
loadedBytes = this.getBytesLoaded();
totalBytes = this.getBytesTotal();
percentageOutput = int((loadedBytes/totalBytes)*100);
bar._xscale = percentageOutput;
}
function preloadloop() {
if (loadedBytes<totalBytes || introBytes<introTotal) {
percentageOutput = int((loadedBytes/totalBytes)*100);
bar._xscale = percentageOutput;
this.gotoAndPlay(2);
} else {
this.gotoAndPlay(4);
}
}

preloader();

2nd Frame

barlength();

3rd Frame

preloadloop();

In the news.swf I have:

1st frame
_root.preloader(this);

2nd Frame
_root.barlength(this);

3rd Frame
_root.preloadloop(this);


I'm not sure if I'm using 'this' in the correct place. If anyone could give me more info on why and where to use 'this' I would be very grateful.

Thanks for your help,

Graeme

View Replies !    View Related
Calling HTML Functions From SWF
Hi I'm new to all this and am in need of some advice.

I recently posted a small site designed for a friend in which the swf calls functions inserted in the html page to shake the browser window and also open a new window. This functionality was fine when accessed directly at the host (demon.co.uk) however the site has a separate domain name which is masked at freeparking. When using this domain name the functions did not work at all (something to do with freeparking opening the site in a frame I believe). Anyway the guys at freeparking gave me some code:

<TITLE>Can't be in a frame</TITLE>
<SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
<!-- Hide script from old browsers

if (top.location != self.location) {
top.location = self.location
}
// End hiding script from old browsers -->
</SCRIPT>

so whilst the site now functions, the .demon.co.uk appears in the address bar instead of the somewhat catchier domain name.

Are there any ways around this at all ??? Help please!
Cheers

View Replies !    View Related
Calling Functions From A Variable?
how do i call a function from a variable?????????
i want to call a function through a variable named"mode"
the function will change depending on which btn is pressed.
my function works fine but when i try to call it through the variable it does not work!!!! how do i do it

i establish the function
a button then defines "mode"
another btn triggers mode
this doesn't work.....why

//function1
function songplay(){ code}

//function2
function songcycle(){ code}

//mode btn 1
on (release) {
mode=function(){
songplay
}
}

//mode btn 2
on (release) {
mode=function(){
songcycle
}
}
//apply btn...is this right?
on (release) {
mode
}

View Replies !    View Related
Calling Functions From An Array
Hi

I'm trying to populuate an array with function calls and then I want to activate the functions by clicking a button (gather) in the order that they are populated in the array. This is my first attempt at an array and i'm having no joy. How do I get the array to play the functions in the correct order? This is my script on the root level frame:

function playSound() {
intro2 = new Sound();
intro2.attachSound("intro2");
intro2.start();
}
function playSound2() {
section1 = new Sound();
section1.attachSound("section1");
section1.start();
}

myArray = new Array();
_root.gather.onRelease = function() {
_root[myArray[0][1]];
trace(myArray);
};


This is my script on the 2 buttons to popualate the array. Am i populating the array with the functions?

on (release) {
_root.myArray.push("playSound");
trace(myArray);
}


on (release) {
_root.myArray.push("section1");
trace(myArray);
}


I think i'm a long way off the mark and would really appreciate some help.

Thanks
boonos

View Replies !    View Related
Calling Functions With A Variable
Hi,
Is there any way to call a function whose name is returned by a variable.
say for example if u have three functions

function function1(){
trace("function 1");
};

function function2(){
trace("function 2");
};

function function3(){
trace("function 3");
};

and there is a variable x whose values will be "function1","function2","function3"

the question is ..... is it possible to execute the function by value x
like call(x); or something of that sort.


Please get back ASAP.

Regards
Venkat

View Replies !    View Related
Problem Calling Functions From Mc's
I think my problem is that I'm used to other OO languages, and I'm not getting what I'm supposed to do with assigning functions to movie clips. What I've done is created some movie clips with 2 layers, actions and contents. In the actions layer, I've created some functions to make it easier to customize the clips (such as populate dynamic text fields). Now, I would assume that if my clip was called "Clip1" and I wanted to add a new Clip1 to my movie, I could do the following in the main timeline:

_root.attachMovie("Clip1","newClip",0);
newClip.populateText(string1,string2,...);

Now, I would assume that the above code would work, but it does nothing, except create a new instance of Clip1 named newClip. What am I doing wrong? Do I create all the functions as prototype functions for the clips in the main timeline? Or is what I'm trying to do just not feasable and I should just write functions on the root that take the clip reference as a parameter?

Oh yeah, I'm authoring in Flash MX but I'm publishing as Flash 5. Thx,

Liam

View Replies !    View Related
Calling Functions Within Objects
I'm trying to call a function that is outside an object from within an object.
this is my code.


stop;
//this is my object "ball"
function ball() {
this.test = "testing";
}
// this is a funtion within my object "ball" Note that it calls a funtion "callfuntion" at the end.
ball.prototype.jump = function() {
this.test = "changed to jumped";
msg = "varable passed";
this.callfuntion(msg);
};
// says bb is a new ball object
bb = new ball();
// calls the jumb function within my ball object
bb.jump();
// this is where I'm haveing problems. the following should work but it does not.
// I'm trying to "catch" the bb.callfuntion and tell it to exacute the "calledfromball" function
bb.callfuntion = calledfromball;
// this is the funtion in the end that i'm trying to exacute from within a ball object
// but it never get exacuted.
function calledfromball(msg) {
trace("got to called from ball");
trace(bb.test);
trace(msg);
}
I know this can be done. ElectroServerAS from Eelectrotank does it.
Any Ideas?
Mike.

View Replies !    View Related
Calling Dynamic Functions...
Hi,

I have a array of values say arr[5,6,"sumit"]

in this "sumit" is the name of a function that accepts two parameters and returns the sum of those two parameters.

I want to create a syntax that will take the function name from the array element3 and will pass array element1&2 as parameters.

Please help. is this possible?

Many thanks,
Bhavin.

View Replies !    View Related
Calling Loaded Swf Functions
Hello

I load some external swf file into my movie using loadMovie()
how can i call some function in it or just make it gotoAndPlay ?

i tryed like this:
loadMovie("myMov.swf", dropZone);

tellTarget(dropZone){
gotoAndPlay(1);
}

but it doesn't work.....

View Replies !    View Related
Calling Functions From Other Levels
I have a bunch of functions defined on the _root level. Most the actions being performed are on that level or originating there. But later on I had to make a contentMC that loads into itself different SWFs. Can I access those _root based functions from within that content MC? If so, what would the command look like? Thanks.

View Replies !    View Related
Defining And Calling Functions In MX
Hi, this is quite a basic/general question, but I'm designing a fairly complex Flash game and the learning curve I'm on is pretty steep!

Anyway, the main bulk of the programming I need to define a series of functions that can be called by different sections of the actionscript. My question is, would it be better to define all the functions in the first frame of the whole timeline, or to place the entire movie into a new MC and attach all the functions to it on the stage.

Sorry if it sounds a little confusing.
Any help would be greatly appreciated!

View Replies !    View Related
Calling Functions From Timeline
Hi:

I have the following code on the first frame of the timeline, wich has 6 movieclips named coin1, coin2, etc.
code:
function monedaInit(){
velo=random(6)+3;
this._y=500;
this._x=random(480)+3;
monedaMover();
}
function monedaMover(){
this.onEnterFrame=function(){
this._y-=velo;
if (this._y<=-20)
monedaInit();
}
}
totalMonedas=6;
this.onLoad=function(){
for (i=0; i>totalMonedas; i++){
nom="coin"+i;
_root[nom].monedaInit();
}
}


it doesn't work. I'm very confused on how functions are called. If I say onClipEvent (load){this.monedaInit()} on the movie clips it won't work either, and if i say onClipEvent (load){_root.monedaInit()} it'll apply the function to the stage (thus, moving the whole thing around). It's very annoying, what's te correct usage?

Thanks

Sir Patroclo

View Replies !    View Related
Calling Functions Streamlining
Greetings all,

I am attempting to streamline my code and am seeking guidance/assistance.

What I have is thirty functions such as this:

function word_one() {
dostuff blah blah
my_sound.onSoundComplete = function() {
word_two();
};
)

each function is named as above through _thirty.

Within each function after user receives feedback, it calls the next function.

What I am trying to do is simplify the calling of the next function which will enable me to more rapidly repurpose this script.

Any suggestions?

Thanks in advance.

View Replies !    View Related
Problem Calling Functions
Hi, i am pretty new to functions and am having a bit of trouble with making them work. I am making a paintball game and want to generate paintballs and make them shoot from the enemys gun. The problem i am having is that when i execute the function all the variables are messed up (each enemy is stored withing a different movieclip and i want the function to be called from within their movie clips). . I am creating the function on the Main timeline, could that be the problem?:-

Heres the function that i have created on the main timeline (_root). Before i tried using functions, this code was stored within the timeline of each enemy movieclip.

myfunction = function(){
poschange = new Object();
poschange.x = enemymove.tester._x;
poschange.y = enemymove.tester._y;
enemymove.main.localToGlobal(poschange);
globalX = poschange.x;
globalY = poschange.y;
enemymove.main.shoot.gotoAndPlay("shoot");
_root.paintballs.shot1.duplicateMovieClip("shotx"+ _root.n, _root.n);
_root.paintballs["shotx"+_root.n].work = enemymove.colour;
_root.paintballs["shotx"+_root.n]._x = globalX;
_root.paintballs["shotx"+_root.n]._y = globalY;
_root.paintballs["shotx"+_root.n]._xscale = 0;
_root.paintballs["shotx"+_root.n]._yscale = 0;
_root.paintballs["shotx"+_root.n].blurshot.ammochange.gotoAndStop("ammo"+enemymove. colour);
_root.n++;
}

I am then calling this function from the within the enemys movie clips with this code

_root.myfunction

View Replies !    View Related
Calling Functions - Can I Simplify It?
Greetings all,

Have a whole lot of functions all sequenced with names such as
setone_1 through setone_30

Currently I am using this to call the next function:

blah blah
my_sound.onSoundComplete = function() {
setone_2();
}
Also have an onPress function for the buttons to do the same.

I was wondering if/how can I call the next function from a variable which would sequence the function?

I am attempting to streamline my code and any guidance and/or assistance would be appreciated.

I am using flash 8 and publishing using AS2.

Thanks!

View Replies !    View Related
Calling Functions Question
Hi there,

I have got a global function with a slide effect which I am reusing several times on different target mc's.

After the slide effect is done I want to call 'a' function within the slide function which could be any function depending on what target I have slided.

How do I call the function within the slide function? It can be any function with a not fixed amount of paramenters.

Cheers,

Albert

View Replies !    View Related
Calling Functions From Movieclips
hi, can anyone tell me...

i have a function defined on the _root
i.e
function my_function() {
trace(my_var);
}

it is then called from inside a movieclip like so
_root.my_function();

when the function is run does it run localy to the movie clip or on the _root so that if my_var was contain within the movieclip would the function on the _root have to be
if function is run localy to movieclip
trace(my_var);
or if function is run on _root
trace(my_move.my_var)

did my best to make the understanable but dont think i did a good job but please help all the same

View Replies !    View Related
Calling Functions Using A Variable
Hello there,

I've been searching the internet for if this is possible. I want to do something like this:
---
function Fred()
{
trace ("hello");
}

var Jim:String = "Fred";

this[Jim]() //I am trying to call the function Fred using this variable
---
I want to do this so I can call the correct function out of lots of functions, by changing a variable. Yes, I know there's a long way of 'if (Jim == "Fred"){ Fred() } else if (Jim == "blahblah) then call another function etc...but if there are lots of functions it gets quite long.

Thank you!

View Replies !    View Related
Calling Functions In Classes
I have used addChild for a movieClip several times. These instances are linked to their own class. I have given names to each of the children...child0, child1 etc..

e.g.
var bh:MovieClip; //done at the beginning

new BlackHole(ball_mc) //BlackHole is the class
bh.name = "child" + i
addChild(bh)

I know how to remove them by doing removeChild(getChildByName("child1")) whenever I want and I can access their class to call functions...but only when I'm adding them. For example here I'm calling the function 'doStuff' in its class:

bh.doStuff();

When I try to access a function later on, I'd expect I could have done

getChildByName("child1").doStuff()

but it doesn't work. How do I access this function doStuff from the child1's class?

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved