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




Calling A Function



i have this function

function fadeIn(clipName)
{
extendTween = new TweenExtended(clipName,["_alpha"],easingType2,[clipName._alpha],[100],2,true);
}

how do i call it, in terms of i want multiple clips to fade in when i start my movie eg.

clip1._alpha=0;
clip2._alpha=0;
fadeIn(clip1);
fadeIn(clip2);

i'm missing something as it not working at the Mo!!!
Rat



FlashKit > Flash Help > Flash ActionScript
Posted on: 11-10-2006, 05:56 AM


View Complete Forum Thread with Replies

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

Calling A Function, External To The Calling Class
hello to everyone, who looks at this post
So there's a class, that needs to call/access an external function.
'External' (imho) in this case would be any function, declared outside of the class.
How is it possible to:
1) call a function declared in the main timeline.
2) call a function in another class (i suppose, the only way of doing it is by importing the class having this function into the calling class?)

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

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.

OOP In Flash: Calling A Function W/in A Function Class?
Okay so I am reading through sens tutorial on OOP and updating my game that I am making. It is much easier to code this way (IMO) but still hitting snags.
I am trying to get through this code:

ActionScript Code:
House = function(){        this.floors = 4;         this.siding = "Red";         this.outputSiding = function(){            trace(this.siding);         };     };         // create an instance of the House class     myHouse = new House();     myHouse.outputSiding(); // traces "Red"  

Now as it seems to me, I have nearly the same thing (I will condense this to save space):

ActionScript Code:
//set new character function()character = function (depth, x, y, charType, name, HP, MP) {    //sets stats used; this works fine :)        //attachMovie and set x/y     _root.attachMovie(this.name+"_mc", this.name+"MC", this.depth, {_x:this.x,_y:this.y});    /*this is where I am having trouble; it won't do anything!I have tried tracing to no availalso, can I set the x and y coords somehow with thealready made object x and y? I am tired right now andcan't think of a way but what I have done, which doesnothing as this function won't go!*/    statsBox = function(depth)  {        this.depth = depth;        trace(this.depth+newline+'hello');        this.x = enemy._x+130;        this.y = enemy._y-50;        _root.attachMovie("stats_mc", statsNameMC, this.depth, {_x:this.x,_y:this.y});    };};enemy = new character(30, 350, 200, 'enemy', 'genericName', _root.EHP, _root.EMP);enemy.statsBox(50);

that's it, pretty much. So what's wrong? Maybe I'm too tired for this right now...
thanks.

OOP In Flash: Calling A Function W/in A Function Class?
Okay so I am reading through sens tutorial on OOP and updating my game that I am making. It is much easier to code this way (IMO) but still hitting snags.
I am trying to get through this code:

ActionScript Code:
House = function(){        this.floors = 4;         this.siding = "Red";         this.outputSiding = function(){            trace(this.siding);         };     };         // create an instance of the House class     myHouse = new House();     myHouse.outputSiding(); // traces "Red"  

Now as it seems to me, I have nearly the same thing (I will condense this to save space):

ActionScript Code:
//set new character function()character = function (depth, x, y, charType, name, HP, MP) {    //sets stats used; this works fine :)        //attachMovie and set x/y     _root.attachMovie(this.name+"_mc", this.name+"MC", this.depth, {_x:this.x,_y:this.y});    /*this is where I am having trouble; it won't do anything!I have tried tracing to no availalso, can I set the x and y coords somehow with thealready made object x and y? I am tired right now andcan't think of a way but what I have done, which doesnothing as this function won't go!*/    statsBox = function(depth)  {        this.depth = depth;        trace(this.depth+newline+'hello');        this.x = enemy._x+130;        this.y = enemy._y-50;        _root.attachMovie("stats_mc", statsNameMC, this.depth, {_x:this.x,_y:this.y});    };};enemy = new character(30, 350, 200, 'enemy', 'genericName', _root.EHP, _root.EMP);enemy.statsBox(50);

that's it, pretty much. So what's wrong? Maybe I'm too tired for this right now...
thanks.

[F8] Calling A Function Froma Function
Please excuse my ignorance, but can i call a function from a different function. I'm not sure how to do it.

eg:
myBut.onPress = function ()
{
_root.currentimage=1;
_root.crumb.titles="/fashion&lifestyle";
_root.loadLeft._visible=0;
FashStrip.mc01._alpha = 60;
}

