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








Calling Inside-movieclip-functions


Hiya!

Here's what I've got:

Inside Movieclip("menu") on frame 1 there are two functions I'd like to call from outside of the movieclip.

my trusty '"Action Script Reference Guide" tells me you may call functions from anywhere in the timeline, provided you acces them with the correct path.

Okay, so : _level0.menu.myfunction(); right?
Wrong. It don't work.

Please help,




FlashKit > Flash Help > Flash ActionScript
Posted on: 04-02-2002, 10:45 AM


View Complete Forum Thread with Replies

Sponsored Links:

Calling Functions Inside A Windows DLL
Hello:

I am not a Flash user yet but I would like to know if it is possible to use a dll from Action Script.

I come from visual basic and I would like to port a software to Flash but I need to comunicate with the functions of a dll. There are several functions inside the dll but the most complicate seems one that must to recieve the pointer of an Array of bytes of 512 size.

Thanks and sorry if I posted in a wrong thread...

ManMatin

View Replies !    View Related
Problem With Calling Functions Inside MC. Please Help
Hi,
I have a movie clip in the library. I attach this MC to another movie clip on the stage.

ActionScript Code:
mc_on_stage.attachMovie("MC","newMC",someDepth);

my MC in the library has som simple motion tweens and at the end of that motion tweens I have

ActionScript Code:
_root.myFunction();stop();

and myFunction is a function in the _root of main movie and continues my flash movie.
The problem is that I can see what myFunction does at home, but the movie stops right before the myFunction on my PC at work. Some of my friends can see whole movie but a few can't and the movie stops right befor myFunction!

Is there any problem with my calling the function?
I have used _parent._parent.myFunction as well but the problem remains unsolved.

Any help please?

View Replies !    View Related
Calling Functions Inside Of An Event Handler
Hi actionscript.org members,

I am working on a xml parser for a class assignment but I am running into some trouble.

I am trying to call a function inside an event handler function for an XML.onLoad inside of a class.


Code:
class Pokedex
{
var xml_file:XML;
var error_message:String;
function Pokedex()
{
this.error_message ="no error message set."
this.xml_file = new XML();
this.xml_file.ignoreWhite = true;
this.xml_file.load("pokedex.xml");
//onLoad returns a boolean for failure/success
this.xml_file.onLoad = validate_xml;

};

function validate_xml(success:Boolean)
{
trace('perform validation');
load_pokedex();
xml_status(this.xml_file);
if (success)
{
trace("node name: " + this.xml_file.firstChild.nodeName);
trace("node name of first child: " + this.xml_file.firstChild.firstChild.nodeName);
}
};

function load_pokedex():Void
{
trace('Load Pokedex');
};

function xml_status(xml_file:XML):Void
{
trace('status:'+ xml_file.status);
switch (xml_file.status)
{
case 0 :
error_message = "No error; parse was completed successfully.";
break;
case -2 :
error_message = "A CDATA section was not properly terminated.";
break;
case -3 :
error_message = "The XML declaration was not properly terminated.";
break;
case -4 :
error_message = "The DOCTYPE declaration was not properly terminated.";
break;
case -5 :
error_message = "A comment was not properly terminated.";
break;
case -6 :
error_message = "An XML element was malformed.";
break;
case -7 :
error_message = "Out of memory.";
break;
case -8 :
error_message = "An attribute value was not properly terminated.";
break;
case -9 :
error_message = "A start-tag was not matched with an end-tag.";
break;
case -10 :
error_message = "An end-tag was encountered without a matching start-tag.";
break;
default :
error_message = "An unknown error has occurred.";
break;
}
this.error_message = error_message;
trace(this.error_message);
};
}
the event handler function does not call the load_pokedex or any other function I try to call inside of the event handler.
Also the two traces I perform on my xml file comes up undefined.

View Replies !    View Related
Calling Two Functions From Inside An OnRelease Statement
Hi all.

I have this:

Code:

btnContact_mc.onRelease = function  () {
   animateOff(currentPage);
   animateOn("dataContact_mc");
   currentPage = "dataContact_mc";
}

