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




Call To Function Not Working?



Hi, I have a function that changes the background colour of a text field:
Code:
function changeColour() { _root.ticker_txt.backgroundColor = "0xFFCC00"; _root.ticker_txt.background = true; _root.ticker_txt.border = true; }
I call this function in another function that refreshes the screen every 5 seconds:
Code:
// delay function function unpause() { // get XML file each time getXML(); // change colour of text field changeColour(); trace("Colour Change: "+changeColour); // clear existing delay interval clearInterval(_global.my_interval); }
The XML feed is parsed and the text put into the textField I want:
Code:
// parse XML function loadXML(loaded) { if (loaded) { // trace XML data trace("XML Data: "+xmlData); // get ticker & volume _root.ticker = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue; // set text box values _root.ticker_txt.text = _root.ticker; } else { trace("File not loaded!"); } }
This unpause function is called in one last function that loads XML data into my textField:
Code:
// get XML function function getXML() { var xmlData:XML = new XML(); xmlData.ignoreWhite = true; xmlData.onLoad = loadXML; xmlData.load("xmlfeed"); trace("Requested Feed: xmlfeed"); // request ever 5 seconds _global.my_interval = setInterval(unpause, 2000); }
I have a textfield on the stage with an instance name of ticker_txt. I don't see why this is not working? If I move the changeColour(); call outside of the unpause(); function - it works perfectly!? Any ideas - I am sure it is the way I am refrencing the textField - but everything is in the same moviclip/scene/frame - so _root should work surely? I am utterly at a loss - tried lots of things - really need some advice. Cheers, Chris



SitePoint > Design Your Site > Flash and Actionscript
Posted on: Aug 19, 2005, 02:10


View Complete Forum Thread with Replies

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

Call To Function Not Working?
Hi,

I have a function that changes the background colour of a text field:


Code:
function changeColour() {
_root.ticker_txt.backgroundColor = "0xFFCC00";
_root.ticker_txt.background = true;
_root.ticker_txt.border = true;
}
I call this function in another function that refreshes the screen every 5 seconds:


Code:
// delay function
function unpause() {
// get XML file each time
getXML();

// change colour of text field
changeColour();
trace("Colour Change: "+changeColour);

// clear existing delay interval
clearInterval(_global.my_interval);
}
The XML feed is parsed and the text put into the textField I want:


Code:
// parse XML
function loadXML(loaded) {
if (loaded) {
// trace XML data
trace("XML Data: "+xmlData);

// get ticker & volume
_root.ticker = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;

// set text box values
_root.ticker_txt.text = _root.ticker;

} else {
trace("File not loaded!");
}
}
This unpause function is called in one last function that loads XML data into my textField:


Code:
// get XML function
function getXML() {
var xmlData:XML = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("xmlfeed");
trace("Requested Feed: xmlfeed");
// request ever 5 seconds
_global.my_interval = setInterval(unpause, 2000);
}
I have a textfield on the stage with an instance name of ticker_txt. I don't see why this is not working?

If I move the changeColour(); call outside of the unpause(); function - it works perfectly!?

Any ideas - I am sure it is the way I am refrencing the textField - but everything is in the same moviclip/scene/frame - so _root should work surely?

I am utterly at a loss - tried lots of things - really need some advice.

Cheers,
Chris

[CS3] Function Call Not Working
Why is the function not working, any ideas?


This is my function:
function add_controll_pannel() {
this.attachMovie("controll_pannel","controll_panne lMC",10);
controll_pannelMC._x="157";
controll_pannelMC._y="186";
}

And this is my function call:
add_controll_pannel;

Nothing happens. Any help?

Thank you!

Function() Call Not Working
hi, i'm doing a flash web and made a photo gallery scene by action script. the problem is, when i leave the scene and jump to another page, the movie clips the action script created would still remain in the movie. so i put a removeMovieClip() action on the buttons when u leave the photo gallery scene. another problem, when i go back to the photo gallery page, the function does not repeat anymore..u can check on the project at vina.activeresourceteam.com pls help.. thanks..

Call To Function Not Working?
Hi,

I have a function that changes the background colour of a text field:


ActionScript Code:
function changeColour() {       _root.ticker_txt.backgroundColor = "0xFFCC00";       _root.ticker_txt.background = true;       _root.ticker_txt.border = true;   }


I call this function in another function that refreshes the screen every 5 seconds:


ActionScript Code:
// delay function   function unpause() {       // get XML file each time       getXML();                  // change colour of text field       changeColour();       trace("Colour Change: "+changeColour);          // clear existing delay interval       clearInterval(_global.my_interval);   }


The XML feed is parsed and the text put into the textField I want:


ActionScript Code:
// parse XML   function loadXML(loaded) {       if (loaded) {           // trace XML data           trace("XML Data: "+xmlData);                      // get ticker & volume        _root.ticker = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;                      // set text box values           _root.ticker_txt.text = _root.ticker;                  } else {           trace("File not loaded!");       }   }


This unpause function is called in one last function that loads XML data into my textField:


ActionScript Code:
// get XML function   function getXML() {       var xmlData:XML = new XML();       xmlData.ignoreWhite = true;       xmlData.onLoad = loadXML;       xmlData.load("xmlfeed");       trace("Requested Feed: xmlfeed");       // request ever 5 seconds       _global.my_interval = setInterval(unpause, 2000);   }


I have a textfield on the stage with an instance name of ticker_txt. I don't see why this is not working?

If I move the changeColour(); call outside of the unpause(); function - it works perfectly!?

Any ideas - I am sure it is the way I am refrencing the textField - but everything is in the same moviclip/scene/frame - so _root should work surely?

I am utterly at a loss - tried lots of things - really need some advice.

Cheers,
Chris

OnSoundComplete Function Call Not Working
Hello, i have a small but annoying problem. I want an clip called 'next' to be displayed when the sound has stopped playing. This code works on my computer and many others but doesnt on a few and i dont know why. The clip doesnt load when the sound finishes playing.


ActionScript Code:
_root.next._visible = false;

//create a global sound object
mySound = new Sound();

//attach the sound to the object
mySound.attachSound("027.mov");

//stop all sounds in the movie
mySound.stop();

//play sound
mySound.start();

function showarrows() {
_root.next._visible = true;
}


//check to see if sound finished, if it has then display the next arrow
    mySound.onSoundComplete = showarrows;

   
stop ();

Does anyone have any suggestions or ideas? I thought it may be the way i have set the _visible property to true in the showarrows function, but the only other way is the setProperty way which is redundant now.

I'm using MX 2004 and the fla is set to run for Flash Player 6 and ActionScript 1.0

Hope you can help

KJ

Dynamic Function Call With Eval Not Working
Ok flash masters. Here is another question for you. I am trying to make function calls by using the eval() method.

how do I get that to work?
I have tried
var x = 'fncName';

eval(fncName());

Can this be done and if so how?

Parent Swf Call Function In Child Swf Not Working
Hi all,