how do i integrate this into the above function?:
function fadeOut()
{
extendTween = new TweenExtended(_root.loadLeft.fashThumb,["_alpha"],
easingType4,[_root.loadLeft.fashThumb._alpha],[0],1,true);
}

i know i could put it straight in the button function but i want to reuse the fadeOut function again many times!!! (just learning to keep my code nice and neat)

Rat

Calling Function From Within A Nested Function
Hi guys,

I current have this piece of code:


Code:

var parentObj:Object = this;

this.form.submit.onRelease = function() {
parentObj.processingIn();
}

function processingAnimationIn():Void{
//DO STUFF
}
But I can't get this to work. Does anyone know what's going on?

Thanks!

Calling A Function Inside Another Function
Hi All,

I've set up two functions (friendsClick and policyLink) I would like to use everything inside of friendsClick inside of policyLink but I'm not sure how to go about doing it. I get the following error:
1136: Incorrect number of arguments. Expected 1.

My code looks similar to:


Code:
function policyLink(e:MouseEvent){
friendsClick();
"all my other info here"
}
I can just copy everything from the friendsClick function and paste, but I'm trying to limit my amount of repetitive code (I'm trying to get better at that). Please Help.

Calling A Function Inside Another Function
Hi i've created some functions that run when diffrenent buttons are pressed, and they work fine, but i want something else to do the same thing when any of the buttons are pressed, i thought the easiest way to do it was to create a function and call it each time one of the buttons are pressed. but what is the code to run the function??

all the code is on the main timeline..

i've wrote this and it doesn't work....

the function i want to run is:


brentGandS = function (){
_root.menu_mc.brent_mc.tween("_width",200,5,"easeoutelastic")
}


and the on press function is:

menu_mc.contact_btn.onPress = function() {
window_mc.resizeTo(250, 350, speed, "easeoutelastic", onEnda);
brentGandS
};

any ideas????????

Calling A Function
I set a function in frame one of the main stage called salWalk.

I access it in the last frame of _root.sal but it is not calling the function.

What I wrote is this in the last frame:

stop ();
i = Math.round (Math.random () * 40);
if (i =26){
i = 41
}
salWalk(i);

and the function is this:

function salWalk(i){
sal_[i].gotoAndPlay("move");
}


what am I doing wrong?

Calling A Function
I have placed a function on a timeline which reads:

function intro () {gotoAndPlay ("Scene 2", "one");
}

I am now trying to call that function from a button placed on a movie clip, the script I have placed is:

on (release) {
function intro() {
}
}


however I am not sure what the command is for calling the function because this seems to relate to creating another function, I would be grateful to anyone who can help.

Calling A Function
I'm having difficulties with a .swf that is loaded into _level1 that is calling a function on _level0. It works when loaded localy:
ex: loadMovieNum("menu.swf", 1);

It does not work when loaded from a URL
ex: loadMovieNum("http://www.xyz.com/www/menu.swf", 1);

The calling code of the function is located in the movie being loaded into _level1.

ex:_level0._root.myFunctionName();

Function Calling
Can anyone tell me how to call functions from different levels in my movie.

I have several functions ... some on the main timeline, others in movie clips ... and i need to call these from anywhere withing my movie, for example when i call a function from within a movie it does not work.

Function Calling . . .
Friends,

I have what appears to be a simple function. However, weverytime it runs my variables come back as undefined. Here, take a look:

FRAME 1:

function slideAmount (functionBoxDepth) {
var functionSlideAmount = functionBoxDepth/480;
return functionSlideAmount;
}


MOVIECLIP in FRAME 1:

onClipEvent(load){
boxDepth = getProperty(this,_height);
trace(boxDepth);
//So far, so good.
thisSlideAmount = slideAmount(boxDepth);
trace(thisSlideAmount);
// DAMN!
}

The second trace command always returns "undefined."

Me so confused!

Calling A Function?
ok maybe this beolongs in newbies but I can't figure this out. I have a dynamic calendar in a movie clip wihtin the main timeline. The main timeline, onRelease of a a button for location, draws the data in using an asp file and tellTarget's the calendarwindow instance of the calendar symbol. There is a function in frame one of the calendar symbol to parse the data a build the calendar (via dynamic text blocks).

how do I get that function to trigger automatically when the calendarwindow begins playing?

i can get it to work when I have a button in frame one which calls the function and then gotoAndPlay's the frame with the built calendar but not autorun. any help would be much appreciated. code to follow:

on (release) {
loadVariables("flavorsflash.asp?loc=2&m=10", "calendarwindow");
gotoAndPlay(5);
tellTarget ("calendarwindow") {
gotoAndPlay("yorc");
}
}

and right now I'm using this to all the function, it's like the fourth thing I've tried:

offsetDays.call(null, firstWeekDay);

thanks

lateralis

Calling Function
Hi,

I'm loading XML into flash.
but insted of using the standard;

Code:
thisXML = new XML();
thisXML.ignoreWhite = true;
thisXML.onLoad = myLoad;
thisXML.load("environment_page.xml");

I've made an XML preloader, but now i can't call the function.
i'm trying;

Code:
myLoad(thisXML);

but of course that won't work. i'm not too good with functions...

anyone??

many thanks

Calling A Function In A MC
I am trying to call a function that is in a MovieClip. I have a movie clip named "box" and a function in that mc called myFunction.
//----- in the box MC on the _root-------
function myFunction()
{
trace("this is a function")
}
//----- on the _root timeLine
box.myFunction()

What do i need to do difrently

Calling A Function Using If
Hi

I got this code from someone on FK recently. And it works a treat.

on (release) {
_root.remoteMovie.tempMovie._visible = true
obj = new Object();
obj.interval = function() {
_root.remoteMovie.tempMovie._visible = false
};
setInterval(obj, "interval", 2000);
}

The trouble is that I want to have three seperate buttons calling the same function. So I tried putting it in the main timeline and using variables on the buttons to call it.. but it don't work.. can anyone tell me why?

//button code

on (release) {
_root.tempOn = true;
}

//maintimeline code

if (_root.tempOn == true) {
_root.remoteMovie.tempMovie._visible = true
obj = new Object();
obj.interval = function() {
_root.remoteMovie.tempMovie._visible = false
};
setInterval(obj, "interval", 2000);
}

Am I right in thinking it is because "if" only checks the variables one time?? If so what do I change it to??

Calling A Function
_global.loadImage = function(Image) {
trace("LoadImage");
preload(ImageSpace);
}

function preload(preloadContent) {
trace("preloader");
}


"LoadImage" is returned when loadImage is called, but "preloader" is not. Any idea why this is?

Thanks

Calling A Function
Hey, what is wrong with this?
Code:
initvalues = function (X, Y, XYscale, Alpha) {
this._x = X
this._y = Y
this._xscale = this._yscale = XYscale
this._alpha = Alpha
}

var mc_a = _root.mc_1
var mc_b = _root.mc_2

trace ("mc_a = " + mc_a) // returns '_level0.floor_1'
trace ("mc_b = " + mc_b) // returns '_level0.floor_2'

mc_a.onLoad = initvalues (10, 10, 20, 40)
mc_b.onLoad = initvalues (100, 100, 60, 100)
I expect _root.mc_1 to attain the properties _x = 10, _y = 10, _xscale = _yscale = 20, _alpha = 40
and _root.mc_2 to have the properties _x = 100, _y = 100, _xscale = _yscale = 60, _alpha = 100. However, _root.mc_1 appears above _root.mc_2, having the same properties.

Any ideas?
Thanks

Calling Function Of A MC From Another MC
Hi,

I need a little help concerning the possibility of calling a function declared in a frame of a MC from another MC in this MC.

I have 2 buttons in MC1. But, I want in my MC1.2 to know wich button was pressed.

Do someone can help me with this ?

Calling A Function - Help
When the close button in the popup is pressed it wont call the function from the main menu.

Can someone tell me why this function aint been called from the main menu?

Popup menu

// calls Var
this.window_mc.jpgwindow_mc.loadMovie(_level0.jpgV ar + ".jpg");

// calls this function from the main movie
window_mc.close_btn.onRelease = function() {
_level0.popUpClose(window_mc);
trace(_level0.jpgVar);
}

main menu

// functions to close pop-up
function popUpClose(window) {
unloadMovieNum(2);
for (var item in buttons) {
eval(buttons[item]).enabled = true;
}
}
//Button Code
button1.onRelease = function() {
_level0.jpgVar = 3;
popUpOpen("landpopUp.swf");
};


Now the trace is a test that pulls up the number from the main menu to test that its reading

from the main menu. This works fine and returns the varable so its finding the number from the

_level0. Its just not calling the popupclose function. Whyyyyyyyy.

This is tearing my hair out!!