function animateOn(page:String) {
   eval(page).gotoAndPlay("_on");
}

function animateOff(page:String) {
   eval(page).gotoAndPlay("_off");
}


What happens is that animateOff takes a movie clip and fades it to white, then animateOn runs and fades from white into the contents of the movie clip. What is happening though is that both seem to be playing at the same time so one fades to white and then the image that is in the animateOn movie clip just appears but you don't see the fade in.

Did I explain that right? Basically one clip needs to play first and then the next one needs to play. I can't seem to find the right code to make the second one wait until the first one is finished.

Would appreciate any help if someone knows. I'm still pretty new to this so I have probably missed something basic but I just can't figure out what it is.

Cheers.
Jim

View Replies !    View Related
-----Calling Functions Located Inside Duplicated Clips-----
I am duplicating a bunch of movie clips dynamically and i'm stumped as to how to call a function that is located inside one of the dynamically created clips. Let's say i have this:

duplicateMovieClip ("contentsection", "contentsection" + i, i + 50);

And then, i want to call a function (dupLinks) that is located inside that duped movie clip, so i try this:

this["contentsection" + i].dupLinks(parameters);

And nothing!

However, if i try to manipulate a MC inside that duped clip, it works fine:

this["contentsection" + i].MC1._x = 100;

I don't understand why the function cannot be accessed using the dynamic path, but MC properties and variables can. Anyone have any ideas? Thanks.

View Replies !    View Related
Calling Functions Inside Loaded Movie Clips
"calling functions inside loaded movie clips" - Can this be done? If so, lets explore!

I did a search but could not come up with anything so I thought this would be a good thread to start and keep updated. Please use this to consolodate all information on this subject.

I realize that a class file would accomplish the tasks involved in OOP, but as a root designer and Flash beginner, it is easier to use SWF's.


Pet peeve: Posters not being explicit and concise in the Title when creating / replying to posts. I think we should all take our time to properly convey our thoughts when posting. Even for beginners (like me) who more often than not tend to rush to try to get the answer to get the job done. Does anyone agree with me?

View Replies !    View Related
Problem Calling Functions Inside Custom AS 2.0 Class
Hey yall!
Ok here´s my gamepage, what I want to do is let a lister triggered function create a new timer, but somehow it doesn´t work. Hope anyone hava a clue, I´m so tired of these problems.


Code:

class classesUI.GamePage extends MovieClip
{
private var timeKeeper:TimerExtended;//Special class
private var roundTimes:Number;
private var roundTimeKeeper:Number;
private var gameTimeKeeper:Number;

public function GamePage()
{
}
//Init
function onLoad()
{
roundTimes = 0;
roundTimeKeeper = timeKeeper.intervalCall(1000, -1, Delegate.create(this, roundTimer));

//This works, but I don´t want to do this here, I want to do this on onGameStartEvent();
addTimer();
}

private function roundTimer():Void
{
//This works
roundTimes = roundTimes + 1;
_root.mainShell.roundTimer_txt.text = "Round timer:" + roundTimes;
}

public function addTimer():Void
{
gameTimeKeeper = timeKeeper.intervalCall(1000, 60, Delegate.create(this, timerTick));
}

public function timerTick():Void
{
//this never gets triggered unless from onLoad(), why is that??
_root.oppTimer--;
}
//This function is beeing called from another class with this class registered as a listener
public function onGameStartEvent(newGameStartEvent:GameStartEvent)
{
addTimer();
}
}

View Replies !    View Related
Going Nuts...calling Functions Inside Movie Clip..
hey all,

i need some help with calling a function from within a movie clip.

i wrote a function that is with a movie clip, something like this:
-----------------------------------------
function didYouRegister () {
if (userLevel == 1) {
loadMovieNum ("http://www.cnn.com", "blank");
} else if (userLevel == 2) {

}
loadMovieNum ("http://www.cbc.ca", "blank");
}

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

now, when the movie is loaded i need flash to figure out if the user has registered. in the main time line on the action script layer,i have this line of code, which should kick the user the cnn.com (according to the fucntion "didYouRegister") :