I'm having a problem with this and I just can't figure it out :( (I've been trying different things and staring at it for hours and I'm losing my mind...)

So I have a Parent swf that loads a Child swf (this goes without any problems), but I want the Parent to call a function in the child, now this is where it goes wrong...

The function the Parent has to call is named "lookupcar" and needs to give the value "wagen" with it. The problem I think is that the Parent wants to call the function but it still needs to load (correct me if I'm wrong). Is there a way to check if the Child swf is loaded completely before trying to call the function? Could you give me an example of this please? Or any other suggestions on what goes wrong?

Code in the Parent
.......
root.inhoud.createEmptyMovieClip("thetext", "thetext", this.getNextHighestDepth());
root.inhoud.thetext.loadMovie("uitrusting-wagenpark.swf");
root.inhoud.thetext.lookupcar(wagen);

Code in the Child
(the function lookupcar)
_global.lookupcar = function(carnr:String){
trace("LOOKUPCAR, with car nr: " + carnr);
......
}

Thanks in advance for all the help.

How To Call A Function First And Create A Delay And Call Another Function
Hi, I am new to actionscript. Is it possible for me to call a function first and call the second function after a short delay.

I try to use this codes. But it didnt work

function a(){
trace("A");
setInterval(b(), 1000);

}

function b(){
trace("b");
}

Can't Call Function Created Via Eval Using ExternalInterface.call
I have created a flash movie that acts as an MP3 player. Using ExternalInterface, I pass an array containing cue points in the song to the flash move so that it makes a callback to javascript when it hits certain points in the song. Since I want to deal with these callbacks differently for each song, I have made it so that I can dyanmically change the function that is called from Flash (to Javascript). Here is the code for that piece:

ExternalInterface.addCallback("setCuePointFunction ToCall", this, setCuePointFunctionToCall);

var cuePointFunctionToCall:String='';
var intCurrentCuePoint:Number=0;

function setCuePointFunctionToCall(strFunctionName){
_root.cuePointFunctionToCall=strFunctionName;
}

function reportToJavascript_CuePoint(intCuePointID:Number){
ExternalInterface.call(_root.cuePointFunctionToCal l, intCuePointID);
_root.intCurrentCuePoint++;
}

This works perfectly as long as the function that cuePointFunctionToCall refers to is defined in a script block on the HTML page. However, this project is an AJAX-style thing, and I need to be able to define the function that is triggered on a cue point in code that is dynamically executed at run-time via an "eval' call.

Here's the code that talks to actionscript. This appears in a script block on the main page (not via eval).

function setCuePointFunctionToCall(strFunctionName) {
thisMovie("PushPuppets_Media_Center").setCuePointF unctionToCall(strFunctionName);
//alert(strURL);
}

function thisMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}

Here's the code that is dyamically being executed via an eval statement in javascript:

setCuePointFunctionToCall("cuePointNew");

function cuePointNew(lngCuePointID) {
alert('New function, cue point: ' + lngCuePointID);
}

This does not work. But if I copy the above function block to the main page (not in the code that is executed via an eval) it does work. I am certain that setCuePointFunctionToCall is being executed properly via the eval - it is definitely changing the function that actionscript will call. This is apparent since it is calling the right function when the function is declared on the HTML page (not in the AJAX-style eval call). So I'm guessing that this has something to do with the scope in which eval operates.

I encountered a very similar problem when I tried redefining a function in the eval call that was already defined on the main page. It just didn't take.

Please let me know if you have any suggestions.

Thanks,

Erich

Call A Function In A Duplicated Movie Clip Form Another Function : (
i have a movie clip on my root name "pl".
on command, it duplicates with instance name as "y0","y1", etc.

here is the method :

function callPL(transmit,receive,addy,level) {

var newName = "y"+_root.x;
duplicateMovieClip("_root.pl",newName,101);
_root[newName]._x = 400;
_root[newName]._y = 400;

_root.[newName].start(transmit,receive,addy,level); //look here
}


there i attempt to call a function of the newly duplicated clip call "start()".
Start() function is written on the first frame of the movieclip like this :


function start(a,b,address,level) {
a.sendAndLoad(address,b,"Post");

this.path = b;

b.onLoad=function(success) {
gotoAndPlay("start");
}
}


however it seems like the function callPL() could not invoke function start() of the new movieClip.I have no idea how is it so.
Even when i trigger it with a onLoad handler it still doesnt work
pls shed some light.

Calling Constructor In Condition: A Function Call On A Non-function Was Attempted.
Hi guys,

Please help me somebody with this cos I have really no idea. I have made a simply condition calling a constructor of a class. Today I had to add an "else if", what caused the compilator to show me "A function call on a non-function was attempted."...

ActionScript Code:
function loadIt() {    if (var1 == "1") {        var a:SomeClass = new SomeClass(true);    } else if(var2 == "1"){         var a:SomeClass = new SomeClass(false); //<- if this is not here, everything works fine    } else {        var b:SomeOtherClass = new SomeOtherClass();        b.init();    }}

Any ideas? Thanks for any help!

Poco

Filling Function Arguments With Array Items, Function.call()
HI!

I have this code but I cannot work out how to fill in function parameters based on an array and it's length, see line 7

ActionScript Code:
import com.robertpenner.easing.Cubic;MovieClip.prototype.framesTimeout = function(func:Function, frames:Number, args:Array) {    var t:Number = 0;    var mc:MovieClip = this.createEmptyMovieClip(String(new Date().getTime()), this.getNextHighestDepth());    mc.onEnterFrame = function() {        if (t == frames) {            func.call(this._parent,args);            delete this.onEnterFrame;            this.removeMovieClip();        } else {            t++;        }    };};MovieClip.prototype.movex = function(x:Number, frames:Number) {    trace(x+" "+frames)    delete this.movex.onEnterFrame;    this.movex.removeMovieClip();    if (!frames) {        frames = 20;    }    var t:Number = 0;    var sx:Number = this._x;    var ax:Number = x-this._x;    var mc:MovieClip = this.createEmptyMovieClip("movex", this.getNextHighestDepth());    mc.onEnterFrame = function() {        if (t == frames) {            delete this.onEnterFrame;            this.removeMovieClip();        } else {            t++;            this._parent._x = Cubic.easeOut(t, sx, ax, frames);        }    };};MovieClip.prototype.otherfunction = function(param1, param2, param3, param4){    trace(param1+" "+param2+" "+param3+" "+param4)}mc.framesTimeout(movex, 50, [100, 50]) mc.framesTimeout(otherfunction, 200, ["asd", 1, 2, 55])

Is it possible to call a function and fill in the parameters based on an array and it's lenth?

My Function Isn't Functioning/Actionscript To Call A Function Flash MX 2004
Hello,

Well in theory I know how to create a function but for some reason I am unable to call it.

Can someone take a look at it and tell me what went wrong. Basically when I go to "a certain page" I want to click on a button and have it go to another page known as "pics" it then will load a jpeg there known as jpeg loader. Now I know it works properly without a functin, but because I am lazy I do not want to write more code than I have to, there are like 300 differnt jpegs I have to load. Thus I need to create a function.

here is my AS


ActionScript Code:
//this is on frame one of my root timeline
//I am trying to call the function "display" on release of my button
 
omnihotelButton.onRelease = display ("J010 Omni Hotel.jpg");
 
 
//this is my function that I set up it is also on my root, but on a different frame
//this function is named display and it goes to the "pics" page and stops
where it then loads a jpeg which is et up as my variable.
//the xscale and the yscale are just setting up my size of the jpeg.
 
function display(jpeg){
    _root.gotoAndStop("pics");
    jpegLoad_mc.loadMovie(jpeg);
    jpegLoad_mc._xscale=90;
    jpegLoad_mc._yscale=90;
}

Function Calling From The _root But Call A Function Within A Instance
I have created a new instance 'Check_1' to work as a checkbox with a set of propertys and functions.

All ive done is created the functions in a script in the first frame of the instance-movie these are...

Simple......
================================================== =======

selected = -1;
function select_frame (FrameNum) {
gotoAndPlay (FrameNum);
}
function change_select () {
select_frame(2);
trace (selected);
}
function change_unselect () {
select_frame(1);
selected = -1;
}

================================================== =======

now from the _root i wish to call the above functions to change the instance propertys, it all works fine from within the instance but i also need to use the functions for that instance from the _root...

iv'e tried the follow with no joy...


_level0.Check_1.change_select()


Any light would be greatly appreciated.

Inside XmlOnload Function Can Not Call Other Function Directly
I have a question, why the test function can not be called ?
Thanks.

Code:
class testClass {
public function testClass() {
var XMLData:XML = new XML();
XMLData.load("coonfig.xml");
XMLData.onLoad = this.xmlOnLoad;
}
public function xmlOnLoad(success:Boolean) {
if (success) {
// this.test();
test();
}
}
public function test () {
trace("test success");
}
}

Cannot Call Button Function Within Another Event Function
Hopefully someone can help me out with this one. I'm importing XML in order to draw images into an animated scrollbar, and would like to nest a button function within the function urlLoaded as listed below:

import caurina.transitions.*;

var urlCall:URLRequest = new URLRequest("pics/hotel_dreams/hotel_dreams.xml");
var urlLoader:URLLoader = new URLLoader();
var xml:XML;
var xmlList:XMLList;
urlLoader.load(urlCall);
urlLoader.addEventListener(Event.COMPLETE,urlLoade d);

var arrayThumb:Array = new Array();
var photoContainer:Sprite = new Sprite();
addChild(photoContainer);
photoContainer.mask=thumb_holder;


function urlLoaded(event:Event):void {


xml = XML(event.target.data);
xmlList = xml.children();
trace(xmlList.length())
for (var i:int=0; i<xmlList.length(); i++) {
var thumb:Thumbnail = new Thumbnail(xmlList[i].url);
arrayThumb.push(thumb);
arrayThumb[i].y = 67.5;
arrayThumb[i].x = xml.children().x_position[i];
photoContainer.addChild(thumb);
arrayThumb[i].gallery = xml.children().gallery[i];

trace(arrayThumb[i].gallery);


}


}

my hope is to create a button that looks something similar to the following in order to execute an if then statement within the function controlling the visibility of images from the XML based on their gallery property value.

btn_gallery_2.addEventListener(MouseEvent.CLICK, open_gallery_2);
function open_gallery_2(event:MouseEvent) {

if (arrayThumb[i].gallery == 2) {
arrayThumb[i].visible = true
}

}

I have been trying to nest within the urlLoaded function to no avail. By running trace statements I can see that [i] is inaccessible when nested within another function within urlLoaded and when completely outside of the urlLoaded function.

The Thumbnail class referenced is in an .as file that looks like this:

package {
import flash.display.Sprite;
import flash.display.Loader;
import flash.net.URLRequest;

public class Thumbnail extends Sprite {

private var url:String;
private var loader:Loader;
private var urlRequest:URLRequest;
public var gallery:Number

function Thumbnail(source:String):void {
gallery = 0
url=source;
drawLoader();

}

{
private function drawLoader():void {

urlRequest=new URLRequest(url);
loader=new Loader ;
loader.mouseEnabled=false;
loader.load(urlRequest);
loader.x=-0;
loader.y=-68
;
addChild(loader);

}}}}

I have the suspicion that I am missing something very basic. If anyone out there might be able to give me some insight, then I would be appreciative.

thanks very much

[F8] How Do You Call A Function In A Function In A Class?
I have this class..

class Bob {
function Bob(){
initiate code
}

function loadImages(){
Load images code...
image.onEnterFrame = function(){
if loaded {
this.nextFunction();
}
}
}

function nextFunction(){
do this
}
}


basically, i have a function that loads images.. and i need to have it automatically do another function in that class once the images are loaded..

how do i wait til they're loaded in the class? cause if i put it in "onEnterFrame" , 'this' no longer refers to the class, it refers to the onEnterFrame..

so how do i refer back to the class?
or how do i determine if the images are loaded all in the one class?

Call Function From A Function In A Class?
i havee..

class testClass
{

function testClass()
{
giveFunctions(mc1);
}

function traceIt(tag)
{
trace(tag);
}

function giveFunctions(mc:MovieClip)
{
mc.onRollOver = function()
{
traceIt("SUP");
}
}

}



How do i make the giveFunctions function access the class?

cause it defines a rollover function for an MC.. but in that rollover function, it has to re-reference a different function in the class..

how does that work?

there'll be more variables and it'll be more complex..



I had like,

function giveFunction(mc:MovieClip,tag)
{
mc.sett = this.traceIt;
mc.mca = mc;
mc.tag = tag;

mc.onRollOver = function()
{
this.sett(this.mca,this.tag);
}
}




that works, but it like.. pulls the traceIt function out of the class so it couldn't reference any other variables if it needed to

String With Function Name To Call Function?
hi guys,

it so happened that I have to call some function from XML. What is the best way to do this??

say i have a class "ABC.as" with a function "def()" can I do this:


Code:
var abc:ABC = new ABC();
var strg:String = "def()";

//then i call the function...

abc.strg;
is this going to work?? else is there any solution can let me do something similiar?

thanks!

Call A Function From Inside Another Function?
Hey Guys,

Having a bit of a problem here

Just say this was the case on the main timeline


ActionScript Code:
function topFunction(){
trace("you just called the topFunction")
}

function testFunction(){
function nestedFunction(){
topFunction();
}
}

How the hell do i run the topFunction from inside nestedFunction();. In AS2 if i wanted to reference it i would type _root.topFunction(); but now I don't know how to get to it.

I just need to know how to reference variables and functions from anywhere in my actionscript if i'm in another scope or in another MC.

Thanks guys

[AS]Call A Function After Another Function Ends
Hi,

I have a question: How i make (if it's possible to do this) to call a function after another function is finished. I have 4 function:

ActionScript Code:
function tween1 () {//some tweens}function tween2 () {//some tweens}function tween3 () {//some tweens}function tween4 () {//some tweens}


And i want to play first tween1 and then tween2, when tween2 ends then play tween3 and so on!

It's this possible?

Thanks, btibia.

Pass Function Name To Function And Call
bit stuck on this.

any help much appreciated!


ActionScript Code:
func_1(mc10, 'func_2',[id1, add]);
 
function func_1(tofade, oncompletecall, var){
 
//fade out 'tofade'
//then call oncompletecall(func_2) function..
 
how do i form the call to func_2?
 
}
 
function fun_2(id1, add){
do something...
}

Call A Function Inside A Function
I have a function that attaches a movie clip and names it movieClip_1. I now need the to call the same function again to create movieClip_2 when you click movieClip_1.

[F8] Irritating Error: "A Function Call On A Non-function Was Attempted."
So I've been out of flash for a long time and I decided to hop back into it now that I have time again. I'm running on Flash 8 and I'm trying to make a simple particle engine. This simple, day or two project has turned into a nightmare I can't figure out.

For whatever reason, the colorTransform method of the Transform object is griping at me when I try to call it from a member function of the class I'm writing. I have this same code working in a different class, and the only difference I could see was that in the working code I was creating the Transform object on the fly for each color modification, as opposed to making it a property of the class.

Anytime I run the .colorTranform method, I get the error from the title on that line of code. I can't see to figure out what that even means exactly, let alone how to get rid of it. Has anyone encountered this before?

Here's what I have. I cut out the parts that don't pertain to this error (mostly sizing and speed code for the particle).


Code:
import flash.geom.Transform;
import flash.geom.ColorTransform;

class Particle
{
private var ColorInitial:ColorTransform;
private var ColorFinal:ColorTransform;
private var ColorCurrent:ColorTransform;

private var GraphicObject:MovieClip;
private var GraphicTransform:Transform;

function Particle(strQuality:String, intInitialX:Number, intInitialY:Number)
{
var newDepth:Number = _root.getNextHighestDepth();
_root.attachMovie("Particle" + strQuality, "dmParticle" + newDepth, newDepth);
this.GraphicObject = eval("dmParticle" + newDepth);

this.GraphicObject._visible = false;
this.GraphicObject._x = intInitialX;
this.GraphicObject._y = intInitialY;

this.PositionInitialX = intInitialX;
this.PositionInitialY = intInitialY;

this.GraphicTransform = new Transform(this.GraphicObject);

this.LifeBegin = 0;
}

function SetColor(ctfColorInitial:ColorTransform, ctfColorFinal:ColorTransform):Boolean
{
if (this.LifeBegin)
return false;

this.ColorInitial = ctfColorInitial;
this.ColorMedian = null;
this.ColorFinal = ctfColorFinal;

return true;
}

function Run():Boolean
{
this.LifeNow = new Date();

if (!this.LifeBegin)
{
this.LifeBegin = this.LifeNow.getTime();
this.ColorCurrent = this.ColorInitial;
this.GraphicTransform.colorTransform(this.ColorCurrent);
}

return true;
}
}

Call JS From AS Not Working..
Hi please can you look at this problem
at left side of the page, www.fluxads.com you can see few flash buttons each button calls Javascript in HTML source.

buttons are working if you check it out on http://www.fluxads.com, but if you check it on http://fluxads.com.. buttons are dead..

So, can someone help me?
Thanks
V.

PS.
This is only soultion I found that works for all browsers, if I put links in text file and loadVariables, Opera based browsers are not accepting it.. and so on..

Call Not Working?
Hi all,

I'm a bit of a beginner to ActionScript, so i would really appreciate any help you can give me. I have a movie with just one scene. And several frames. At the end of the movie there is a frame containing some ActionScript which i have labelled: leaderBoard. The first frame calls this frame as follows:
call("leaderBoard");

When i export the file from within flash, it works fine. The leaderBoard frame is called & everything progresses as normal. However, when i try to play the standalone .swf, the leaderBoard frame does not get called. Would anyone know why this might be?

Thanks so much for your help.
Celine

Call() Function. BUG?
Hello,

I found out:

- I do a call() in Flash 4 and in the
script of the call there is quite some stuff going on.

- Directly under the call() statement I want to get a
variable which has been generated by that call.

This didn't work properly, as if Flash didn't wait for the code in the frame I called to execute!!!

Instead I placed the code that was in the frame of the call
in the frame before the frame I wanted to get the variable.
This worked.

My question is, if anyone knows: does Flash give a call() statement a certain amount of maximum time, before it goes on executing other code? (For instance, does the framerate have to do anything with it?)

I'm really bothered by this... If anyone is really interested, I could mail the code, but it's quite a chunk..

thanks in advance,
Wubbo

Call A Function
Hi,

I have a simple question (I hope it’s simple) !

I have a MC!
The MC is placed on the main line (_root), and the instance name is “myMC”.

In the MC I have in “frame 1” a function called
“test” -> “function test()”.
This function is in “frame 1”, not in a “onClipEvent”!

Now, I want to call this function from the main line (_root).
I have tried a lot of possibilities, here a short description:

-) _root.myMC.test()
-) myMC.test()
-) test()

but no of the possibilities works!
I can’t call the function from the main (_root)!
The function isn't executed!

Thanks
David

Call That Function
Hi! -

I've got a function inside a movie clip. When this movie clip is on
the stage I can call the function from a button by referencing
MovieClipInstanceName.functionName, but I just can't seem to call this
function automatically ie when the frame is loaded. I need to call this
function every time the frame is viewed to refresh the content of the movie
clip. Can anyone tell me what's up -- pleeeease???

Regards

Darren

PS I'm using Flash MX

Call Function?
heya

i have a function named "anim" on the first frame in the main timeline of my movie, i want to call it with code on a MC on the _root. is this the right way to call it?

onClipEvent (enterFrame) {
_level0.anim.call();
}

thanks for your help!

Call() Or Function() ?
Hi,

I am trying to have a few things done at once (fading menu, appearing new menu, moving objects etc.). Now I have been trying to play with it for a long time with no luck. Untill I just found out I used to do that like H. Curtis explained in his F4 book. I totally forgot about that calling of scripts in a separate /scripts MC.

Of course F5 does have new things, so I am wondering, should I use that method, of making an MC with scripts in it, that I call on the press of my buttons, or does a function somewhere on my timeline work better?

I have to get the following done:

1. I have a dynamic menu
2. on the press of the button, a ' box' appears
3. on the press of a new button, the current box should fade out as the new one fades in

I was thinking of assigning a variable when the button is pressed, so the movie knows what box is displayed, when we press a new button, the movie knows what box to fade out, and we fade in the new box and assign the new variable.

I have to use some standard 'calling' method for it, as that would be the most simple way I guess.

Any idea's?

How To Call Function From MC
hi, how do I call a function on an MC in the timeline, form a MC inside ANOTHER MC...
I have tried
onClipEvent (enterFrame) {
_root.TB.speak();
}
And have tried using _parent, but it doesnt work.
I have also tried putting that on the MC in the itmeline, not the one with the function, and it works that ay, but I need it done this way, thanks!

Call A Function In A Mc From Elsewhere?
If I have a function named drawSquare which I create in a mc with instance name CodeContainer which is on the _root

how can I call that function with a statement like this from the _root

_root.onEnterFrame = drawSquares;

the function works when called from inside the mc, I dont know how put the path to a function.
I want the function to run in the CodeContainer where it draws squares obviously!
this does not work
_root.onEnterFrame = CodeContainer.drawSquares;

thanks mark

Call A Function
hey, i have a problem calling a function

when a movieclip is clicked, i want to trigger a function in a mc on the _root level

this is the mc actrionscript:


Code:
onClipEvent (mouseDown) {
_root.helpmovie.magnify(movie1);
} {
this is the _root movieclip:


Code:
onClipEvent (enterFrame) {
function magnify(movie) {
_root.movie._xscale += (200-_root.movie._xscale)/5;
_root.movie._yscale += (200-_root.movie._yscale)/5;
}
}

Why doesn't it work?

please help me


greetings & a merry christmas


Xaero

Function Call
Can a function be called from anywhere or if I was inside a movie clip and the function was at the root would I have to use

_root.functionname();

Thanks
DL

How Do I Call Or Run A Function?
Dear All,


I'm not sure if this is a no-brainer question to you guys but my mind is twisted already finding a way, i'm sure you may have some answers...

Now, I'm having problems launching a function from a string name

Example:

code:
var myString = "myFunctionName";


how do I call this function:
code:
function myFucntionName(){
trace("Hello Earth");
// other complex hello earth here...
}


if I did have this myFunctionName function that a want to launch inside a frame in my movie and myString accepts string inputs e.g. from a text input or an XML attribute, is there a way to interpret the string into a function name and run it?

Any recommendations?


Bests,
Butch

Function Call (as2.0)
Flash MX
actionScript 2.0

Hi,

I have created a function :

function AnimMenu(lineName, StartX, StartY, NSpeed, StopY, Fcolor, lineLenght)
{
//blablabla
}

Then I want to call this function :

onClipEvent (enterFrame)
{
AnimMenu("drawing0", -221, -86, 35, -10, 0x003399, 113);
}

Is it the way it's suppose to be?
because It doesn't work !!!

Any Idea ?

Thanks

How To Call AS Function?
How to call an AS function?

at start of the script I have

function hideButton (){
setProperty(_root.rotateButton5, _visible, false)
trace ("blabla");
}

at some point I need to call and execute that function..
thanks..

[F8] Where Do I Call My New Function? Help
I´m trying to learn how to add some basic movements to a character.
I found this OS bubble game from gotoandplay.it. My problem now is that I can't seem to find where the move/jump functions are called from.

If you read the *** PART 4 *** bub's playability important note it says they are called from within the bub MC but I don't find any functions activations there.


My own added function is the "sword" function..
I try to get that to work.. (notice there is no sword there yet)

any help appreciated!
/nic

[F8] Call MC Function
How do you call a mc function from the root level? I am currently trying it this way and it's not working.

mc_instance_name.function_name();

Thanks
~SC

From Where Do I Call My Function
Hi guys

I'm working on a Flash guestbook with a simple Access database. Using using XML to parse the entries from the database to Flash. This works like a charm. My problem is, and this might sound very basic: I want to integrate a paging-function with my guestbook. I've created the paging-function, but can't figur out from where I'm supposed to call this function?!

I've attached my Flash and Xml (-and a Css file) file, and posted my code beneath. Hope somebody knows the answer.


Code:
//Declaring variables
var xml_row:Number = 1;
var entry_amount:Number = 20;
var bottom_entry:Number = 0;
var top_entry:Number = entry_amount;
var top_difference:Number = 0;
var top_entry_true:Boolean = false;
var xml_str:String = "";

//Paging function: Show next entries
function next_entries() {
if (xml_row == 1) {
top_entry = xml_row * (entry_amount * 2);
bottom_entry = top_entry - entry_amount;
xml_row = xml_row + 2;
} else {
if (top_entry + entry_amount > xml_length) {
if (top_entry_true == false) {
top_difference = xml_length - top_entry;
xml_row++;
}
top_entry = xml_length;
top_entry_true = true;
} else {
top_entry = xml_row * entry_amount;
xml_row++;
}
bottom_entry = top_entry - entry_amount;
}
trace_function();
}

//Paging function: Show previous entries
function previous_entries() {
if (xml_row != 2 & xml_row != 1) {
if (top_entry_true == true) {
top_entry = top_entry - top_difference;
bottom_entry = bottom_entry - top_difference;
top_entry_true = false;
top_difference = 0;
xml_row--;
} else {
top_entry = top_entry - entry_amount;
bottom_entry = bottom_entry - entry_amount;
xml_row--;
}
} else {
xml_row = 1;
}
trace_function();
}

//Load XML file
guestbook_xml = new XML();
guestbook_xml.ignoreWhite = true;
guestbook_xml.load("xml/guestbook_db.xml");

//Send data from XML to TextField
guestbook_xml.onLoad = function() {
xml_length = guestbook_xml.firstChild.childNodes.length;
for (var i:Number = bottom_entry; i < xml_length; i++) {
xml_str += "<b>" + guestbook_xml.firstChild.childNodes[i].childNodes[2].firstChild.nodeValue + "</b><br><a href='mailto:" + guestbook_xml.firstChild.childNodes[i].childNodes[3].firstChild.nodeValue + "' class='mailLink'>" + guestbook_xml.firstChild.childNodes[i].childNodes[3].firstChild.nodeValue + "</a><br>" + guestbook_xml.firstChild.childNodes[i].childNodes[4].firstChild.nodeValue + "<br><br>";
}
xml_txt.htmlText = "<body>" + xml_str + "</body>";
};

[F8] Call PHP Function
say i had a function in the php of a page that my flash was embedded in. how could I call this function using actionscript?

[CS3]Call Function Bug
Hi all,

I've got a problem in my Actionscript-Code(2.0).

I've got 2 layers. One contains a movieclip, which contains a function.

The other one contains a AS-Code which calls this function.

If I use this code the function is called correctly.

Code:
function loadXML(loaded){
if (loaded){
_root.test_mc.test_function("hello");
}
else{
trace("file not loaded!");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("test.xml");


but if I delete the XML-part the function wouldn't be called.


Code:
_root.test_mc.test_function("hello");


Does anyone have an answer?

[CS3/AS2] How To Call Function Only Once
I got a timer and when time is 30, I need it to run a function, but it does the function as many times as it can before the timer changes (it changes about once a second). So with the next code I have my thing going to randomspot like 20 times or so within the 1 second when it's supposed to just change its position once.
(the function just does mc._x/y = random)


Code:
onClipEvent (load) {
_root.timer = _root.remain*20;
_root.time_show = Math.round(_root.timer/20);
}
onClipEvent (enterFrame) {
if (_root.time_show > 0) {
_root.timer--;
}
if(_root.time_show = 30){
_root.randomspot();
}
_root.time_show = Math.round(_root.timer/20);
}

Call Function
This is driving me round the bend, and I know it's simple.

I have a movie which allows the user to toggle between audio and text.

When they enter a particular frame, the relevant text or audio is opened.

This is the code I'm using for each frame:


ActionScript Code:
stop();
onEnterFrame = function() {
    if(myButton._currentframe ==1){
        myText = "";
        var mySound= new Sound;
        mySound.attachSound("dialogue");
        mySound.start();
//This will open the audio version
    }else if(myButton._currentframe ==2){
        stopAllSounds();
        myText = "hello";
//This will open the text version
    }
}
delete this.onEnterFrame

But if the user presses the button ("myButton")which toggles between the sound and text, nothing happens because I've removed the function.

How do I make my button call the function again??!!

Please, please can someone help!! I know I'm missing something simple!

Only Call Function Once
I'm trying to auto-hide a menu based on the mouse position and I've got it working however I'm listening for the mouse move with an onClipEvent and my problem is only calling the function once. It's clear that it's working but it keeps calling the function and hence I've lost the smooth transition from the mx.transition.

This is the code on the menu mc

Code:
onClipEvent (enterFrame) {
if (_level0._ymouse<_level0.mask_center) {
_level0.hideMenu();
} else if (_level0._ymouse>_level0.mask_center+85) {
_level0.showMenu();
}
}

This is the code in the frame:

Code:
function UpDown(MC, End, Time) {
MoveMC = new mx.transitions.Tween(MC, "_y", mx.transitions.easing.Strong.easeOut, MC._y, End, Time, true);
buildStage();
}
function hideMenu() {
UpDown(_level0.menu_holder.menu,150,1.5);
}
function showMenu() {
UpDown(_level0.menu_holder.menu,8,1.5);
}
Alternatively I know that there are new mouse listeners however I have no clue how to use them. If it's simpler that way and someone can point me in the right direction, that would be great!

Thanks in advance!

?have Tab Call Function
I have a timeline1_mc that scrolls to different xPostions using a function called scrollme1

Inside timeline1_mc I have a number of inputText components.

What I'd like to happen is for timeline1_mc to scroll to -400 xPostion using the scrollme1 function when the user tabs to a form labeled street_address.

This is what's not working for me


Code:
this.timeline1.street_address.onSetFocus = function(){
this.timeline1.scrollme1(-400);
}


//finds current x pos and sets speed to new x pos
MovieClip.prototype.scrollme1 = function(xPos) {
cX = this._x;
difX = cX-xPos;
this._x = cX-(difX/5);
};

//the three timline arrays
//variable starting value
arrayIndex = 0;
//timeline stopping postions
timeline1Xpos = new Array(0, -400, -800, -1200, -1600, -2000);
//scrolling animation
timeline1.onEnterFrame = function() {
this.scrollme1(timeline1Xpos[arrayIndex]);
};

//buttons that scroll the timeline to specific x positions
//but1,2,3,4,5,6,7,8, all here
for (var i = 1; i<=5; i++) {
controller_mc.but1.gotoAndStop("down");
controller_mc["but"+i].i = i;
controller_mc["but"+i].onRollOver = function() {
this.frameHold = this._currentframe;
this.gotoAndStop("over");
};
controller_mc["but"+i].onRollOut = function() {
this.gotoAndStop(this.frameHold);
};
controller_mc["but"+i].onRelease = function() {
butRelease(this);
};
}
function butRelease(obj) {
this = obj;
arrayIndex = this.i-1;
for (var mc in this._parent) {
var thisHold = this;
if ((this._parent[mc] == thisHold) && (this._parent[mc]._name.indexOf("but") != -1)) {
this._parent[mc].gotoAndStop("down");
} else {
this._parent[mc].gotoAndStop("up");
}
}
}

JS Call AS Function
Hi all,

Is it possible to get JavaScript to call an AS method?
I know the other way around is (using ExternalInterface) but I can't seem to get the other way to work.

Example I've tried:

ActionScript Code:
package{

    import flash.display.Sprite;

    public class Main extends Sprite{
       
        public function Main():void{
        }
       
        public function callMe(s:String):void{
            trace(s);
        }
    }
}

I'm calling it like this:

Code:
<html>
<head>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>

<script type="text/javascript">
$(function(){

swfobject.embedSWF("Main.swf", "eg", "300", "120", "9.0.0","expressInstall.swf", {}, {}, {});

var swf = swfobject.getObjectById('eg');
if(swf){
swf.callMe("Hello swf from flash");
}
});
</script>
</head>

<body>
<div id="eg">123</div>
</body>
</html>

Function Call
Hi, I have a simple question, I hope. I have a document class calling a "navigation bar" class and a "library" class. When I click a button in the navigation bar, I would like to call a function in the document class to clear the library and rebuild the library with new data.

I'm not sure how to address the function in the document class from the navigation bar class. Any ideas?

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