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








How Can You Call A Function In Another (3rd Party) Swf File?


Hiya
Does anyone know how to call a function in a 3rd party swf file?
For example, I want to call the function

'_root.mc.splitPane_mc.mcContent_1.mcSplitPane.mcC ontent_0.mcSplitPane.mcContent_1.content_mc.sendBu tton_mc.performClickAction();'

Is it possible to do so using javascript, or another flash file, or something like visual basic? Maybe using script injection?

Im pretty new at flash but here is my story. Basically I have a flash object embedded in a visual basic project, and that flash object has a 3rd party swf loaded in it. Using visual basic, I can modify (get or set) variables provided I know their name, using something like FlashObject.SetVariable "_root.mc.splitPane_mc.mcContent_1.mcSplitPane.mcC ontent_0.mcSplitPane.mcContent_1.content_mc.inputA rea_mc.richTextBox_mc.textField_tf", "hello world".

However I have no idea how to call functions... there is a CallFunction function available for the flash object, but FlashObject.CallFunction "_root.mc.splitPane_mc.mcContent_1.mcSplitPane.mcC ontent_0.mcSplitPane.mcContent_1.content_mc.sendBu tton_mc.performClickAction();" does not work.

I know it IS possible to do it somehow. There is a program called 'flash game master' (http://www.cordyblog.cn/?action=show&id=148) that lets you 'run a script' into a loaded swf file. for example if i 'run script' "_root.mc.splitPane_mc.mcContent_1.mcSplitPane.mcC ontent_0.mcSplitPane.mcContent_1.content_mc.sendBu tton_mc.performClickAction();" it works perfectly. but how is flash game master accomplishing this?




ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 01-20-2009, 09:44 AM


View Complete Forum Thread with Replies

Sponsored Links:

[AS3]Call Function Outside Of A Class File
hello there,

I like to call a function that is outside of the class file.

for example

main.fla

Code:
function callmepls(){
trace("yes");
}
Calling.as

Code:
package{
public class Calling{
callmepls();
public function Calling(){
}
}
}

View Replies !    View Related
Call A Flash Function From XML File?
My client says make this, and use XML so it's dynamic and easy to update:
A text box with scroller holding news headlines, and a more link that will open an MC with the entire news article. Like:
11/28/05 - X-Raided Celebrates 3 Years in Prison
Folsom Correctional facility officers report that imprisoned rap
artist X-Raided threw a party in his cell (with his cellmate) to
celebrate his third anniversary in prison. Officials state.. [more]

11/14/05 - AP9 & FedX Release Video
Ipsum orny fengshui garble garb garb gimmicky garble garb
Ipsum orny fengshui garble garb garb gimmicky garble garb
Ipsum orny fengshui garble garb garb gimmicky... [more]

I say, sure boss, I can do it, I'm a flash guru! I think to myself, surely someone on Kirupa knows how to make that "more" link in the XML tell flash to run a specific function.
I already have a function that makes whatever mc I want visible and I can write some code to fill in dynamic text boxes with the proper nodeData. But what would that "href=" have to be in the XML in order to call that function inside of flash. Is there a way you can turn XML data into executable commands?

View Replies !    View Related
How Do I Call A Function From A .js File From Within Flash?
I have a javascript file and I'm trying to call a function within the file from within a flash file, but it's not working. Any ideas? Here is the code from the flash file:


Code:
return_mc.onRelease = function():Void{
getURL("javascript:parent.populateFrame('lead/lead.html')");
};
The .fla is published as a html file and I have the .js file linked with the html file. Any help would be appreciated.

JPearson311

View Replies !    View Related
Call Actionscript Function From Xml File
greetings all

my xml file is as such:


Code:
<menu txt="THIS ITEM FIRES A FUNCTION IN FLASH" txtcolor="0xFFFFFF" menuaction="myFUNCTION" />
myFUNCTION is a function inside of flash, how can i possibly trigger this?

i did some searches but i can't find the sollution:

i read upon asfunction:myFUNCTION, but it simply doesn't work

this is my relevant flash code


Code:
myFUNCTION = function()
{
trace ("am i called?");
}
BUTTON.ID = i
BUTTON.onRelease = function()
{
trace("myFUNCTION : " + XMLARRAY[this.ID].attributes.menuaction);
XMLARRAY[this.ID].attributes.menuaction
};
thanks in advance

View Replies !    View Related
Call To Function In Separate .js File Using Actionscript 2
I am having trouble calling a function in a separate .js file using actionscript 2.

Is this actually possible?

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

I know this works:


Code:
on(press)
{
getURL("javascript:disappear();"); //
}
Although I need to call a function in a separate JS file. Any suggestions on the code I would use or point me to anywhere that might help.

I would pass it directly to the PHP file although the AJAX has to change the website after login i.e. update the navigation menu once logged in.

Thanks anyone
John

View Replies !    View Related
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");
}

View Replies !    View Related
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

View Replies !    View Related
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.

View Replies !    View Related
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

View Replies !    View Related
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?

View Replies !    View Related
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;
}

View Replies !    View Related
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.

View Replies !    View Related
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");
}
}

View Replies !    View Related
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