userLevel = 1;


now this is the line of code i have, also in the main timeline in the action script layer, that is supposed to call the function:

callFunction.didYouRegister();

The "callFunction" is the name of the MC that is holding the function called "didYouRegister"


So after all this, i cannot get the fucntion to be called.
Can anyone point me in the right direction?
Thanks so much.

View Replies !    View Related
Issue Calling Functions Within A MovieClip
I have a movie clip on my main timeline. I am attaching other movie clips to the main movie clip on my timeline. Here is the code:


Code:
map_mc.attachMovie("Marker", "Markers"+i, map_mc.getNextHighestDepth());
map_mc["Markers"+i].SetUrl(XmlPreferences.firstChild.firstChild.firstChild.firstChild + String(ID));
map_mc["Markers"+i].SetText(Left, Name);
map_mc["Markers"+i]._x = X;
trace(map_mc["Markers"+i]._x);
map_mc["Markers"+i]._y = Y;
I have done traces and X, Y, Left and Name as well as the Xml data I'm reading in has values, yet when I attempt to call my functions (which are defined inside of the Markers movie clip) they don't actually get called (It's just a simple trace ("YOU CALLED ME") inside of them).

What am I doing wrong? I've taken several Flash courses and have made several games with litterally almost the EXACT same code so I don't know what's wrong. Oh and I do have Linkage setup properly. I am also using Flash 8 but am targetting Flash 6 (though it does the same when targetting Flash 7 or 8)

View Replies !    View Related
Calling Root Functions From A Nested Movieclip
So i'm having a tiny bit of trouble adjusting to as3. i cant seem to call functions written on the root timeline from any nested movie clips.

for example:

on frame1 of the root timeline i write a simple function:

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

i then create a movie clip and put it on the stage. on its first frame i call the previous function like so:

root.greet()

but instead of getting traced "hello" i get this compile error:

1061: Call to a possibly undefined method changeActiveFrame through a reference with static type flash.display: DisplayObject.

now, i somewhat understand whats going on, but i have no idea how to fix it. searching for this specific error yields a bunch of unrelated flex problems.

any help would be wonderful, thanks!

View Replies !    View Related
Calling A Function From Inside A Movieclip
I've already posted this in the xml-forum, 'cause I hoped to find people, who know this tutorial, but i guess it's better suited here.

I've been playing around with Flashscript.biz's xml database tutorial and I thought I understood the basics of it, but now I tried to have the Model-Name-Buttons in their own Movieclip and the Results on Frame 2 of the main timeline.
The script I attached to the Model-Name-Buttons in the mc is this:

code:

on (release) {
_root.gotoAndPlay(2);
_root.showModel("kim", "fmodels.xml");
}




which doesn't work(it goes to frame 2 but doesn't show the models/execute the function), i've already tried defining the function within in mc that contains the buttons, but that didn't help either... argh.

So what am i missing?
Help, please... thanks

View Replies !    View Related
Calling A Function Inside A Movieclip
I guess this is pretty basic, but it's giving me a headache by now, and I can't seem to find an answer anywhere.

What I need to do is basically to call a function, and/or change a variable inside a movieclip. This needs to be done from the main timeline (_root??).

For simplicity's sake lets say the movieclip code looks like this:


Code:
_content = "Lirum larum";

function test()
{
this.test_txt.text = _indhold;
}
The I would think I should be able to call that function from the mail timeline, with the following:

Code:
test_txt_instanceName.test();
Only I can't. What am I doing wrong here?

View Replies !    View Related
Calling A Function Outside A Movieclip From Inside One..
hopefully that's not too confusing:

I have a function I made in the root timeline.

Inside of a movie clip, I have a button which calls the function in the actions layer in the root timelime..

how do I make this work?


ActionScript Code:
//IN ROOT TIMELINE:
function modify(PARAM1, PARAM2):void
{
function does stuff here;
}

//Within a MovieClip
click_mc.addEventListever(MouseEvent.CLICK, onClick);