Calling The Same Function Again And Again.
I have a function that changes an MC’s alpha from 0 to 100%. I use this same function over and over, once for each MC (there are 10 of them). Is it possible to compact my code, so that I only have to write this function once while calling it 10 times.

At the moment, my code looks like this:

var speed:Number=20;

tile_1_mc._alpha=0;
tile_2_mc._alpha=0;
tile_3_mc._alpha=0;
tile_4_mc._alpha=0;

…and so forth till tile 10.


AlphaIn();

function AlphaIn (Void):Void{
tile_1_mc.onEnterFrame = function() {
this._alpha += speed;
if (this._alpha>=100) {
tile2();
delete this.onEnterFrame;
}
}
}

function tile2(Void):Void{
tile_2_mc.onEnterFrame = function() {
this._alpha += speed;
if (this._alpha>=100) {
tile3();
delete this.onEnterFrame;
}
}
}

function tile3(Void):Void{
tile_32_mc.onEnterFrame = function() {
this._alpha += speed;
if (this._alpha>=100) {
tile4();
delete this.onEnterFrame;
}
}
}

function tile4(Void):Void{
tile_4_mc.onEnterFrame = function() {
this._alpha += speed;
if (this._alpha>=100) {
tile5();
delete this.onEnterFrame;
}
}
}

…and so forth till the last tile10 function is called.

TIA!

Calling A Function From Another SWF
Hello,

I'm building a flash file called "training_intro" that plays a series of flv's through another flash file called "video_player". With a lot of help from you good people, I've got a listener on "video_player" that tells me when the flv is done. When that happens I need to trigger a function in the main flash file "train_intro". How do I send a call between swf?

Thanks

Calling A Function From Another SWF
Hello,

I'm building a flash file called "training_intro" that plays a series of flv's through another flash file called "video_player". With a lot of help from you good people, I've got a listener on "video_player" that tells me when the flv is done. When that happens I need to trigger a function in the main flash file "train_intro". How do I send a call between swf?

Thanks

Calling A Function
Hi Guys,
I have a button inside a movie clip that i want to use to call a function on the main timeline.
Can any one help me out.
This is the function in the main timeline

//calling with button on timeline//
exit_btn.onRelease = function() {
exitPanel();
}