View Replies !    View Related
How Can I Call I Call An Executable File?
which is the command in flash to execute an .exe file?

View Replies !    View Related
[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?

View Replies !    View Related
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

View Replies !    View Related
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!

View Replies !    View Related
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

View Replies !    View Related
[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.

View Replies !    View Related
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...
}

View Replies !    View Related
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.

View Replies !    View Related
[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;
}
}

View Replies !    View Related
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

View Replies !    View Related
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

View Replies !    View Related
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

View Replies !    View Related
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!

View Replies !    View Related
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?

View Replies !    View Related
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!

View Replies !    View Related
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

View Replies !    View Related
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

View Replies !    View Related
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

View Replies !    View Related
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

View Replies !    View Related
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

View Replies !    View Related
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..

View Replies !    View Related
[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

View Replies !    View Related
[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

View Replies !    View Related
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>";
};

View Replies !    View Related
[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?

View Replies !    View Related
[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?

View Replies !    View Related
[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);
}

View Replies !    View Related
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!

View Replies !    View Related
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!

View Replies !    View Related
?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");
}
}
}

View Replies !    View Related
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>

View Replies !    View Related
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?

View Replies !    View Related
Call A Function
Hello:

I am new to flash as well as actionscript. I have a question about function/method.

I have 2 movieclip, A and B. I would like to call a function from A to B. Can I do that? I tried several time. My code complaint or function was not being called. I don't know how I call a function in actionscript. I am very confused with this. Can anyone help? Please give me some direction

Thanks

View Replies !    View Related
Help: Call Function Per MC
Hello,

Essentially, I have a function that accepts a movie clip, and increases the mc's alpha until it is opaque:


Code:
function incAlpha(mc){
clearInterval(incAlphaID);
mc._alpha++;
if (mc._alpha <= 100){
incAlphaID = setInterval(incAlpha, 10, mc);
}
}
Later, I have a for loop that attaches an MC then changes the text field within it. What I want is for each attached MC to independantly call the incAlpha and thus, fade in. However, when I run it, only the last MC in the for-loop ends up getting faded-in. The for-loop looks something like this:


Code:
for (k = 0; k < this.pI.length; k++){
var thisClip = this.attachMovie("p_mb", ("pl" + k), this.getNextHighestDepth());
thisClip.processText.text = this.pI[k]["name"];
thisClip.processText.textColor = "0x829CD4";
thisClip._alpha = 0;
incAlpha(thisClip);
}
Now, I realize I could use a class and have a method that could be called by creating a new object for each MC in the for loop, but I figured I would see if there is some way to do this from the outside.

Thanks,
Rege

View Replies !    View Related
How To Call A Function Once
I'm trying to learn how to use Actionscript. I wrote this function so that certain buttons are disabled on frame 14 and enabled when the timeline is not on frame 14. When I test it, the function doesn't work unless I call it on fr 1 AND fr 14. Shouldn't I be able to call it once and have it work no matter what frame the timeline is on? Can someone pls tell me what is wrong?









Attach Code

function breakButtons() {

if (_currentframe == 14) {
// these are movie clips used as buttons
proBar._alpha = 30;
loBar._alpha = 30;
proBar.enabled = false;
loBar.enabled = false;
}

else {
proBar._alpha = 100;
loBar._alpha = 100;
proBar.enabled = true;
loBar.enabled = true;
}
}

breakButtons();

























Edited: 05/09/2007 at 07:26:26 AM by dzash2000

View Replies !    View Related
Function Call
Hi all,

For some reason I am unable to get my function (updateFields) to be called. Any suggestions as to where I should look? Here is my code:







Attach Code

private function rectCalc() {
//calculates the coords of the drag point (set to 1 above and below min/max
// so the border fits inside the window)
var d = this._parent;

if(d.mcStylus._x > d.mapWidth) {
d.dragX = d.mapWidth - 2;
} else {
if(d.mcStylus._x < 0) {
d.dragX = 1;
} else {
d.dragX = d.mcStylus._x;
}
}
if(d.mcStylus._y > d.mapHeight) {
d.dragY = d.mapHeight - 2;
} else {
if(d.mcStylus._y < 0) {
d.dragY = 1;
} else {
d.dragY = d.mcStylus._y;
}
}

d.mapPad.clear();
d.mapPad.lineStyle (1, 0xFF0000);
d.mapPad.beginFill (0x990000, 40);
d.drawRect(d.map_x, d.map_y, d.dragX, d.dragY);

updateAfterEvent ();

if(d.mapMode == 2) {

updateFields(d.map_x, d.map_y, d.dragX, d.dragY);

}
d.mapPad.endFill ();


}

private function updateFields(x,y,xx,yy) {
getURL("javascript:debug('here')");
}

View Replies !    View Related
? How To 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









Attach 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");
}
}
}
//timeline forward and backward buttons
controller_mc.goForward.onRelease = function() {
if (arrayIndex<4) {
butRelease(this._parent["but"+(arrayIndex+2)]);
}
};
controller_mc.goBack.onRelease = function() {
if (arrayIndex>0) {
butRelease(this._parent["but"+(arrayIndex)]);
}
};

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