function onClick(event:MouseEvent):void
{
modify(Param1, Param2);  //Param1/2 just an example
}


modify isn't being found. using root.modify or parent.modify isn't working...

what am I missing here?

View Replies !    View Related
Calling Event Listeners Inside A Movieclip
I'm migrating over to actionscript and I'm having issues.
I have a movieclip and I'm just trying to see if the even is working

sandbox (mc)
- ball (mc)



Code:
The following code is in frame 1 of sandbox movieclip

ball.addEventListener(MouseEvent.MOUSE_OVER, rollOver);

function rollOver():void
{
trace('Testing');
}
I'd expect a trace on roll over but I get:

ArgumentError: Error #1063: Argument count mismatch on sandbox::ball_3/rollOver(). Expected 0, got 1.

View Replies !    View Related
[F8] Calling A Movieclip From Inside A Variable-called Moveiclip
On stage, I have five different movieclips, and I only have one of those appear at a time by using the variable "currentvar". But inside of each of those movieclips, I need to call a moveiclip "header", but obviously I can't call it from the main stage by targeting "currentvar.header", so how do I target it? I tried a bunch of things and no success. Any help would be so much appreciated. THANKS !

View Replies !    View Related
Simple Calling An Array From Inside A Movieclip Problem
hi

Here's what i'm trying to do..

On my _root .. maintimeline.. i have a movieclip with instance name... "one".. and inside it.. on the first frame.. I have this array

Code:
testarray = [99,554];
Now.. from the Main timeline.. i have this


Code:
trace(_root.one.testarray[0]);
By just reading it.. it should output "99".. right?
But i just keep getting "undefined"!

Anyone know how to solve this?

Thanks!

*I've added the fla of this problem here - file size = 32kb
http://four4swords.110mb.com/OUT/Untitled-4.fla

View Replies !    View Related
Calling Dynamic Text Field On Main Timeline From Inside Movieclip
Hi, this is probably really easy, but I can't seem to figure out how to do it.

I made a little login screen in a separate movieclip on my homepage. When the login is correct, frame 8 of the main timeline is called, and I would like it to say "welcome (name here)." Unfortunately, I don't know how to call the dynamic text field on Frame 8 (instance name "greetings", variable saved as "welcome") from inside the movieclip on Frame 2.

Here's the code from the login button in the movieclip:

on (release, keyPress "<Enter>") {
if (user eq "name" and password eq "password") {
_root.gotoAndStop(8);
//trying to access dynamic text field on frame 8 of main timeline, but nothing works!
_root.greetings.welcome = "Welcome, "+ user;
_root.welcome = "Welcome, " + user;
welcome = "Welcome, " + user;

I just don't know! By the way, this is in Flash MX

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
[F8] Functions Inside Functions? Urgent
Hi, is this in any way valid?


Code:
this.onRelease = function(){
_root.mainbutton(){
freeze == false;
}
i have a set of buttons id like to play their animations when i press a button. Can this be done?

Any help or pointers would be greatly appreciated, thanks!

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
Loading An External Swf Inside A Movieclip That Is Inside Of A Movieclip
I was wondering if anyone could help me!!!! I used the tutorial for loading external swf's into a movieclip off of this site. But what I am trying to do is load another external swf inside of that external movieclip. Not sure if that makes sense. I kind of have it working where it loads the first external clip. But when I press a button to load a different one, it plays the transition then loads nothing. It's just blank.

This is the AS 2.0 that I am using for the external swf button that is inside another:

on (release) {
if (this._parent.currMovie == undefined) {
this._parent.currMovie = "StrategicPlanning2";
container2.loadMovie("StrategicPlanning2.swf");
} else if (this._parent.currMovie != "StrategicPlanning2") {
if (container2._currentframe>=container2.midframe) {
this._parent.currMovie = "StrategicPlanning2";
container2.play();
}


}
}

And this is the AS that I am placing on the last frame in the actions layer

this._parent.container2.loadMovie(this._parent.cur rMovie+".swf");

Please help!!! I am only a Graphic Designer!!

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
Copyright © 2005-08 www.BigResource.com, All rights reserved