Problem Passing Variable To A Function
Good day all:
I am having a problem getting a variable to pass to a function and then running a tween.
On the stage I have a movie clip called imageGroup_mc. Inside that clip I have another movie clip named t01_mc. I have code within the imageGroup_mc clip that adjusts the alpha of the t01_mc clip.
If I write the code as follows all works fine:
this.t01_mc.onRollOver = function () { new Tween(this,"_alpha",Regular.easeOut,70,100,5,false ); }
Problem is there are 12 clips like t01 that will all use the same code so I wrote a function, but the following code is not working. I am not sure if the eval is wrong or something else:
function imageRollOver (image) { new Tween(eval(image),"_alpha",Regular.easeOut,70,100, 5,false); }
this.t01_mc.onRollOver = function () { imageRollOver(“t01_mc”); }
I have tried different variations of putting t01_mc in quotes, writing it as the full imageGroup_mc.t01_mc and nothing is working.
Any assistance would be greatly appreciated.
Thanks in advance. Mark
ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 07-06-2007, 01:02 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Passing A Variable Into A Function?
I simplified my original code as much as possible to show what I need.
From the code below, I need to trace (x) so that it doesn't show the top value of 5.
Actually, I need to be able to recognise which of the attachedMovieClip s have been pressed so's to do a getURL based on it.
Can anyone help? Thanks.
myButt.onRollOver = function() {
var a = 0;
for (var x = 0; x<5; x++) {
var myClip = _root.attachMovie("Clip", "Clip"+a, a++);
myClip._x = myClip._width*x;
myClip.onPress = function() {
trace(x);
};
}
}
Passing A Variable From Within A Function
1. I have successfully parsed either an XML files using the XML object
or variable=value pair using LoadVars in ACTIONSCRIPT 2 (I am using Flash8)
2. However the scope of the variables' value is limited to inside the scope of the success function
(pseudo code)
if (success) {
variable1=value;
}
Now outside this function block I want to be able to access this value whenever I reference the variable1 within the rest of the actionscript.
3.Within the function block, I have tried using:
a) return variable1;
b) _global.variable1=value;
c) _root.variable1=value;
d) this.variable1=value;
4.How do I use a screen name here in the forum? I feel dorky having "screennameisnotavailble" displayed?
Thanks.
Passing Variable In A Function
I think this is a simple problem. I want to pass a Variable to a function when a button is clicked. I am used to just passing a Variable like so: FuncTest(CustomVarible); But that doesn't seem to work. Here is an example of what I trying to do; I know it won't run in actionscript, but at least it will give you an idea.
Attach Code
btnUserButton.addEventListener(MouseEvent.CLICK, ButtonClicked(varFrame));
function ButtonClicked(e:Event):void {
gotoAndPlay(varFrame);
}
Passing Variable To A Function
Hi all,
I have this script that reads pictures and links of the pictures from the an xml file, display the picture and then put the link for the image, but I can't seem to pass the link to the onRelease function anyone can help me on this, below is the code:
Attach Code
Photos = new XML();
Photos.ignoreWhite = true;
Photos.onLoad = function(success) {
numimages = this.firstChild.childNodes.length;
spacing = 120;
var _link:Array = new Array();
for (i=0; i<numimages; i++) {
this.picHolder = this.firstChild.childNodes[i];
this.photosHolder = photos.createEmptyMovieClip("photos"+i, i);
this.photosHolder._x = i*spacing;
this.picHolder._URL = this.picHolder.attributes.link;
trace(this.picHolder._URL); //Tracing image link
var _link[i] = this.picHolder._URL;
trace(_link[i]);//Tracing the link inside the array
this.photosHolder.onRelease=function(){
trace(_link[i]);//Tracing link inside function (still not being passed)
getURL(_link[i], "_blank");
};
this.photosHolder = this.photosHolder.createEmptyMovieClip("photos_image", 0);
this.photosHolder.loadMovie(this.picHolder.attributes.pic);
}
};
Photos.load("xml/hosp.xml");
Edited: 07/28/2008 at 07:44:01 AM by ehajj
Passing A Variable Into A Function
why is my variable not being passed into my function?
Code:
dealerLocate.urlButton.linkButton.onRelease=function(webAddress){
web=webAddress
trace("this is web "+web);
fullUrl="http://"+web;
trace("full url="+fullUrl);
getURL(fullUrl, "_blank");
}
the webAddress variable is from the exact same timeline making it one level up from this function. it traces out correctly too so I know the variable is there... just not getting passed!
now i've got a bunch of goofy trace stuff in there but you get the idea... help!
Passing Variable To A Function
Hi all,
I have this script that reads pictures and links of the pictures from the an xml file, display the picture and then put the link for the image, but I can't seem to pass the link to the onRelease function anyone can help me on this, below is the code:
Code:
Photos = new XML();
Photos.ignoreWhite = true;
Photos.onLoad = function(success) {
numimages = this.firstChild.childNodes.length;
spacing = 120;
var _link:Array = new Array();
for (i=0; i<numimages; i++) {
this.picHolder = this.firstChild.childNodes[i];
this.photosHolder = photos.createEmptyMovieClip("photos"+i, i);
this.photosHolder._x = i*spacing;
this.picHolder._URL = this.picHolder.attributes.link;
trace(this.picHolder._URL); //Tracing image link
var _link[i] = this.picHolder._URL;
trace(_link[i]);//Tracing the link inside the array
this.photosHolder.onRelease=function(){
trace(_link[i]);//Tracing link inside function (still not being passed)
getURL(_link[i], "_blank");
};
this.photosHolder = this.photosHolder.createEmptyMovieClip("photos_image", 0);
this.photosHolder.loadMovie(this.picHolder.attributes.pic);
}
};
Photos.load("xml/hosp.xml");
Passing A Variable To A Function
hi guys
I haven't posted here for a while but i've come across a problem that you might be able to answer
I've boiled the whole thing down to this:
How do i pass a variable to an onLoad() function?
here is my script: .....
Passing A Variable To A Function
hi guys
i haven't posted here for a while but i've come across a problem that you might be able to answer
i've boiled the whole thing down to this:
how do i pass a variable to an onLoad() function?
here is my script:
ActionScript Code:
function loadDescriptions() {
for (var i=0; i<_root.menuItems_array.length;i++) {
var thisTextLoadVars = new LoadVars();
thisTextLoadVars.onLoad = function(success) {
trace (_root.menuItems_array[i]);
};
var thisDoc = _root.menuItems_array[i];
trace ("thisDoc: "+thisDoc);
var textDoc = _root.menu[thisDoc].description;
thisTextLoadVars.load(textDoc);
}
}
the trace in the the onLoad function returns "undefined". Can anyone tell me how to get around this please?
thanks
alz
Passing Variable Inside Function
Can you tell me how to pass variable into _root["menu"+a].onRollOver = function (). See following piece of code and find "<--HERE"
When I roll over mc function is called but nothing returns
Code:
function menuObject() {
if (a<_root.menuGlowne.length) {
_root.attachMovie("menu", "menu"+a, 1100+a);
_root["menu"+a]._y = 0;
if(a==0){
_root["menu"+a]._x = 0;
} else {
_root["menu"+a]._x = _root["menu"+(a-1)]._x + _root["menu"+(a-1)]._width+10
}
_root["menu"+a].onRollOver = function () {
_root.subm(a) // <--HERE
};
a++;
} else {
delete this.onEnterFrame;
}
}
function subm(a){
trace ("called")
trace ("this is" + a)
}
Passing Variable Inside A Function
Hello all,
here is the source of my question:
Code:
id = "1";
function somefunct(){
trace(id);
}
and the "trace" prints undefined ... does anybody know how i can pass the id variable inside the function ?? Thanks in advance
Passing Variable To OnRollOver Function
I have this cycle.
for(var p=0; p<k; p++){
eval("Butt"+areaList[p]).onRollOver = function() {
clipZoom(this, 150, 0.8, null, null);
this.swapDepths(1000);
eval(enterList[p])._visible=true;
};
eval("Butt"+areaList[p]).onRollOut = function() {
clipZoom(this, 95, 0.8, null, null);
this.swapDepths(1);
eval(enterList[p])._visible=true;
};
};
The onRollOver function zoom the movieclip and display another movieclip.
I use two arrays that contain the names of the movieclips.
The problem is that p inside the onRollOut is always = k.
I don't understand why.
Is there a workaround?
Thank you,
Marco
Passing A Variable To OnLoad Function
i haven't posted here before so wotcha
i've come across a problem that you might be able to answer
i've boiled the whole thing down to this:
how do i pass a variable to an onLoad() function?
here is my script:
PHP Code:
function loadDescriptions() {
for (var i=0; i<_root.menuItems_array.length;i++) {
var thisTextLoadVars = new LoadVars();
thisTextLoadVars.onLoad = function(success) {
trace (_root.menuItems_array[i]);
};
var thisDoc = _root.menuItems_array[i];
trace ("thisDoc: "+thisDoc);
var textDoc = _root.menu[thisDoc].description;
thisTextLoadVars.load(textDoc);
}
}
the trace in the the onLoad function returns "undefined". Can anyone tell me how to get around this please?
thanks
alz
Passing Variable Outside Of A Function Block
1. I have already read the Adobe docs and a gazillion Flash forums about the scope of variables within a function block. This is driving me mad!
2. I am using a function to assign values from a parsed XML file to variables within the function block. I am successful at parsing the XML file and displaying the variables from within the function block. However, they expire outside of the function block.
3. I would like these assigned values available globally outside of the function block.
The pseudo code:
_global.newVariable1
_global.newVariable2
_global.newVariable3
function init () {
//parse script here
//assign parsed field values from xml file to variables - fields come from ChildNodes in the XML file - this ISN'T the issue here - the fields are parsed correctly!)
Variable1 = field1;
Variable2 = field2;
Variable3 = field3;
_global.newVariable1 = Variable1;
_global.newVariable2 = Variable2;
_global.newVariable3 = Variable3;
}
var my_xml = new XML ();
my_xml.onLoad = init;
my_xml.load("filename.xml");
my_xml.ignoreWhite = "true";
trace(_global.newVariable1) should NOT be "undefined" but have the value of Variable1 (the XML field value)
[AS1/2] Passing An Object As A Variable In A Function
I have a movieClip prototype that calls another function once it has finished.
The other function could be one of many.
I want to be able to pass the variables of the second function to the first function:
Code:
MovieClip.prototype.func1=function(varA,varB,func2name,func2args){
// do something
// once done call second function:
this[func2Name](func2args.join(','));
};
// called using:
Code:
myMC.func1(varA,varB,"func2Name",{func2Arg1:value, func2Arg2:value})
Any idea how this should be written?
At the moment only the first variable of func2 is populated....
Thanks for helpin me out on this 1
Ed
Passing Instance Name To Function As A Variable
hello friends
the idea is that the site keeps tracks of whatever page is current and passes this variable to the alpha function which will target that movie instance to fade when moving to another page - then that page's name will be assigned to current.
this is the code that i have now..
#include "alpha.as"
evolution.onRelease = function() {
this[current].gotoAndPlay(2);
this[current].alpha(5, 0);
};
evolution and solo exist in the same timeline..
the hierachy is like this there is a movie called pictures on the root timeline - this contains all the buttons and all the scripts that you see (except the external script for the alpha function) - plus the variable current is declared in it too.
it's a one frame movie which contains another movie solo which is what i am trying to target when a button is clicked.
any help very much appreciated..
Si
Passing Instance Name To Function As A Variable
hello friends
ok the idea is that this movie keeps tracks of whatever page it's on using the variable current. when the button evolution is clicked it should jump to frame 2 of the movie whose instance name is contained in the variable current and also pass this variable to a function called alpha which fade that movie's instance when moving to another page - then that page's name will be assigned to current.
this is the code that i have now..
#include "alpha.as"
evolution.onRelease = function() {
this[current].gotoAndPlay(2);
this[current].alpha(5, 0);
};
all these buttons and movie instances are contained in the same movie clip and the variable current is declared in it too.
any help very much appreciated..
Si
Quick Fix: Passing A Int Variable Into A Function
I can't seem to get this to work:
var i:int = 0;
function count(a:int):void
{
a++;
}
count(i);
count(i);
count(i);
trace(i);//traces 0
Is there a way I can make it do it's math, to the variable itself, without some crazy solution or using objects to hold the variables?
[AS1/2] Passing An Object As A Variable In A Function
I have a movieClip prototype that calls another function once it has finished.
The other function could be one of many.
I want to be able to pass the variables of the second function to the first function:
Code:
MovieClip.prototype.func1=function(varA,varB,func2name,func2args){
// do something
// once done call second function:
this[func2Name](func2args.join(','));
};
// called using:
Code:
myMC.func1(varA,varB,"func2Name",{func2Arg1:value, func2Arg2:value})
Any idea how this should be written?
At the moment only the first variable of func2 is populated....
Thanks for helpin me out on this 1
Ed
Passing Variable To OnRollOver Function In A Loop
Code:
//this is where the array 'list' is
function buildList(){
spacing = 30
var i = -1;
while(++i <= list.length-1){
name = "infobar"+i;
y = i * spacing;
display.list.attachMovie("infobar",name,i);
display.list[name]._y = y;
display.list[name].linkText.text = list[i][0];
display.list[name].onRollOver=function(){
trace(list[i][0]);//this trace returns undefined
}
trace(list[i][0]);//this trace returns correctly
}
}
buildList();
it seems when i try to use the variable 'i' in the onRollOver function, it doesnt work, because if i replace i with, say, 1... it works fine.
thank you for the help
Passing A Variable In A GetURL Function To An HTML Page With JavaScript
This is probably a stupid question, but here goes:
I want to open external windows with high quality jpegs, and I don't want toolbars, scrollbars, etc...
So what I have made a blank html page called "launch.html"
On this page is some simple javascript set up to take the variable passed from Flashs getURL function, and open up a new window with the correct file.
But when I use a javascript alert to find out if the variable is being passed correctly the alert box says my variable is undefined.
The flash getURL function is scripted as such:
getURL("launch.html&openWindow=" + _root.myTarget, target="_blank", "GET")
_root.myTarget variable is set when a user presses a thumbnail image on my webpage.
Well thats my problem, hope I explained it well. Thanks ahead of time for any help you can provide
btw, using Flash 5
Problem Passing Variable Values (from XML) To Variable In Child Movie
I'm reading something from XML, and store it in a variable. I can trace the variable and it shows two items. I can display those two seperately with variable[0] and [1], meaning that it works as intended.
After that, I'm calling a movieclip, which is supposed to read that variable.. sadly, it can't do it. So I resorted to passing the content of the first variable to a variable inside the called movieclip. This works, and tracing the second variable shows both items from the first. However, I cannot access the items seperately with variable2[0] for example.
What's the problem? The second variable is currently a string. I tried to declare is as other things (like xml or array) as well, but that didn't help. Is there also a way to make this procedure unnecessary, i.e. can I somehow access the first variable?
I've attached the fla/xml/swf in case my description doesn't make sense!
Mysql->PHP->FLASH Function. (Passing Function To A Package)
I've just started with ActionScript3.0, and is currently working on a flash that is to communicate with a mysql database and have found a great deal of example code online that I've started to work with.
Currently I have the following package added to my project:
Code:
package
{
import flash.events.*;
import flash.net.*;
public class SendAndLoad
{
public function SendAndLoad()
{}
public function sendData( url:String, _vars:URLVariables, completeFunc:Function ):void
{
var request:URLRequest = new URLRequest( url );
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
request.data = _vars;
request.method = URLRequestMethod.POST;
loader.addEventListener( Event.COMPLETE, completeFunc );
loader.addEventListener( IOErrorEvent.IO_ERROR, onIOError );
loader.load(request);
}
//private function handleComplete( event:Event ):void
//{
// var loader:URLLoader = URLLoader( event.target );
// trace( "Par: " + loader.data.par );
// trace( "Message: " + loader.data.msg );
//}
private function onIOError(event:IOErrorEvent):void
{
trace("Error loading URL.");
}
}
}
And is running the following code in my flash:
Code:
import SendAndLoad;
import flash.net.URLVariables;
function loadUsername( event:Event ):void
{
var loader:URLLoader = URLLoader( event.target );
//userNameText.text = "ffff";
userNameText.text = loader.data.user;
}
var url:String = "pages/test.php";
var vars:URLVariables = new URLVariables();
var sal:SendAndLoad = new SendAndLoad();
sal.sendData( url, vars, loadUsername );
As you can see I am trying to seperate the function to be called when the return value of the page I am accessing returns with a value, so I wont need to pass all different actions to be called on different pages I will be requesting throughout my flash program.
But as it is now, the function loadUsername, never even gets called, which I assume is because the package can't call the function outside it.
As I said, I am just starting out with ActionScript 3.0, and is kind of stuck at this.
Any thoughts?
Mysql->PHP->FLASH Function. (Passing Function To A Package)
I've just started with ActionScript3.0, and is currently working on a flash that is to communicate with a mysql database and have found a great deal of example code online that I've started to work with.
Currently I have the following package added to my project:
Code:
package
{
import flash.events.*;
import flash.net.*;
public class SendAndLoad
{
public function SendAndLoad()
{}
public function sendData( url:String, _vars:URLVariables, completeFunc:Function ):void
{
var request:URLRequest = new URLRequest( url );
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
request.data = _vars;
request.method = URLRequestMethod.POST;
loader.addEventListener( Event.COMPLETE, completeFunc );
loader.addEventListener( IOErrorEvent.IO_ERROR, onIOError );
loader.load(request);
}
//private function handleComplete( event:Event ):void
//{
// var loader:URLLoader = URLLoader( event.target );
// trace( "Par: " + loader.data.par );
// trace( "Message: " + loader.data.msg );
//}
private function onIOError(event:IOErrorEvent):void
{
trace("Error loading URL.");
}
}
}
And is running the following code in my flash:
Code:
import SendAndLoad;
import flash.net.URLVariables;
function loadUsername( event:Event ):void
{
var loader:URLLoader = URLLoader( event.target );
//userNameText.text = "ffff";
userNameText.text = loader.data.user;
}
var url:String = "pages/test.php";
var vars:URLVariables = new URLVariables();
var sal:SendAndLoad = new SendAndLoad();
sal.sendData( url, vars, loadUsername );
As you can see I am trying to seperate the function to be called when the return value of the page I am accessing returns with a value, so I wont need to pass all different actions to be called on different pages I will be requesting throughout my flash program.
But as it is now, the function loadUsername, never even gets called, which I assume is because the package can't call the function outside it.
As I said, I am just starting out with ActionScript 3.0, and is kind of stuck at this.
Any thoughts?
Mysql->PHP->FLASH Function. (Passing Function To A Package)
I've just started with ActionScript3.0, and is currently working on a flash that is to communicate with a mysql database and have found a great deal of example code online that I've started to work with.
Currently I have the following package added to my project:
quote:package
{
import flash.events.*;
import flash.net.*;
public class SendAndLoad
{
public function SendAndLoad()
{}
public function sendData( url:String, _vars:URLVariables, completeFunc:Function ):void
{
var request:URLRequest = new URLRequest( url );
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
request.data = _vars;
request.method = URLRequestMethod.POST;
loader.addEventListener( Event.COMPLETE, completeFunc );
loader.addEventListener( IOErrorEvent.IO_ERROR, onIOError );
loader.load(request);
}
//private function handleComplete( event:Event ):void
//{
//var loader:URLLoader = URLLoader( event.target );
//trace( "Par: " + loader.data.par );
//trace( "Message: " + loader.data.msg );
//}
private function onIOError(event:IOErrorEvent):void
{
trace("Error loading URL.");
}
}
}
And is running the following code in my flash:
quote:import SendAndLoad;
import flash.net.URLVariables;
function loadUsername( event:Event ):void
{
var loader:URLLoader = URLLoader( event.target );
//userNameText.text = "ffff";
userNameText.text = loader.data.user;
}
var url:String = "pages/test.php";
var vars:URLVariables = new URLVariables();
var sal:SendAndLoad = new SendAndLoad();
sal.sendData( url, vars, loadUsername );
As you can see I am trying to seperate the function to be called when the return value of the page I am accessing returns with a value, so I wont need to pass all different actions to be called on different pages I will be requesting throughout my flash program.
But as it is now, the function loadUsername, never even gets called, which I assume is because the package can't call the function outside it.
As I said, I am just starting out with ActionScript 3.0, and is kind of stuck at this.
Any thoughts?
Edited: 10/09/2008 at 08:46:50 AM by _TT_
Passing Array Variable Name In To Component Variable & Getting It's Value
Hi, All
Anyone can solve my problem????
My Problem is that I want to store a array' s name in to a component variable. like this:-
working in this case
Scene action on timeline
_global.arr = "This is aray Test"
component parameters
VarName : _global.arr
Not working in this case
Scene action on timeline
_global.arr1 = new Array()
_global.arr 1[0]= "This is aray Test"
component parameters
VarName : _global.arr1[0]
in component I'm doing this on timeline action
abc.text = eval(VarName)
plz help me out of this
Regards
Ankur Arora
Passing A Function Ref To A Function With Parameters
Can anyone tell me how to pass a function reference to a function WITH parameters?
I want to do something like this:
genericFunc = function(funcRef, params){
//do something that takes a while
//and when done...
//call my funcRef with params:
funcRef(params)
}
func1 = function(){
//trace("here's funct#1");
}
func2 = function(arg1, arg2){
//trace("here's func#2 with arguments "+arg1+" and "+arg2);
}
Test 1: genericFunc(func1);
Test 2: genericFunc(func2, ...) //this is where I lose it.
So, this works fine if I'm passing in a function call that requires no parameters (test 1). But what I really need to do is keep this flexible so that I can reference different functions with varying numbers of parameters (test 2).
Passing A Function To Another Function In A Loaded Swf
Here is the problem: to make it simple, I have two swf's, one loaded into a movie instance of another swf. In the loaded swf, there is a function called checkClient with a variable passed into the function. Here is the code for checkClient
function checkClient(userID)
{
_parent.isResultCompleted(checkClient(userID));
}
isResultCompleted is a function in the root swf with the code
function isResultCompleted(functionToBeChecked)
{
functionToBeChecked;
}//end function check result
The problem I'm having is that functionToBeChecked dosen't call the function checkClient. The code in red is where I know the problem lies. Any ideas?
I have been trying to get this to work for a while now and have looked all over this forum, but nothing seems to give me a result that works. Thanks in advance. KD
Passing A Function Handle To A Function...
How can I do the following:
So I add a new child to my stage and inside this movie I got a couple variables and button handling lines of code.
I set this variables on each of the created movies and I would like to also pass a reference to a function.
This reference function can than be called when a button is pressed inside any of those created movies on my stage...
//Pseudo code
this.clip34.setFunctionReference(displayMessage);//Here I pass my function handle... How can I do this?
function displayMessage(str:String)
{
trace(str);
}
function setFunctionReference(func:FUNCTION?)
{
func("Hey I was clicked!");
}
Hope you understand me... ^.^
Passing Value To A Function
Hi guys
im calling a function and passing a value (Unit41)
function passlist(param1){
mylist=param1
trace(param1)
//unit41
}
I have a list called unit41
unit41=[1,23,45,67,89,12]
i want to set mylist in the above function to
mylist=[1,23,45,67,89,12]
hope this makes sense. I need to point the parameter passed to my function
to a list with the same name
cheers
weblingo
Passing An MC Name To A Function
What I'm trying to do is something along the lines of this:
Code:
funtion someFunction(clipName) {
clipName.somethingInside.affectClip(1,2,3);
}
mc_01.button.onRollOver = someFunction("mc_01");
mc_01.button.onRollOver = someFunction("mc_02");
So I have the containing movie clip, a button in side, and another object inside that I would like to affect. Any help is greatly appreciated.
Thank you.
Passing A Url Var In A Function.
this does not work:
var soemthing = new Something("./something.html"); for some reason... when you want to pass that as a var... i do not want to hard code anything, though.
Passing A Value Into A Function
Im cant work out what in doing wrong. I have a function on the main root time line which is only one frame.
ActionScript Code:
function inertiaCalc (cheese) {
speed=1.8
if (_root.MCScale<>_root.MCTarget) {
_root.MCScale = Math.round (_root.MCScale+(_root.MCTarget-_root.MCScale)/speed);
_root.cheese._yscale = _root.MCscale;
}
}
where cheese variable i want to pass in a instance name of the MC i want to change scale.
On the MC itself, instance name square2, I have this code
ActionScript Code:
onClipEvent (enterFrame) {
cheese = square2
_root.inertiaCalc (cheese)
}
On a separate button i have this
ActionScript Code:
on (rollOver) {
_root.MCTarget = 200
}
on (releaseOutside, rollOut) {
_root.MCTarget = 100
}
on (press) {
_root.MCTarget = 400
}
on (release) {
_root.MCTarget = 200
}
Now I know the function works because when i change cheese to square2 in the function on the root it it is perfect - i just cant get it to work when passing the instance name in variable cheese! help!
Passing MC Name To A Function ?
OK, I'm trying to figure this one out and if anyone can help, life would be a brighter place
Lets say i have a function in _root:
function changeText (mc) {
mc.myText_txt = "hello";
trace("should write hello");
}
and then I would have a MC with a instance name of "myClip" with a dynamic text field named myText_txt. On the first frame I calll the function in _root and pass the parameter with the name of this MC.
_root.changeText (myClip);
Why doesn't this work, and how can i pass MC names to functions to use them?
Passing Variable
Hi,
I want to have a movie in level1 write variables to level0. I have tried several ways and none of them have worked. I'm not sure I know the proper syntax and have had trouble finding a complete reference on it. Here is what I'm trying right now:
In a frame script in level1 which is loaded into level0:
_level0.module = "netbas";
Then I have a button script in level0 use it this way:
on (release) {
loadMovieNum (+module+"_c.swf", 1);}
I want the button to load the following file into level1: netbas_c.swf. When I test and click the button I get an error that says it can't find "_c.swf" indicating to me that it isn't getting the variable value. It works fine when I set it within level0, but not from level1.
Can you please tell me why this won't work and what I need to do. Is there a better way to have links in level0 use variables that will be set in the current movie in level1?
Where can I get complete help on this?
Additional info: I have several movies that will be put into level1. A button in level0 will load a movie in level1. Once that movie is loaded, then I want all the navigation
buttons in level0 to have "netbas" in front of them so that they only load the swfs associated with the current movie in level1. Then when the user clicks on Advanced
Networking from the main menu and loads that movie into level1, I want all those buttons in level0 to have "netadv" in front of them. (i.e. netadv_c.swf). I hope this is
clear. I've made parts work, but I cannot get the variable to level0.
Thanks,
Brian
Passing Variable?
i have a MC-b within a MC-a,i set a variable in MC a now i want to use it in MC b also how do i pass it on from MC-a MC-b or to main time line?
Thanx!
Passing Variable
I have a base movie. In this base movie I have loaded two other movie using the basic action:
loadMovieNum ("movie1.swf", 1);
loadMovieNum ("movie2.swf", 2);
I have identified and set variables in movie1.
[eg. _root.variable1 = "white";]
I would like to be able to change these variable from movie2.
[eg. _root.variable1 = "blue";]
I have not been able to do this.
Advice please.
Passing Variable
I have a base movie. In this base movie I have loaded two other movie using the basic action:
loadMovieNum ("movie1.swf", 1);
loadMovieNum ("movie2.swf", 2);
I have identified and set variables in movie1.
[eg. _root.variable1 = "white";]
I would like to be able to change the value of the variable from within movie2.
[eg. _root.variable1 = "blue";]
I have not been able to do this.
Advice please.
Variable Value Passing
I am trying to make an RPG in flash... I have a dynamic text box in the top left hand corner of each scene, to show how many credits the player currently has. The variable of that textbox is "showcredits". So I put in 2 actions:
credits = 500
showcredits = credits
In this game, people will be able to purchase things using the credits. But here is my problem. I have a seperate scene for a store in which they can buy things. In this scene, I have one action:
showcredits = credits
But in this scene, the number of credits doesn't show up... I'm guessing that the value I set for the "credits" variable in the first scene didn't pass over to the next scene... what can I do?
Passing A Variable To .SWF
I wonder if anyone can help me. This is probably a simple question for most of you but can I pass a variable into a .swf movie by simply doing this:
mymovie.swf?mapid=1
I would then like to collect the variables value within the flash movie. Is this possible or is there another way of doing it.
Thanks in advance
Steven
Variable Passing
I cant give up now im almost finish.But my problem is i cant pass a variable to php is some thing wrong with my coding
at flash
---------------------------------------------------------------
// Create random number to append to URL
randNum = Math.random()*1000000000;
var classID ="1"; >>>>this is the variable i want to pass to php
// Call PHP script to fetch class information
loadVariables ("viewforum.php?cla_id="add classID add "&" add randNum, this);
// Halt the movie clip until data loaded
stop ();
--------------------------------------------------------------
and here is my coding at php side
-------------------------------------------------------------
<?
// Include config file
include('common.php');
// Connect to database
$link = dbConnect();
// Build query to fetch forum
$query = "SELECT * FROM prod_subclass where cla_id= '$classID'";
// Execute query
$result = mysql_query($query);
// If query failed...
if (!$result) {
// Inform Flash of error and quit
fail("Couldn't list class from database");
}
// Find out how many class in this table
$threadCount = mysql_num_rows($result);
// Setup our variable to hold output
$output = "classCount=$classCount";
// For each classreturned...
for ($count = 0; $count < $classCount; $count++)
{
// Extract post details from database
$class= mysql_fetch_array($result);
$classID = $class['subcla_id'];
$topic = stripslashes($class['subclass']);
// Add thread details to output
$output .= "&class" . $count . "ID=" . $classID;
$output .= "&class" . $count . "Topic=" . urlencode($topic);}
// Output all threads in one go
echo $output;
// Inform Flash of success
print "&result=Okay";
// Close link to database server
mysql_close($link);
?>
-------------------------------------------------------------------
Please help ...thank you in advance
Variable Passing
I'm new to this. I need to pass a variable as defined in one script contained in a movie clip to another instance. The purpose of this is to have a drop down menu with button choices. Selecting a button will initiate a transition movie clip. When the last frame of the transition clip is viewed, a separate .swf file will begin loading. This same transition clip will be played before every linked .swf file is loaded. The name of the .swf is the variable I want passed from the menu to the tranisition clip.
I know it's wrong, but here's the code as it stands today. "movieOpen" is the intended variabe, of course used incorrectly here.
Drop Down Menu Clip Code:
on (release) {
_root.Transition.gotoAndPlay(2);
with (_root.Transition) {
_root.Transition.movieOpen = "Test.swf";
}
}
Transition Instance Code:
ifFrameLoaded (11) {
unloadMovieNum (3);
loadMovieNum ("movieOpen", 3);
}
stop ();
Thanks in advance for your tutelage,
Todd
Passing A Variable To A URL
Hi,
I am having difficutly figuring out how to pass a variable from an input text field to a URL. I have a form field for users to input their zip code, then I would like to append the a url to add that zip code. The URL ends with "zip= " and I would like to input the zip variable before executing the getURL command. Any thoughts?
Best
Passing Variable Help
little syntax help please :
var fadeButton = 2;
_root.button(fadeButton)._alpha = 50;
trying to make button2 fade 50%....not working...whats the proper syntax.
THANKS!
Passing Variable From URL To SWF
I am creating a small SWF of a speedometer. The end result should take the value of a variable "speed" from the URL and have the needle of the speedometer stop on a corresponding frame. There is 160 MPH on the speedometer and the needle goes from 0-160 over the course of 160 frames. I have gotten the needle to work using a slider (please excuse the jumpy-ness).
http://www.blackdragonmotorsports.com/speed.htm
Now that I have gotten that to work, I need to replace the slider with a dynamic variable (from the URL) that will tell the MC "needle" to stop at the corresponding value. For example...if the URL was:
http://www.blackdragonmotorsports.c...ed.htm?speed=45
the needle should stop on frame 45.
The *.fla is at http://www.blackdragonmotorsports.com/speedometer.fla
Any help would be awesome.
Thanks,
Jay Almers
Variable Passing
Hi expert out there, need some help from you guys, so here is the situation, i have a html file which content 2 frames FRAME1 and FRAME2, how do i pass variable(onclick or onload) from HTML in FRAME1 to the flash(swf) in FRAME2 to do something? Is this posible?
Thanks in advance!!!!
Variable Passing
*is there anyway that you can pass variables from one movie clip to the another.
Say i have a in one movie clip/button
on(press){
if(t=true){
gotoandplay("blah");
}
else{
gotoandplay("blah2");
}
can i update that variable t in another movie clip and pass it to the one that has the code above?????
is it even possible?
thanks
Peter
Passing Variable
howdy
i have three swf's main, nav, and window now what im tring to do is when a button is clicked in nav set variable in root i have this action, not sure if its right
_root.section="home";
i declared this variable in the main.swf, i have the following code:
section="0"; in the first frame of main
now when i click the button in nav as well as sending the variable to _root i get it to start anination in window which is doors shutting, when they finally close there is the following actions
if (_root.section == "home") {
loadMovie("pages/home.swf", "_level2.contentwindow.msg");
} else if (_root.section == "work") {
loadMovie("pages/work.swf", "_level2.contentwindow.msg");
} else if (_root.section == "skills") {
loadMovie("pages/skills.swf", "__level2.contentwindow.msg");
} else if (_root.section == "gallery") {
loadMovie("pages/gallery.swf", "_level2.contentwindow.msg");
} else if (_root.section == "contact") {
loadMovie("pages/contact.swf", "_level2.contentwindow.msg");
} else if (_root.section == "msg") {
loadMovie("pages/msg.swf", "_level2.contentwindow.msg");
}
cant seem to get them working, been playing with the code for ages now, pulling my hair out.
thanks in advance
Re: Passing Variable
Hello,
I am having some trouble passing a variable from an input box to a dynamic text box. I want the user to input their name, click a submit button and then have their name passed to a dynamic text box. At the moment I have an action on the button as follows: -
on (release) {
inText = grad_Name;
gotoAndStop("output");
}
(grad_Name is the name of the variable attached to the input box, to be passed to a frame named "output".)
The action on "output" frame is as follows: -
outText = inText;
stop();
(outText is the name of the dynamic text box).
Now, it was working OK but then I adjusted a graphic and now it doesn't work!!!
Any ideas or a better solution much appreciated.
|