//the function//
function exitPanel() {
easeType = mx.transitions.easing.Strong.easeOut;
var begin = 3;
var end = -306;
var time = 0.5;
var mc = media_mc;
panelSlide = new mx.transitions.Tween(mc, "_x", easeType, begin, end, time, true);

I can call it with a button in the main timeline, but it wont work with a button inside a movieclip. Really stuck.

Calling A Function
Hi guys

suppose you want to call a function let's say:

function ctrl_status () {
}

Now normally to 'call' this function you use:

ctrl_status();

Is there a way to 'build' this 'call' so that I have something like:

"ctrl_"+variable+"()";

Thanx in advance for your help

Calling Function
AS2.0
I currently have a text box, "Coordinates", and a function which loads into it the xmouse and ymouse properties [See Below]. I would like for this function to be called as false/void when I rollOver a separate mc so that I can then load different text, i.e. "click to copy". Then when I rollOut I can call the function true and the xmouse and ymouse will be loaded back into Coordinates.text. The problem is this can't just be done by loading different text into the text box as it opperates onMouseMove so as soon as I move the cursor it would revert back.

//on mc ("Cursor") in which Coordinates.text is located
onClipEvent (load) {
onMouseMove = function () {
Coordinates.text = "X" + _root._xmouse + ",Y" + _root._ymouse;
};

//on mc which I want to have change the contents of Coordinates.text
on (rollOver){
_root.Cursor.Coordinates.text = "click to copy to clipboard";
}

Calling A Function
I have a very basic question. I have a custom class called caurina. I've imported the class and it works great. What i did is use that as a function called slide().

What I would like to do is make that function play when a button is pressed. I can't seem to find out how to do this anywhere. I am using as3 in CS4.

Summary: When btn is pressed go play function slide()
Thanks!

Calling A Function On A MC?
I have a movie clip whose name is 'targetMC'
I have written a function on the MC using the onClipEvent handler.

onClipEvent(load){
function targetFunction(){
do somthing I need...
}
}

I than duplicate the mc several times.

for (i=2; i<=_root.maxDups; i++){
duplicateMovieClip('targetMC','targetMC'+i, i);
}

I need to call the function for each of these MCs at different times, and from different places within the movie.

if I do the following:
_root.targetMC12.targetFunction();

Flash looks for the function on the main timeline within the MC, which is what it should do, but how do I access / call the function that resides on top of the MC?

Thanks,
Hiram

Calling Function
hi I am a bit new at this whole function thing.
I know how to assign functions to listeners, but when I was given advice that I should...
have a single function that the listener calls, and on the first frame of the movie you call that function.

Does anyone know a good tute which would guide me through the calling function thing?

Thanks

Help With Calling Function
I am trying to set a moving function that I can change the speed in each level of my game and can be called for each object that I create. currently I have this function in each symbol, but I need to create it as a global function to be called by each MC instance when created:

this.moving = function() {
if(this.hitTest(_parent.c_belt)){
this._x+=_root.speed;}
if(this.hitTest(_parent.trash)){
trashCount++;
if(trashCount == 1){
_root.score = _root.score - 50;
}
this._visible=false;
}
}

Help?

Calling AS Function From JS
Hey People,

I'm looking at the AS 8 Bible, specifically on calling AS functions from JS and I have done just what they have said... I have a function in my main .as file called "collapseMenu" and I have entered this code in, just under that function

Code:
ExternalInterface.addCallback("runCollapseMenu", null, collapseMenu);
Now in my HTML page, I have this


HTML Code:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>menubar</title>

<SCRIPT LANGUAGE=JavaScript>
function initialize() {
if (navigator.appName.indexOf("Microsoft") != -1) {
flash = window.menubar;
}
else {
flash = window.document.menubar;
}
}
</SCRIPT>

</head>
<body onLoad="initialize();" bgcolor="#ffffff">

<SCRIPT LANGUAGE=JavaScript>
function collapse() {
flash.collapseFlash();
alert('gibds');
}
</script>

<div id="swf">
<object onblur=runCollapseMenu() classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="800" height="280" id="menubar" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="menubar.swf" />
<param name="quality" value="high" />
<param name="wmode" value="transparent" />
<param name="bgcolor" value="#ffffff" />
<embed src="menubar.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="800" height="280" name="menubar" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</div>

</body>
</html>
For some reason, when I click outside of the .swf area though, nothing happens. In the JavaScript console, it says that "runCollapseMenu" is not a function. If I take that like of code out of my HTML, leaving only the javascript alert, it will come up when I click outside of the swf area.

Anyone have any idea why the runCollapseMenu won't register properly for me?

Thanks,

--D

Calling A Function From Itself?
For a game I am making, I want an item to be placed randomly on the stage, but it must fall within certain boundaries. To do this, I first generate a random position, then check whether this position falls within the allowable boundaries. If it does, then create the item, if it doesn't then repeat the process until a suitable position is found.

The code works as expected, I was just wondering if anyone has anything to say about calling a function from itself?


ActionScript Code:
function generateTokenPosition():Array {
    var tokenX:Number = Math.round(Math.random() * 19);
    var tokenY:Number = Math.round(Math.random() * 22);
    var proposedTokenTile:String = "t_" + tokenY + "_" + tokenX;
    var tokenInfo:Array = new Array();
    tokenInfo = [tokenX, tokenY, proposedTokenTile];
    return tokenInfo;
}


function makeToken():Void {
    var tokenInfo = generateTokenPosition();
    var tokenX:Number = tokenInfo[0];
    var tokenY:Number = tokenInfo[1];
    var tokenTile:String = tokenInfo[2];
    if (Game.container[tokenTile].walkable){
        Game.container.attachMovie("Token", "token_mc", 45000);
        Game.container.token_mc._x = (tokenX * Tile.tileW) + Tile.tileW / 2;
        Game.container.token_mc._y = (tokenY * Tile.tileH) + Tile.tileH / 2;   
        tilePosition = tokenTile;
    } else {
        makeToken();
    }
}

Calling A Function
Hi guys,
im wondering if someone can put me out of my insanity. Im trying to call a function that is on the main stage with a button that is inside a movieclip. I can only seem to get the function to work when i put the button on the main stage.
This is the code i used on the main stage which works

_root.test_btn.onRelease = function() {
slidePanel();
}
For some reason i can get the button inside a movieclip to exectue a function. Can anyone help me out?

Calling A Function. With Or Without ()
its not really urgent, but it occurs to me from time to time. What is the difference between calling a function like


ActionScript Code:
myFunc;

and like:

ActionScript Code:
myFunc();


Call me stupid if you want but i never figured that one!

Function Calling Twice
I have no idea what in the world is going on here. What am I over looking:

AS 2.0

ActionScript Code:
import mx.utils.Delegate;

import com.fg.parser.XMLParser;

class DocumentClass
{
    private var _root:MovieClip;
    private var _info:XMLParser;
    private var _xmldoc:String;
   
    private var _i:Number = 0;
    private var _interval:Number = 0;
   
    public function DocumentClass(scope:MovieClip)
    {
        _root = scope;
        _xmldoc =  (_root.xmldoc != undefined) ? _root.xmldoc : "default.xml";
       
        loadXML();
    }
   
    private function loadXML():Void
    {
        _info = new XMLParser();
        _info.addEventListener( XMLParser.COMPLETE, Delegate.create(this,initMovie) );
        _info.load( _xmldoc );
    }
   
    private function initMovie():Void
    {
        trace("initMovie called");
        makeBalls();
        trace("---------");
    }
   
    private function makeBalls():Void
    {
        trace("makeBalls called");
       
        //for (var i:Number=0; i<6; i++) trace("i = " + _info.data[i].y);
        //for (_i; _i<6; _i++)      trace("_i = " + _info.data[_i].y);
    }
}

When the line

ActionScript Code:
for (var i:Number=0; i<6; i++) trace("i = " + _info.data[i].y);
is ran, every works as expected. It traces this:

Code:
initMovie called
makeBalls called
i = 896
i = 896
i = 550
i = 204
i = 204
i = 550
---------
However, whenever this line is ran

ActionScript Code:
for (_i; _i<6; _i++)          trace("_i = " + _info.data[_i].y);
I get this:

Code:
initMovie called
makeBalls called
_i = 896
_i = 896
_i = 550
_i = 204
_i = 204
_i = 550
---------
initMovie called
makeBalls called
---------
How in the world is initMovie getting called again just from that 1 line???

just incase you need this:

ActionScript Code:
import mx.events.EventDispatcher;
import mx.utils.Delegate;

class com.fg.parser.XMLParser extends EventDispatcher
{
    private var _xml:XML;
    private var _data:Array;
   
    private static var _complete:String = "complete";
   
    public static function get COMPLETE():String { return _complete; }
   
    public function XMLParser()
    {
        _data = new Array();
       
        _xml = new XML();
        _xml.ignoreWhite = true;
        _xml.onLoad = Delegate.create(this, onLoad);
    }
   
    public function load(file:String):Void
    {
        _xml.load(file);
    }
   
    private function onLoad(success:Boolean):Void
    {
        if(success)
        {
            var nodes:Array = _xml.firstChild.childNodes;
            for (var i:Number=0; i<nodes.length; i++)
            {
                var obj:Object = new Object();
                obj.id  = nodes[i].firstChild.firstChild.nodeValue;
                obj.name = nodes[i].firstChild.nextSibling.firstChild.nodeValue;
                obj.x   = nodes[i].firstChild.nextSibling.nextSibling.firstChild.nodeValue;
                obj.y   = nodes[i].firstChild.nextSibling.nextSibling.nextSibling.firstChild.nodeValue;
                obj.links = nodes[i].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.nodeValue;
               
                _data.push(obj);
            }
           
            dispatchEvent( {type:COMPLETE, target:this, status:success} );
        }
    }
   
    public function get data():Array { return _data; }
}

Calling A Function
This may seem like a lame question, but I'm loading in a SWF. The SWF has a function call on the last frame. It's trying to call a function on the main timeline.

This is the code:

this.parent.parent.callFun(); - doesn't work

nor does

this.parent.callFun();

Am I missing something obvious? Thanks!

Getting The Calling Function's Name
Is this possible? I've tried:

arguments.caller.name
arguments.caller.toSource()
arguments.caller.toString()
arguments.caller.prototype

And no luck.

Calling A Function
hello

here is my prob :

on frame 1 : I define a function
exemple : function exemple(){
a=1;
}//end function

on frame 2 : line0 :exemple()
line1 : trace(a);

=> but there is no trace of a. the function has not been called

but if I add a button with on release exemple(), the function exemple has been called

is this normal ? how can I call and execute a function without calling it trough a button.


thanks for your help !

Calling A Function
Here's what I have:

ActionScript Code:
function TurnOff () {
                _root.DonPicturetar._visible=false;
                _root.DonGlowtar._visible=false;
                _root.UPCOMING._visible=false;
                _root.NEWS1._visible=false;
                _root.ScrollBox._visible=false;
                _root.TextBck._visible=false;
                _root.SlideScreen.gotoAndPlay("open");
                menuItem = "on";
}



//assign a value to the menu being closed
menuItem = "off";


_root.watchTrailer.onRelease = function() {
        if (menuItem == "off") {
            TurnOff.call()
            SlideScreen.menu="trailer.swf";
               
        } else if (menuItem == "on") {
            loadMovieNum("trailer.swf", 1);
                menuItem = "on";
        }
};


When checking script, it says no errors. I get no output of errors when clicking the watchTrailer button.

I just want to condense having that list of setting all those mc's to invisible after checking whether something else is already selected. If I put the code in the function declaration back into each handler for each button, everything works fine.

I thought creating a function to turn all the elements 'off' (make invisible) would be more streamlined and less data in the long end.

But, I'm not doing something right.

Calling A Function
I have written a function which is based on the main timeline. The function is called "dragDrop" which allows the user to drag movie clips to any target location. If the user doesnt drag the object to the hitArea the movieclip returns to its home position. If the user drags the movieClip to the hit area the movieClip will smoothly move into the hit position.
The functions code is as follows:


ActionScript Code:
/* ****************************************
 * Author: L.Tambiah
 * Date: 08/03/05
 * Description: Drag and Drop user template
 * FileName: FADrag&Drop
 ******************************************/
 
//create a function called dragDrop
function dragDrop(movieClip, targ1, targ2) {
   
/*****************************************
* When a user presses the mouse on the
* movieClip enable the a drag.
*****************************************/

    movieClip.onPress = function() {
        startDrag(this);
        mousePressed = true;
    }; //close onPress
   
/*****************************************
* When the user releases the mouse button
* stop dragging the movieClip.
*****************************************/

    movieClip.onRelease = function() {
        stopDrag();
        mousePressed = false;
        //create a test condition using the if statement
        if (eval(this._droptarget) == targ1) {
            this.onTarget = 1;
        } else {
            if (eval(this._droptarget) == targ2) {
                this.onTarget = 2;
            } else {
                this.onTarget = 0;
            } //close else
        } //close else
    }; //close function
/************************************************************
* The variables below will store the clips starting position
************************************************************/

    movieClip.myHomeX = movieClip._x;
    movieClip.myHomeY = movieClip._y;
   
/*********************************************************
* The variables below will store the clips end position
*********************************************************/

    movieClip.myFinalX1 = targ1._x;
    movieClip.myFinalY1 = targ1._y;
    movieClip.myFinalX2 = targ2._x;
    movieClip.myFinalY2 = targ2._y;
   
/********************************************************
 * Create a new function "onEnterFrame"
 ********************************************************/
 
    movieClip.onEnterFrame = function() {
       
/********************************************************
 * The if statement checks the movieclip position, if the
 * movieclip is not on a target and the mouse is released
 * it returns to the Home position. If the movieclip is
 * on a target location then locate to target position.
 ********************************************************/
 
        if (mousePressed == false && this.onTarget == 0) {
            this._x -= (this._x-this.myHomeX)/4;
            this._y -= (this._y-this.myHomeY)/4;
        } else {
            if (mousePressed == false && this.onTarget == 1) {
                this._x -= (this._x-this.myFinalX1)/4;
                this._y -= (this._y-this.myFinalY1)/4;
            } else {
                if (mousePressed == false && this.onTarget == 2) {
                    this._x -= (this._x-this.myFinalX2)/4;
                    this._y -= (this._y-this.myFinalY2)/4;
                }//close the if statement
            }//close the second else
        }//close the first else
    }; //close onEnterFrame function
}//close dragDrop

dragDrop(drag1, target1, target2);
dragDrop(drag2, target1, target2);

Basically drag1 and drag2 is a rectangle movieclip which can be dragged to target1 and target2. The target1 and target2 are also a movieclip in shape of a rectangle but a different colour.

The function is working correctly. What i would like to achieve though is a reset. I have button on the stage labeled "reset" and would like the user to be able to click the reset button so all the dragable movie clips when placed to there target positions will return back to the original position. I thought i should be able to write a function called reset which can then be called from the button. However i didnt have much look with this approach. I would like the movieClips to return to HomeX and HomeY (see code above). Does anyone know how i could implement this?

Help would be most appreciated......

Regards

L. Tambiah

Calling Function
the following codes are in a "TitleWindow"

function Init()
{
var keyListener:Object = new Object();
keyListener.onKeyDown = function()
{

switch (Key.getCode())
{
case Key.ENTER :
this.SendData();
break;
case Key.ESCAPE :
this.deletePopUp();
break;
};

Key.addListener(keyListener);
}

function SendData() is in the same file as function Init().
But Why function SendData() is never called??????

Calling A Function
Hey guys... I'm not exactly the best programmer (as you can probably tell by this post haha). I got this code for a liquid GUI and it works great. Only problem is it doesn't happen when the movie first loads, only if the movie is resized. Normally I'd be able to figure this kinda thing out through some trial and error, but I haven't been able to get it.

I'll include the code here... what I'm trying to do is call the same "myListener" function that resizes these movie clips with an onLoad function in addition to the onResize one that occurs here.... any help would be appreciated.

Stage.scaleMode = "noScale";
Stage.align = "TL";
var myListener:Object = new Object();
myListener.onResize = function (e:Object):Void {
var sw:Number = Stage.width;
var sh:Number = Stage.height;
body_mc._width = sw;
body_mc._height = sh;
bg_mc._height = (sh*.8);
bg_mc._width = (bg_mc._height*1.44);
bg_mc._x = (sw-bg_mc._width)/2;
bg_mc._y = (sh-bg_mc._height)/2;
header_mc._height = (bg_mc._height*.2);
header_mc._width = (bg_mc._width*.965);
header_mc._x = (sw-header_mc._width)/2;
header_mc._y = (bg_mc._y*1.23);
nav_mc._height = (bg_mc._height*.05);
nav_mc._width = (bg_mc._width*.965);
nav_mc._x = (sw-nav_mc._width)/2;
nav_mc._y = (bg_mc._y*3.1);
shadow_mc._height = (bg_mc._height*.21);
shadow_mc._width = (bg_mc._width*1.01);
shadow_mc._x = (sw-shadow_mc._width)/2;
shadow_mc._y = (bg_mc._y*8);
footer_mc._height = (bg_mc._height*.035);
footer_mc._width = (bg_mc._width*.965);
footer_mc._x = (sw-footer_mc._width)/2;
footer_mc._y = (bg_mc._y*8.7);
screen_mc._height = (bg_mc._height*.625);
screen_mc._width = (bg_mc._width*.965);
screen_mc._x = (sw-screen_mc._width)/2;
screen_mc._y = (bg_mc._y*3.6);
};
Stage.addListener(myListener);

Calling A Function
I have a very basic question. I have a custom class called caurina. I've imported the class and it works great. What i did is use that as a function called slide().

What I would like to do is make that function play when a button is pressed. I can't seem to find out how to do this anywhere. I am using as3.

Summary: When btn is pressed go play function slide()
Thanks!

Who Is Calling The Function ?
i have a movie clip of a square in the library exported as Square1, i place 2 instances of it on stage and push them to an array called ar
i add event listeners to both ar[0] and ar[1] to do a certain function.
i need flash to tell me wheter ar[0] or ar[1] called the function. How do I do that ?
thanks!








Attach Code

var ar:Array=new Array();
for (var i=0;i<2;i++)
{
var square=new Square1;
addChild(square)
square.x=100;
square.y=100+100*i;
ar.push(square)
}
ar[0].addEventListener(MouseEvent.MOUSE_OVER, MouseOver);
ar[1].addEventListener(MouseEvent.MOUSE_OVER, MouseOver);

function MouseOver(event:MouseEvent):void{
// who is calling the function ? ar[0] or ar[1] ?
}

Calling Function
I have done a search using "calling function" and tries 5 different things and still no luck but this is a simple problem

on the first and only frame of my movie I have this function


Quote:




blank_mc.onAllSlidesLoaded = function() {
this.uuShow._visible = true;
this.uuShow.beginTransitions();
};




The above code starts my slideshow. However I want my slideshow to start when I click on a button. So I guess I need to comment the above code out and call it through a click of a button

Sandman9

Calling A Function
hello

here is my prob :

on frame 1 : I define a function
exemple : function exemple(){
a=1;
}//end function

on frame 2 : line0 :exemple()
line1 : trace(a);

=> but there is no trace of a. the function has not been called

but if I add a button with on release exemple(), the function exemple has been called

is this normal ? how can I call and execute a function without calling it trough a button.


thanks for your help !

Calling Function
hi !!

I have a function at frame 1 (_root). Well, i am trying to call this function from a button, inside a movie clip, but it's not successful..

anyone could help me ?

thanks
ba

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