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.
KirupaForum > Flash > ActionScript 3.0
Posted on: 07-01-2008, 01:56 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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 From Inside An MC
Is it possible to call a function from inside an mc? I have:
MovieClip.prototype.scrollme = function(xPos){
this._x -= (this._x-xPos)/5;
};
//initialise a variable
var xPos:Number;
xPos = menu._x;
_global.out;
out = false;
//menuMC actions
menu.EnterFrame=function(){
if (out) {
//call the prototype and provide a target xpos
this.scrollme(-723);
} else {
this.scrollme(-315);
}
}
so, I have buttons two mcs INSIDE of this one that should scroll the whole menu to the left when called- I can't seem to get it to work. I've tried calling the function (scrollme(-723)), and setting the variable out=true. It doesn't budge. Is there any reason why this shouldn't work?
Thanks so much, time is running out!
miakazi
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
Calling A Variable Inside A Function
Is it possible for me to call a variable from inside another function, and if so how? For instance:
Code:
this.onEnterFrame = function() {
variableX = 1;
VariableY = 2;
variableZ = 3;
};
if (variableZ == 3){
variableX += 4;
}
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?
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?
Calling A Function Inside A Combobox
I have this script for me Combo Box
Code:
function nextImage2() {
//picture.loadMovie("testimages/image1_big.jpg", 1);
trace("FUNCTION2");
}
omboBox.addItem({data:"http://www.beispiel.de/tiere", label:"Tiere"});
comboBox.addItem({data:"http://www.beispiel.de/DerIngo", label:"DerIngo"});
comboBox.addItem({data:"http://www.flashforum.de", label:"FlashForum"});
var listener:Object = new Object();
listener.change = function(eventObject:Object) {
var beschriftung = eventObject.target.selectedItem.label;
var wert = eventObject.target.selectedItem.data;
trace(beschriftung+":"+wert);
getURL(wert, "_blank");
};
comboBox.addEventListener("change", listener);
How can call a Function (eg nextImage2() ) instead of an URL???
any help is much appreciated
cheers
ChromeD
Calling A Function Inside A Flash Movie Via JS
I need to call a function inside a Flash Movie via JS (to update a textfield and sum Vars) can someone point me in the right direction???
I tried to figure out the external interface api, but i dont understand how it really works ...
For example:
JS calls function "Fieldupdate" and in the Flash Movie the Fields and Vars Updates
thanx in advance
ChromeD
Calling A Function Declared Inside An Externally Loaded Swf
Hi,
I wish to call a function declared inside an externally loaded swf from the parent swf.
main.swf >loads in gallery.swf
I have looked into this and have read a little about casting, yet am still unsure as to how this works and the 'syntax' if you will of doin this.
Obviously in AS2 this was acheived by targeting the ._parent or ._child swf, but in AS3 I am unsure how to do this.
Any help appreciated
Calling Function Located On A Frame Number Inside A MC
Hi everyone,
I have a movie clip on the stage which contains 4 frames and i wanna call a function from for example frame number 4... Obviously i wanna call this function from the main timeline containing all the MC. How can i do that, i have been looking around but cannot find much...
Can anyone help me achieve this please
Thanks in advance,
Jerome
Function And Target Problem (calling From Inside A Movie Clip's Timeline)
(Using Flash MX 2004 Pro, AS2)
I have a whole bunch of custom setInterval functions defined in an included AS file that have either a 'gotoAndPlay' or 'function()' action within. All of my setInterval functions that are being called globally from the main timeline of the movie work beautifully, however I have two calls that are calling their function from within a movie clip of the same timeline...they are not working, they're not even calling back to the function. Here's my function code in the AS file:
Code:
function cardRevealPause(){
gameLogic.gotoAndPlay("shuffle");
clearInterval(welcomeTimeOutIntervalID);
clearInterval(gameTimeOutIntervalID);
clearInterval(cardRevealPauseIntervalID);
}
Here's my global call code from within the movie clip 'gameLogic' timeline:
Code:
_global.cardRevealPauseIntervalID = (cardRevealPause, _global.cardRevealPauseInterval);
ANy thoughts as to why this won't work for me??? Thanks in advance!
Function And Target Problem (calling From Inside A Movie Clip's Timeline)
(Using Flash MX 2004 Pro, AS2)
I have a whole bunch of custom setInterval functions defined in an included AS file that have either a 'gotoAndPlay' or 'function()' action within. All of my setInterval functions that are being called globally from the main timeline of the movie work beautifully, however I have two calls that are calling their function from within a movie clip of the same timeline...they are not working, they're not even calling back to the function. Here's my function code in the AS file:
Code:
function cardRevealPause(){
gameLogic.gotoAndPlay("shuffle");
clearInterval(welcomeTimeOutIntervalID);
clearInterval(gameTimeOutIntervalID);
clearInterval(cardRevealPauseIntervalID);
}
Here's my global call code from within the movie clip 'gameLogic' timeline:
Code:
_global.cardRevealPauseIntervalID = (cardRevealPause, _global.cardRevealPauseInterval);
ANy thoughts as to why this won't work for me??? Thanks in advance!
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.
Parsing Data To A Function And Altering It Inside The Function
Hi all
I need to parse variables to a function and let the values of the variables be changed inside the function. But in a way that the data are actually changed, not only a reference to the data! It is not possible using primitive data but should be possible with composite data.
But I cant get it right - any suggestions?
code:
test = new Object();
test = false;
aFunction = function(control){
control = true;
trace(test);
other code here...
}
How can I make the trace(test) output true when I call the aFunction(test) with test as parameter?
Hope anyone have the answer!
Ciao ciao
T
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");
}
}
Functions Inside A Function Returning To Previous Function
This is a kind of long post so for your benifit here's some story Tags, if you don't want to read my sobbing story, then just look for the /story tag
<story>
Hello there, I'm trying to build a semi-combat system for a small RPG that I am making. I'm to the part where I am trying to make a combat system based upon AD&D 2nd Edition Rules, that's Dungeons and Dragons. It involves rolling for initiative, rolling Thaco(Deciding whether or not you hit), and then deciding on how much damage is inflicted.
So as I was trying to automate the task of choosing who goes first(Initiative), the long process of writing the code came about and I realized that I will have to write the same code twice. Once for the monster going first and again for the character going first.
</story>
What I want to do is to write a function that goes into another function if the parameters are met and then that function will test some more variables and if the variables don't agree, the function will resume from whence it broke off into the new function.
ActionScript Code:
function attackAction(){
//Roll d10 for each party
cr=Math.round(Math.random()*9)+1;
this.cr_txt.text=cr;
er=Math.round(Math.random()*9)+1;
this.er_txt.text=er;
//If the enemies roll is greater, then have him attack first
if(er>=cr){
That's where a new function would come in. It would be something like
ActionScript Code:
function monsterTurn(){
//Test Thaco
if(Math.round(Math.random()*19)+1>=_root.monsterThaco){
//Roll for damage amount
damage=Math.round(Math.random()*_root.monsterAttack);
//Display message of Damage and takes damage from you
this.actions_txt.text="The Monster hits you for "+damage;
this.Health-=damage
//sees if the character is dead
if(this.Health<=0){
this.actions_txt.text="Oh no! You died";
}
else{
//Go back to the previous function and resume from there
Then of course there would be a playerTurn() that would do everything similar except test the player's variables.
<story>
If you're going to say that I should just have it list the commands, I tried that. It was far too long and complex to keep track of even with notes.
</story>
So can anyone help me out with Going through a function, hitting an if statement, going to a function based upon the statement, then testing a statement inside of the second function, then returning to the first function if the statement is false and doing the other part of the if statement in the first function.
It's difficult for me to explain this, but I hope you go the general jist. Thanks in advance.
[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!
Using Variables Created Inside A Function Outside The Function?
I am trying to use a variable I am creating inside of a function, outside of that function, but I seem to have a scope issue when I do this.
My code is:
Code:
function drawlines(centerx, centery, radius, radians){
var radiansSoFar:Number = 0
var piechart:MovieClip = new MovieClip();
piechart.name = "piechart"
piechart.x = stage.stageWidth/2;
piechart.y = stage.stageWidth/2;
stage.addChild(piechart);
}
but I want to make a function outside of this which removes the variable piechart, but because im so unfamiliar with how flash names instances now I have no idea how to do this.
It works if I define var piechart:MovieClip = new MovieClip() outside of the function, but this isnt very useful as I eventually need to create multiple movieclips dynamically and name them dynamically.
So basically how would make it so I would be able to use the code
Code:
function removeChart(chartname){
stage.removeChild(chartname)
}
to dynamically remove a movieclip I created in a function?
Pausemovie Function Inside Fadein Function
Last edited by pusherman : 2007-06-21 at 10:26.
I am trying to merge two functions together. The result is however, pausemovie function does not work (perhaps overriden by onEnterFrame) and mypic's alpha reaches 100 by increments of 7.
ActionScript Code:
//MC:mypic1 appears.
createEmptyMovieClip("fadein", 222);
fadein.onEnterFrame = function() {
pauseMovie(4);
if (mypic1._alpha<100) {
mypic1._alpha += 7;
} else {
removeMovieClip("fadein");
}
};
My pausemovie function is on my 1st frame and is as follows:
ActionScript Code:
function pauseMovie(seconds) {
stop();
var startTime = getTimer();
var endTime = seconds * 1000;
this.onEnterFrame = function(){
currentTime = getTimer();
if(currentTime - startTime > endTime){
//this is where your action goes
play();
delete this.onEnterFrame
};
};
};
I would appreciate any help.
Thank you.
Placing A Function Inside A Function
Hey everyone,
So I'm not very effecient with actionscript and i'm trying to simplify some code. the bottom line is that that i want to call a function within a function. i have no idea what code to use to do that. I did use it in one part, although i'm not entirely sure how that works(yah code snipits off the net).
function homeOn() {
// send second children back
movieclipTweenOut(strategyBtn_mc, 831, 85, 100, 100, 0);
movieclipTweenOut(strategyBtnLine_mc, 807, 75, 100, 0, 0);
movieclipTweenOut(historyBtn_mc, 831, 85, h, h, 0);
movieclipTweenOut(historyBtnLine_mc, 770, 111, h, h, 0);
// send first children back
var tween_handler:Object = new Tween(strategyBtnLine_mc, "_alpha", Elastic.easeOut, 100, 0, 3);
tween_handler.onMotionFinished = mainButtonsIn;
};
so where the //send children back code is, i'd like to make a function so that i don't have to keep calling that every time, like this:
function subAboutUsIn(){
movieclipTweenOut(historyBtn_mc, 831, 85, h, h, 0);
movieclipTweenOut(strategyBtn_mc, 831, 85, 100, 100, 0);
movieclipTweenOut(strategyBtnLine_mc, 807, 75, 100, 0, 100);
movieclipTweenOut(historyBtnLine_mc, 770, 111, h, h, 0);
};
if anyone has any ideas, that would be great. it's probably very simple, i just can't figure it out. i uploaded the file too incase u need to check it out.
thanks
Call A Function From Inside Another Function?
Hey Guys,
Having a bit of a problem here
Just say this was the case on the main timeline
ActionScript Code:
function topFunction(){
trace("you just called the topFunction")
}
function testFunction(){
function nestedFunction(){
topFunction();
}
}
How the hell do i run the topFunction from inside nestedFunction();. In AS2 if i wanted to reference it i would type _root.topFunction(); but now I don't know how to get to it.
I just need to know how to reference variables and functions from anywhere in my actionscript if i'm in another scope or in another MC.
Thanks guys
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.
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 Function For Mc From Within Other Function?
Hello, been taring my hair out over this little problem. I'm trying to call below function for a movie clip from within an onRelease function on another movie clip.
The full extent of my problem is that i want movie clips to fade in on the stage when i press a movieClip button. The code below works fine if i call it from an onClipEvent handler on the actuall movie clip, but I'd like to control when It happens from somewhere else.
Code:
function fadein(clip, tAlpha) {
clip._alpha += (tAlpha-clip._alpha)/15;
if(Math.abs(clip._alpha-tAlpha) < 1) clip._alpha = Math.ceil(tAlpha);
}
i've tried attachMovie from teh library, but still if just after that try to call this function the movie clip only snaps in on the stage and won't use the function.
Code:
this.onRelease = function() {
homePage._visible = false;
_root.attachMovie("testePage", "testemonialPage", 3);
testemonialPage.onEnterFrame = function(){
fadein(this, 100)
}
}
but no go with this.... i'm sure it's a simple task for someone more apt at AS. big thanks for any help! cheers, david
Calling A Function From A Function
How can I get a function to call another function? I simply cannot get it to work:
ActionScript Code:
function displayMenu() {clearMenu}
This is a cut down version of my code for clarification purposes - it doesn't work either.
Does it have to be in an "on" handler (onClipEvent or onEnterFrame for example)? 'cause I just want it to run the other function automatically without the user having to do anything or the movie having to go to any particular frame. blah
Calling A Function From Within Function
Is there any way to call a function from within a function?
***************************************************
Here is the Function I am calling from:
SET.onRelease = function() {
in1_txt.text = "C";
in2_txt.text = "F";
in3_txt.text = "G";
OUT1.text = "C";
OUT2.text = "F";
OUT3.text = "G";
varKeyShift = 0;
this._parent.varShow = "SET.onRelease";
Output_Key(); // Here is the Function call
};
****************************************
Here is the function I am calling:
function Output_Key() {
this._parent.var1 = 1;
}
*******************************************
I have an Input Text with Variable Name "var1"
but var1 shows no value when clip is run
Function Inside A Function
Hi everyone,
Is it possible to activate a different function inside a function by using action script?
Maybe this sounds unclear?
What I aim for is something like....
This.onChanged = function() {// start function on changed data field
bla bla bla, and some text.// (the function)
Do function X;// redo function X
}// end function
Do I in order to achieve this give the function a name between the brackets?
function()
If anyone has some time left after reading this to visit my other problems that would be great.
How to remove NaN from textfield
adding formula inside datagrid
All help is apreaciated
Kind regards,
Sebastiaan
Function Inside A Function
function inside a function
why it doesnt work? Do anyone know how can I use the "press" instruction for button inside a function?
this is something I am working
function makeMove(){
// Have a shoot
if(myMove=="T"){
target1.btnHit.onPress = function (){
trace("hit")
}
if (_root.count <0){
trace("over")
}
} else{
yourMove();
}
}
Function Inside A Function
getOccurances function is not called.
Code:
keylistener = new Object();
keylistener.onKeyDown = function()
{
if (Key.getCode() == 65)
{
//Some code
var letterAs:Array = getOccurances(string, "A");// it dosn't call getOccurances
function getOccurances(string:String, letter:String):Array {
var index:Number = 0;
var letterIndex:Number = string.indexOf(letter, ndex);
var indexes:Array = new Array();
while (letterIndex != -1) {
indexes.push(letterIndex);
index = letterIndex+1;
letterIndex = string.indexOf(letter, index);
}
return indexes;
}
Key.addListener(keylistener);
Function Inside A Function
I basically need to run a function inside a function in actionscript, and am having trouble. Basically, nothing in bold is being applied. Any ideas? Thanks!
Code:
var myVariable:LoadVars = new LoadVars();
myVariable.load("http://www.myURL.com/ad/store/baby/demo.asp");
myVariable.onLoad = function(success:Boolean) {
if (success) {
var Tester2:MovieClip = _root.MainMovie.Img2.createEmptyMovieClip("imgHolder", 1);
var mcl2:MovieClipLoader = new MovieClipLoader();
var mclListener2:Object = new Object();
mclListener2.onLoadInit = applySmoothing2;
mcl2.addListener(mclListener2);
mcl2.loadClip(this.Image2, Tester2);
function applySmoothing2(target2:MovieClip) {
var mcParent2:MovieClip = target2._parent;
var mcName2:String = target2._name;
var myBitmap2:BitmapData = new BitmapData(target2._width, target2._height);
myBitmap2.draw(target2);
target2.removeMovieClip();
target2 = mcParent2.createEmptyMovieClip(mcName2, mcParent2.getNextHighestDepth());
target2.attachBitmap(myBitmap2, 1, "auto", true);
}
}
}
SetInterval Inside A Loop Inside A Function - Am I Crazy?
I've got a menu loading from XML data - however I'd like the mc's to appear sequentially, maybe 1/10th second apart. I know setInterval should do this, but I'm still new to flash and despite trawling Google for 24 hrs solid, nothing seems to show me the right way.
Here's the script:
Code:
function CreatePortMenu(port_xml)
{
var portClients = port_xml.firstChild.childNodes;
var xPos = 0;
var yPos = 0;
var xSpacing:Number = 90;
var ySpacing:Number = 35;
var i = 0;
for ( i = 0; i < portClients.length; i++ )
{
switch (i) //splits the menu items into columns of 4 (max 12 items)
{
case 0:
case 1:
case 2:
case 3:
yPos = ySpacing * i;
break;
case 4:
case 5:
case 6:
case 7:
xPos = xSpacing * 2;
yPos = ySpacing * (i - 4);
break;
case 8:
case 9:
case 10:
case 11:
xPos = xSpacing * 3;
yPos = ySpacing * (i - 8);
}
var currentClient = portClients[i];
var portHold = portHolder_mc.attachMovie( "jobOption", "pb"+i, i, {_x:xPos, _y:yPos});
portHold.jobTitle.jobText.text = currentClient.attributes.title;
}
}
So I *think* I should be inserting two lines, one creating a setInterval, and one clearing it, but where? Some guides say inside the function, some say outside, some say only the clearInterval should be inside, some have the function inside the loop... I also *think* I've tried every possible combination, but no soap. Please help!?
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
|