[CS3, AS2] Passing A Function (and Its Parameters)
does anyone know how to pass a function, and an unknown number of parameters, through another function? I'd like a function to behave similarly to setInterval, where you pass a function name, and every parameter after the function name, no matter how many there are, is used as a parameter for the function call.
i.e.
function aFunc(bFunc:Function, arg1, arg2, ...):Void { // magic code makes stuff happen!! }
so: aFunc(bFunc, arg1, arg2, arg3, arg4, arg5);
would give me the same thing as: bFunc(arg1, arg2, arg3, arg4, arg5);
any ideas?
FlashKit > Flash Help > Flash ActionScript
Posted on: 06-25-2008, 10:54 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Function Not Passing Parameters
I have a component on my stage, within this component there is this function at the first frame of the component's timeline:
code: function ContentLoad(File:String, xFile:Number, yFile:Number) {
//Create a container for the image to load into
_root.createEmptyMovieClip("ContentLoader", _root.getNextHighestDepth());
//Load the actual image
_root.ContentLoader._x = xFile;
_root.ContentLoader._y = yFile;
loadMovie("content/location/description.swf", _root.ContentLoader);
}
Inside this same component, there are buttons, which call the function.
This is defined as follows:
code: on (release) {
ContentLoad("description.swf", 100, 100);
}
The function is called, but the parameters aren't passed.
What is wrong ???
Passing Parameters To A Function
Hi,
I'm new to AS3, but have written a piece of code in AS2 which I'm now trying to convert.
Basically I've got a movieclip ("grid1") and in that there are a number of instances of the same movieclip ("g1", "g2" etc) and in that is a textbox ("ans.text"). The code I worte passes the name of the movieclip click and takes the content of that textbox and passes it to a function which checks it.
on the button:
Code:
on (press){
checkAns1p(this.ans.text, this);
}
the function:
Code:
function checkAns1p(myAns, referer) {
if (myAns == sub_answer) {
//do something
}
This works fine, the problem I am finding is now that AS3 does not use "on (press)" I don't see how it's possible to pass this information.
Code:
function checkAns(event:MouseEvent):void {
selectedAns = grid1.g1.ans.text;
if (selectedAns == subAns){
trace("Correct!");
}
}
If I hard code it as above then it works, but I don't want to have to do this 32 times. Is there anyway to pass "this" across as I did in AS2?
Passing Parameters To A Function
Hi,
I'm new to AS3, but have written a piece of code in AS2 which I'm now trying to convert.
Basically I've got a movieclip ("grid1") and in that there are a number of instances of the same movieclip ("g1", "g2" etc) and in that is a textbox ("ans.text"). The code I worte passes the name of the movieclip click and takes the content of that textbox and passes it to a function which checks it.
on the button:
Code:
on (press){
checkAns1p(this.ans.text, this);
}
the function:
Code:
function checkAns1p(myAns, referer) {
if (myAns == sub_answer) {
//do something
}
This works fine, the problem I am finding is now that AS3 does not use "on (press)" I don't see how it's possible to pass this information.
Code:
function checkAns(event:MouseEvent):void {
selectedAns = grid1.g1.ans.text;
if (selectedAns == subAns){
trace("Correct!");
}
}
If I hard code it as above then it works, but I don't want to have to do this 32 times. Is there anyway to pass "this" across as I did in AS2?
Passing Parameters Into A Function
Ok gang here's my code:
ActionScript Code:
var rssXML = new XPathDocument();
var blogXML = new XPathDocument();
loadXML(rssXML, parseRSS, "http://mlb.mlb.com/partnerxml/gen/news/rss/col.xml");
//*********************************************************************
import com.xfactorstudio.xml.xpath.*;
//*********************************************************************
function loadXML(obj, func, url) {
trace (obj);
obj.ignoreWhite = true;
obj.onLoad = function(success) {
if (success) {
//trace (obj);
func();
}
};
obj.load(url);
}
What I'd like to do is pass the parameters into the function so that when I first run 'loadXML' the rssXML object loads the proper url and then calls a function entitled 'parseRSS'. The trace is coming up as 'undefined'. Where do my problems lie?
Passing Parameters To A Function
anyone can find a way to say the same in just a few line of code?!
25 lines of code people where are u guys?!
ActionScript Code:
menuAS = function () { //TIOCCHA menuBar.menu01.menu01_btn.onRelease = function() { pageLOADER.loaderIndex.gotoAndStop("menuTioccha"); resetMenu(); menuBar.menu01.menu01_btn._visible = 0; }; //FRANCHINSING menuBar.menu02.menu02_btn.onRelease = function() { pageLOADER.loaderIndex.gotoAndStop("menuFranchising"); resetMenu(); menuBar.menu02.menu02_btn._visible = 0; }; //CATALOG menuBar.menu03.menu03_btn.onRelease = function() { pageLOADER.loaderIndex.gotoAndStop("menuCatalog"); resetMenu(); menuBar.menu03.menu03_btn._visible = 0; }; //STORES menuBar.menu04.menu04_btn.onRelease = function() { pageLOADER.loaderIndex.gotoAndStop("menuStores"); resetMenu(); menuBar.menu04.menu04_btn._visible = 0; }; //CONTACTS menuBar.menu05.menu05_btn.onRelease = function() { pageLOADER.loaderIndex.gotoAndStop("menuContacts"); resetMenu(); menuBar.menu05.menu05_btn._visible = 0; };};
thx
Passing Function Parameters From An XML Doc
Hi-
I'm having an issue with calling a function from an imported XML file. This is my function:
function SwitchImage(movieName) {
this.popBox.popImage.loadMovie(movieName);
this.popBox.popCaption = "Go Bulldogs";
}
This is the XML. The function works fine. It calls the function "SwitchImage" and it loads the image "1.jpg".
<myLife >
<pagetext whatYear="1959">I was born on February 4<a href="asfunction:_global.shell.SwitchImage,images/1.jpg">change picture</a></pagetext>
</myLife>
Now I want to pass it another parameter called "popCaption":
function SwitchImage(movieName, popCaption) {
this.popBox.popImage.loadMovie(movieName);
this.popBox.popCaption = (popCaption);
}
<myLife >
<pagetext whatYear="1959">I was born on February 4<a href="asfunction:_global.shell.SwitchImage,images/1.jpg, my new caption">change picture</a></pagetext>
</myLife>
I'm not sure what I'm doing wrong, but it must be in the XML. Any help is appreciated.
Thanks,
Clemente
Passing Parameters To Function
Hi how can i adjust the code below to pass the variables to the function go()? I not quite sure on how to do it... What i am trying to acheive is that each button will goto a different place, but i want one function to handle it.
CODEimport flash.net.*;
function go (event:MouseEvent) {
//trace(eventObject.name);
var req:URLRequest = new URLRequest(url);
navigateToURL (req, "_self");
}
//b1.addEventListener (MouseEvent.CLICK, go));
b2.addEventListener (MouseEvent.CLICK, go);
//b3.addEventListener (MouseEvent.CLICK, go("#message"));
Passing Function Parameters In A Loop?
Hey guys,
i am creating a flash product catalogue using an xml file to store the data. The catalogue has a few categories and a few products in each category.
I have written the script to put the categories into a array and now I am writing the script to make the category buttons. I want the category buttons to call another function which will place the products from that category on the screen.
The problem is that in the “for Loop” the function parameter is not being set or passed for some reason. Can anyone see what im doing wrong here?
thanks for your help!!!
Joe
PHP Code:
//For loop to place a button instance
for (var i = 0; i <aCat.length; i++) { {
//Place the button instance
attachMovie("mcCatButton", "mcNewCatButton"+i, i, {_x:xPos, _y:yPos});
//add the label
this["mcNewCatButton"+i].catTitle.text = aCat[i][0];
// add an onRelease which calls the displayProducts funciton
this["mcNewCatButton"+i].onRelease = function():Void {
displayProducts(catID[i][1]);
}
// This trace works fine
trace(catID)
}
//This is the function where the products will be displayed on stage
displayProducts function(cat:String) {
// Why does this trace return undefined??
trace(cat)
}
Passing Parameters Of The Function With The Listener
my function is this:
ActionScript Code:
function gotoAndPlayRandomFrameLabel(clip_name, frameLabels_array) {
if (frameLabels_array == undefined) {
frameLabels_array = clip_name.frameLabels;
}
var randomLabel:Number = Math.floor(Math.random() * (frameLabels_array.length));
clip_name.gotoAndPlay(frameLabels_array[randomLabel]);
}
and my timer is this:
ActionScript Code:
var blink_interval:Timer = new Timer(5000);
blink_interval.addEventListener(TimerEvent.TIMER, MovieClip(parent).gotoAndPlayRandomFrameLabel(this.head_mc.blink_mc, this.head_mc.blink_mc.frameLabels));
blink_interval.start();
I'm getting a Error #2007: Parameter listener must be non-null.
How can I pass the parameters with the timer to the function? Make sense?
Passing Parameters To A Function In SetInterval()
If I wanted to set inteval for a function requiring a parameter, how do I
pass the parameter?
If I do like this:
var myInterval =setInterval(f(p),2000);
it causes the functuion to execute immediately
Custom Function, Passing Parameters
If i create a function... function blah(A:MovieClip, B:MovieClip, C:String):Void...
is there a way that when i call it i can pass A and C to it and skip passing B and have the function assign a default value to B? I think i saw that you can do that now in AS3... but i cant find a way to do it in AS2.
so what i want to do is something like blah(A, , C); and somehow only be able to send the first and third parameter if i want.
Thanks!
Kyle
Passing Parameters To A Function In A For Loop
how do i pass the values of a for loop (for example the increment count) to a onRelease function inside that loop? in the example below the movie clip will always go to "whatever.php?var=10" because the value of i when you click it is 10. i want the value of i to be included for each run of the loop. how do i do that? i'm guessing maybe a listener, but i can't get anything to work.
Attach Code
var home:MovieClip = this;
for (i=1; i<10; i++) {
var t = home.attachMovie("myMovie", "myMovie"+i, i);
t.onRelease = function() {
getURL("whatever.php?var="+i);
}
}
Passing Additional Parameters To Function Listeners
hboxvar.addEventListener("mouseDown",dosomething(3 43));
hboxvar.addEventListener("mouseDown",dosomething(1 23));
hboxvar.addEventListener("mouseDown",dosomething(1 2342));
public function dosomething( somenumber:Number ):void {
//do something here
}
I try to do above function but I need to pass variable from hboxvar but not from inside function suggested by macromedia.
any one has the solution?
Thanks in Advance.
any one frustated with this way of passing multiple parameter which depends on what to pass in flex 2 using addEventListener ?
http://livedocs.macromedia.com/labs/...=00000506.html
</mx:Application>Passing additional parameters to function listeners
You can pass additional parameters to function listeners depending on how you add the listeners. If you add a listener with the addEventListener() method, you cannot pass any additional parameters to the listener function, and that listener function can only declare a single argument, the Event object (or one of its subclasses).
Function Call Passing Parameters To PendingCall
Help, I have a situation where I am recieving either one or two parameters from a localConnection call and then I want this reciept to both activate a function while passing that function the parameter. I traced and confirmed that both the receiving localConnection and the sending function are recieving and sending the parameters. My problem is in the pendingCall, the function is not working. If I place a trace before and after the pendingCall statement I see that the call should be recieving parameter,but when I look in the debugger it says that the parameter is undefined. Outlined below is a sample of what I am trying to do.
Code:
//---------------<Sending Test>----------------------\
myBtn.onRelease = function(){
var lcArtInfo:LocalConnection = new LocalConnection();
lcArtInfo.send("_nmGetTest","findfoo", myTxt.text);
trace("sending message to receiving movie "+myTxt.text);
}
//---------------<Sending Test>----------------------\
//---------------<Receiving Test>----------------------\
stop();
import mx.rpc.Responder;
import mx.remoting.Service;
import mx.services.Log;
import mx.rpc.RelayResponder;
import mx.rpc.FaultEvent;
import mx.rpc.ResultEvent;
import mx.remoting.PendingCall;
import mx.remoting.RecordSet;
import mx.remoting.DataGlue;
import mx.styles.CSSStyleDeclaration;
import mx.data.binding.*;
//--------------< This is forms interactive basics for the frontpage search>----------\
var artest_lc:LocalConnection = new LocalConnection();
artest_lc.findfoo= function(param1:Number):Void{
trace("Receiving movie is receiving from sending movie this: "+param1);
getAPic(param1);
};
artest_lc.connect("_nmGetTest");
mx.remoting.debug.NetDebug.initialize(); // initialize the NetConnection Debugger
var myLogger:Log = new Log( Log.DEBUG, "logger" );
myLogger.onLog = function( message:String ):Void {
trace( "myLogger-->>>"+message );
}
makeCall = new Service(
"http://localhost:8080/netstore/gateway",
null,
"com.nm.java",
null,
null);
function getAPic(param1):Void {
trace("param1 = "+param1);
var pt_pc:PendingCall = makeCall.getAllAAs(param1);
pt_pc.responder = new RelayResponder(this, "ads_Result", "ads_Fault" );
};
//---------------<Receiving Test>----------------------\
Thanks in advance for any assistance you can provide.
Passing Additional Parameters To Function Listeners
Hello all,
I'm aware that this topic has been covered before, but after several hours googling and experimenting, I'm not getting any closer and could really do with some help.
I'm migrating to from AS2 to AS3 and trying to get my head around best practices using listeners on buttons.
Let's say I have ten buttons which I've created on my stage in the Flash IDE (these are instances of SimpleButton) which are labelled :
myBtn1
myBtn2
myBtn3
.....
myBtn10
What I want to do is make a function that is called when each one is clicked on which has a parameter passed depending on which one was clicked.
In AS2, I used to achieve this by using Joey Lott's Proxy.as class as follows:
Code:
for ( var i=1; i<=10; i++ ) {
this["myBtn"+i].onRelease = Proxy.create (this, doStuff, i);
};
private function doStuff (i:Number) : void
{
trace("Hey look! Button number "+i+" just got pressed!");
}
Now, obviously in AS3 I guess should be using Listeners instead, so I'm doing something like this:
Code:
for ( var i=1; i<=10; i++ ) {
this["myBtn"+i].addEventListener( MouseEvent.MOUSE_UP, doStuff );
};
private function doStuff (e:MouseEvent) : void
{
trace("Hey look! A button got pressed!");
trace("I know I can find it's instance name by using "+e.currentTarget);
trace("But that doesn't really help me.");
}
Using the above, I know I could stick a switch statement inside my doStuff function and use e.currentTarget to get the instance name of the button that was pressed and work out what to do that way, but that would be an awfully long-winded way of doing it.
From all the googling I've been doing on the subject, it seems I should be creating a custom Listener, but despite finding a few relevant board posts:
http://www.actionscript.org/forums/a.../t-104284.html
http://board.flashkit.com/board/show...event+listener
http://www.actionscript.org/forums/s...ters+listeners
...I can't seem to get them working for the life of me, and I'm totally stuck as to what approach I should really be taking.
Another approach would be to make all my buttons movieclips instead of SimpleButtons and then to add the parameters like this:
Code:
for ( var i=1; i<=10; i++ ) {
this["myBtn"+i].myFunkyParameter = i;
this["myBtn"+i].addEventListener( MouseEvent.MOUSE_UP, doStuff );
};
private function doStuff (e:MouseEvent) : void
{
trace("Hey look! A button got pressed!");
trace("And the parameter is: "+e.currentTarget.myFunkyParameter);
}
... but it seems that you can't add variables to SimpleButtons and I'm loathe to stop using Button-type symbols as I do find them very handy for doing quick rollovers, specifying hitAreas etc.
So can anyone help me?
Thanks!
Passing Additional Parameters To Function Listeners
I have already created a custom mouse event which seems to work fine. It is simply a mouse event which passes an additional sound object. The problem is I am passing this event to another class which checks for collision of a movie clip with another and if true it adds the sound to an array. What I think is happening is a type conversion problem between my customEvent and the MouseEvent.
Error (1119: Access of possibly undefined property sound through a reference with static type flash.events:MouseEvent.
Thanks
Frame Code
ActionScript Code:
this.drum1.addEventListener(MouseEvent.MOUSE_DOWN, newDrums);
function newDrums(event:MouseEvent):void{
var drum:drumKit = new drumKit();
addChild(drum);
drum.x = 200;
drum.y = 200;
dispatchEvent(new CustomSoundEvent( MouseEvent.MOUSE_UP, sound));
drum.addEventListener(CustomSoundEvent.MOUSE_UP, checkTarget);
}
function checkTarget(event:MouseEvent):void {
timeline1.checkTarget(event);
}
Timeline Class
ActionScript Code:
public function checkTarget(event:MouseEvent):void {
for (var i:int = 0; i < _timeBlocks.length; i++) {
var currentX:Number = event.currentTarget.x;
var currentY:Number = event.currentTarget.y;
if (event.currentTarget.hitTestObject(_timeBlocks[i])) {
event.currentTarget.x = _timeBlocks[i].x;
event.currentTarget.y = _timeBlocks[i].y;
event.currentTarget.disable();
addtoTimeline(event.sound);
}
}
}
Custom Event Class
ActionScript Code:
package {
import flash.media.Sound;
import flash.events.*;
public class CustomSoundEvent extends Event {
public static const MOUSE_UP:String = "mouseUp";
public var sound:Sound;
public function CustomSoundEvent( type:String, s:Sound ) {
this.sound = s;
super( type );
}
}
}
Irrelevant code omitted
Passing Additional Parameters To Function Listeners
Hello all,
I'm aware that this topic has been covered before, but after several hours googling and experimenting, I'm not getting any closer and could really do with some help.
I'm migrating to from AS2 to AS3 and trying to get my head around best practices using listeners on buttons.
Let's say I have ten buttons which I've created on my stage in the Flash IDE (these are instances of SimpleButton) which are labelled :
myBtn1
myBtn2
myBtn3
.....
myBtn10
What I want to do is make a function that is called when each one is clicked on which has a parameter passed depending on which one was clicked.
In AS2, I used to achieve this by using Joey Lott's Proxy.as class as follows:
Code:
for ( var i=1; i<=10; i++ ) {
this["myBtn"+i].onRelease = Proxy.create (this, doStuff, i);
};
private function doStuff (i:Number) : void
{
trace("Hey look! Button number "+i+" just got pressed!");
}
Now, obviously in AS3 I guess should be using Listeners instead, so I'm doing something like this:
Code:
for ( var i=1; i<=10; i++ ) {
this["myBtn"+i].addEventListener( MouseEvent.MOUSE_UP, doStuff );
};
private function doStuff (e:MouseEvent) : void
{
trace("Hey look! A button got pressed!");
trace("I know I can find it's instance name by using "+e.currentTarget);
trace("But that doesn't really help me.");
}
Using the above, I know I could stick a switch statement inside my doStuff function and use e.currentTarget to get the instance name of the button that was pressed and work out what to do that way, but that would be an awfully long-winded way of doing it.
From all the googling I've been doing on the subject, it seems I should be creating a custom Listener, but despite finding a few relevant board posts:
http://www.actionscript.org/forums/a.../t-104284.html
http://board.flashkit.com/board/show...event+listener
http://www.actionscript.org/forums/s...ters+listeners
...I can't seem to get them working for the life of me, and I'm totally stuck as to what approach I should really be taking.
Another approach would be to make all my buttons movieclips instead of SimpleButtons and then to add the parameters like this:
Code:
for ( var i=1; i<=10; i++ ) {
this["myBtn"+i].myFunkyParameter = i;
this["myBtn"+i].addEventListener( MouseEvent.MOUSE_UP, doStuff );
};
private function doStuff (e:MouseEvent) : void
{
trace("Hey look! A button got pressed!");
trace("And the parameter is: "+e.currentTarget.myFunkyParameter);
}
... but it seems that you can't add variables to SimpleButtons and I'm loathe to stop using Button-type symbols as I do find them very handy for doing quick rollovers, specifying hitAreas etc.
So can anyone help me?
Thanks!
[AS 2.0] Passing Parameters From A Cue Point To Listener Function
I have an FLVPlayback component with several ActionScript cue points designated along its timeline. I've written a listener that successfully executes a function whenever the video reaches one of my cue points. However, I'd like it to do different things depending on which of the cue points it has reached.
Here is my code:
Code:
// these are the cue points that I'm adding to my video
_root.thevid.addASCuePoint(33, "show1");
_root.thevid.addASCuePoint(43, "hide1");
_root.thevid.addASCuePoint(63, "show2");
_root.thevid.addASCuePoint(73, "hide2");
_root.thevid.addASCuePoint(93, "show3");
_root.thevid.addASCuePoint(103, "hide3");
var listening:Object = new Object();
listening.cuePoint = function():Void {
// code
}
_root.thevid.addEventListener("cuePoint", listening);
Essentially, I would like for the function to accept a String name from the cue point, and then decide which action to take (either showing or hiding something). I don't know the correct syntax for accepting information from the cue point. Should I pass the cue point into the function as an object, then parse its name from within the function?
Every example I've seen dealing with cue points and listeners has assumed that I only want one type of action to occur when a cue point is encountered - which is not the case.
Passing ...rest To A Function With An Undefined Number Of Parameters
So, let's say I am passing a function and its parameters to another function:
[as]function caller(func:Function, ...params) {/as]
So I want to call the function that's been passed, using params as the parameters. But if I just do this:
ActionScript Code:
func(params);
then it calls the function with one parameter, which is an array of parameters.
I could try something like this:
ActionScript Code:
switch (params.length) {
case 0:func();break;
case 1:func(params[0]);break;
case 2:func(params[0],params[1]);break;
case 3:func(params[0],params[1],params[2]);break;
...
}
But that seems a poor way to do it, and will eventually hit an upper limit on the number of parameters that can be passed.
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).
Calling A Function From An Html Link And Passing Multiple Parameters
Hi all
Okay I know how to call a function using an html link like this:
Code:
<a href="asfunction:_root.DoThis,Parameter">Click here</a>
my problem is I need to pass in several parameters but when I do this:
Code:
<a href="asfunction:_root.DoThis,Parameter1,Parameter2,Parameter3">Click here</a>
it passes one parameter with this value:
'Parameter1,Parameter2,Parameter3'
Does anyone know how I get round this?
Thanks in advance
Passing Parameters?
Hi there,
is it possible to pass a parameter through the object/embed tag to the flash player? How do I read this parameter from flash?
thanx!
Dominik
Passing Parameters To Swf
Hi,
I'm an experienced programmer, but completely new to Flash.
I want to create a SWF that draws a guitar chord box, but I don't want to publish a different SWF for each possible chord.
My idea is by passing pre-defined custom variables, the chord shape will be drawn at run-time.
I also envisage having multiple chords on a single web page (all using the same SWF file, but being passed different variables defining the fingering etc.)
Can anyone tell me how to go about the variable passing?
All I can find so far is how to open a text file with variables, but since the name of the text file gets compiled into the SWF, it's not suited to my particular problem.
Thanks,
SadCafe
Passing Parameters
I have a standalone exe that must pass variables values at the end of the presentation to an exe, using the FScommand.
Code:
fscommand("exec", eventlog.exe -drawingid&scratchid&fullname&_root.selected);
fscommand("exec", logplay.exe -_root.scratchid&_root.fullname&_root.prizeArray[_root.selected][2]&_root.prizeArray[_root.selected][4]&_root.WinorLoose;
fscommand("exec", "welcome.exe");
Can someone help me?
Passing Parameters...
Hi,
Can someone please give me an overview of how to pass parameters between movies.
I have 4 movies, there is a car symbol which changes colour on click. I need each movie to know the current colour of car to show on load. And then on exit, to keep the new colour to the destination movie. There are also a few other variables such as radio = on/off, so i think i need to pass parameters between movies here?
Passing Parameters
I have a small Flash intro peice that is embedded at the start of an Authorware peice. It has a few buttons of info, a quit and a start. I want the start button to effectivley stop the Flash movie running and proceed into the rest of the Authorware timeline. The quit button will quit the whole Authorware app. I can code the Flash movie to quit etc when running stand-alone from a .swf file, but how do you pass these parameters to Authorware when it's embedded? Any ideas?
Passing Parameters
I have developed an opening front page in flash for my friends software but he would like to be able to change the version number on this without accessing the .FLA file. Can this be done by passing parameters to the .swf if so can anyone suggest how i go about doing this??
Thanks in advance
Passing Parameters ?
I know this request has something to do with passing parameters (or variables.) I know very little about either one. Please keep in mind that I am more of a designer than I am a programmer.
PROBLEM:
I am creating a world map. As you roll over each country the name of that country needs to appear in a designated box.
(Open the enclosed file to see a demo.) I was just informed by the client that it needs to be multilingual. The trick to this request is getting the country names to come from a data base so that it can be multilingual. (thus only needing to have one map) I am working with a programmer on the back end of this project but he knows nothing of flash. I presume that I need to rig the country buttons to take in a vairiable. I am just not sure how to set the whole thing up.
Currently the only country that works is South America.
I can give you more info at your request. Thanks for your help. Safe to say that I know very little about this topic.
Thank you for your help!
J
Passing Parameters
I'm trying to simplify my code. But I'm having a hard time with creating functions and passing parameters. Can I pass the name of a movieclip as a parameter and then control the alpha of that parameter(MC)? If I'm passing the name of an MC as a parameter, do I put the name of the MC in quotes when I'm setting the variable? Also can I call a function from a hitTest in an enterFrame event?
Passing Parameters
Hi..
I am trying to pass parameters to a flash movie. It passes the variables fine when on the web page. But when its loaded into another movie on the web page the parameters are not getting passed.
What should I do... should I catch the parameters in the main parent movie and make them global variable for the loaded movie... and can I even do that?
Thanks in advance,
Joe
Help With Passing Parameters Please....?
Hi there,
I have looked on these forums and also on the internet to try and find an answer to what I thought originally was going to be quite easy but I think that I have just confused myself so was wondering if anyone here could help with a small (I hope) problem that I am facing.
What I have is lots of .swf files that are using an FLV playback component. These FLV components link to movies stored on the server. This all works fine. What I want to be able to do is have a html page that I design that contains the html layout and also the .swf file that links to the FLV file. What I need is some way of passing in the url
(http://www.yoursite.com/video.html?v...firstVideo.swf)
so that I can just easily point to the next video .swf file by just changing the url passed to the html file.
Is this possible and if so how cross platformable will it be? The reason I need this is that I am making a site where people will be buying products and there will be video demonstrations as part of the package yet I envisage there being a lot of products and so a lot of videos and I didn't want to have to code each page seperately and seemed to remember there was a way of passing a parameter to flash through the url string.
If anyone understands what I am now probably babbling on about a bit too much and can offer any help then I would be very greatful.
Thank you in advance.
Regards,
Mark Bowen
[F8] Passing Parameters From URL
Hello,
I would like to create Flash movies with dynamically changing content.
There are 2 text fields for which I would like to get content from the URL.
For example, the webpage with embedded Flash movie would be:
http://domain.com/page.php?text1=hahaha&text2=hehehe
and I would like to display the 'hahaha' text in one text field of Flash movie
and 'hehehe' in the other.
Is it easily doable?
Best Regards,
prezzz
Passing Parameters From Swf To Swf
Got a bit of a problem here. I am trying to load up a swf file from within flash. Problem is that the swf file I am trying to load needs a flashvars parameter passed into it.
I have tried movieclip.loadMovie("url?path=paramter") format but this doesnt work.
Any idea or work arounds?
Cheers
Nick
Passing Parameters From SWF To SWF
Hello,
Being a total newbie to flash and actionscript in general, there is a big problem I've had for some days now and I can't seem to find a solution, so I was hoping some of you guys could spare a hand over here.
I have a big "parent" SWF which is to load several child swfs, and these have some images and texts that are to be loaded dynamically, hence I need the parent SWF to pass some parameters.
The problem is, I can't seem to figure out a way to do it in AS3. I regret that I didn't start learning AS2 first, because there are like 10 billion tutorials out there on how to do things with it, but AS3 is more new so less tutorials and they all cover the same basic stuff that I don't need.
Basically inside the parent SWF I call a PHP script and load some data from it, it works fine. For passing parameters to the child SWFs I was trying the same approach but it ain't working
If I call the child SWF in a browser like this
Code:
http://server/animations/child.swf?id=1&picture=hello.jpg
It works perfectly, the code loads the parameters passed in the GET request and it's all fine.
But why doesn't it work when loading it from within AS3?
ActionScript Code:
var path:String = 'http://server/';
{...}
var childArea:Shape = new Shape();
childArea.graphics.drawRect( 0 + ( width * i ), 0 + ( height * i ), width, height);
addChild( childArea );
var childLoader:Loader = new Loader();
childLoader.mask = childArea;
var childURI:String = path + 'animations/child.swf';
//var childURI:String = 'child.swf';
var childRequest:URLRequest = new URLRequest( childURI );
var childVariables:URLVariables = new URLVariables();
childVariables.id = '1';
childVariables.picture= 'hello.jpg'; childLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
childRequest.data = childVariables;
childLoader.load( childRequest );
addChild( childLoader );
function ioErrorHandler(event:IOErrorEvent):void
{
trace("ioErrorHandler: " + event);
}
{...}
I always get an IO error that reads
Code:
Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.
I can't debug it with the embedded debugger because I get the "nice" sandbox violation thing and I did the whole crossdomain.xml thing but it ain't working, so screw that and I just test it inside the browser. If I try to load the child locally (see the only commented piece in the code above), I get the same IO error and Im able to trace it says basically it can't find "X:/path_to_htdocs/animations/child.swf?id=1&picture=hello.jpg"
So either way it doesn't work and it'd driving me crazy. What am I doing wrong?
Thanks a lot for your time!!
Passing Parameters...
Hey all,
I'm working on a flash based picture gallery for a fairly specific website. The client submits text and images by way of a form into a database. PHP later renders an XML index of the paths to that data which my SWF file downloads. This works great on a broad level... but every time the player is used, it works the same.
It would be great if I could have a PHP container html file, which would be able to pass parameter or two to my SWF file right off the bat... for instance, and index number... and that would give me a way to customize the player based on it's path in the browser.
So, the question is, can the html/php container pass a parameter (or a few parameters) to an SWF file?
Sorry this was so long - I'm not sure why, but I gave a lot of context this time... :-/
later!
Passing Parameters
Hi all, I'm brand new here.
I'm working on something where I need to define a function on the main timeline and call it through a "enter" button on a remote that changes a channel on a tv. The first 3 number keys on the remote define variables to pass as parameters through the enter key to the function, but I can't get it to work right. My experimental attempts are only on the "3" and "enter" buttons on the remote and on the function in the main timeline. Any help would be greatly appreciated.
Passing Parameters
Hi board,
{Flash MX 2004 Pro}
ActionScript Code:
myMovieClip_mc.onPress = foo(true);function foo(state:Boolean) { // Do something}
The above does not work. Infact the function is not even called.
How can I pass parameters to such functions.
I dont wanna do the following:
ActionScript Code:
myMovieClip_mc.onPress = function(true) { // Do something}
Thanks in advance,
Cruiser
Passing Parameters..?
Check out this code:
on (release) {
getURL("javascript:openNewWindow(My.swf',New window,'height=600,width=800,toolbar=no,scrollbars =yes,resizable=yes,fullscreen=no') ");
}
everything here is fine. It opens finely.
But...
i want to pass parameters where if i click a button in html page My.swf should open a particular scene called 'Scene 2' rather than scene 1.
i tried
on (release) {
getURL("javascript:openNewWindow(My.swf?myparams=S cene 1,'New window','height=600,width=800,toolbar=no,scrollbar s=yes,resizable=yes,fullscreen=no') ");
}
but its not working
so any idea for this or if it has to be done by you, how would you do it?
Pls Help
Thanks in advance
Passing Parameters
Hi, I know this is a basic question:
I've set a param name and value in the Object tag of my HTML:
<param name="oneOn" value="true">
I'd like Flash to read this and do something:
if (oneOn == "true") {
oneMC._alpha = 100;
}
When I run the movie, oneMC is still 0% alpha. Am I missing something/doing things the wrong way? How can I get Flash to recognize this parameter?
Passing Parameters
Hi board,
{Flash MX 2004 Pro}
ActionScript Code:
myMovieClip_mc.onPress = foo(true);function foo(state:Boolean) { // Do something}
The above does not work. Infact the function is not even called.
How can I pass parameters to such functions.
I dont wanna do the following:
ActionScript Code:
myMovieClip_mc.onPress = function(true) { // Do something}
Thanks in advance,
Cruiser
Passing Parameters..?
Check out this code:
on (release) {
getURL("javascript:openNewWindow(My.swf',New window,'height=600,width=800,toolbar=no,scrollbars =yes,resizable=yes,fullscreen=no') ");
}
everything here is fine. It opens finely.
But...
i want to pass parameters where if i click a button in html page My.swf should open a particular scene called 'Scene 2' rather than scene 1.
i tried
on (release) {
getURL("javascript:openNewWindow(My.swf?myparams=S cene 1,'New window','height=600,width=800,toolbar=no,scrollbar s=yes,resizable=yes,fullscreen=no') ");
}
but its not working
so any idea for this or if it has to be done by you, how would you do it?
Pls Help
Thanks in advance
Passing Parameters
I need to pass a parameter to a movie clip that I am loading.
I think my options are probably
this.loadMovie("myMovie.swf?myVar=22")
or in onLoadInit setting the variable directly there
_mc.myVar = 22;
Which method is best ?
Passing Parameters To .exe Or .bat
Hi
Can flash MX standalone player (.exe) send parameters to an .exe or batch file ? I mean here flash alone and not with another third party software like Flash pro or Flash jester or.....
Thanx
Passing Parameters..?
Check out this code:
on (release) {
getURL("javascriptpenNewWindow(My.swf',New window,'height=600,width=800,toolbar=no,scrollbars =yes,resizable=yes,fullscreen=no') ");
}
everything here is fine. It opens finely.
But...
i want to pass parameters where if i click a button in html page My.swf should open a particular scene called 'Scene 2' rather than scene 1.
i tried
on (release) {
getURL("javascriptpenNewWindow(My.swf?myparams=Scene 1,'New window','height=600,width=800,toolbar=no,scrollbar s=yes,resizable=yes,fullscreen=no') ");
}
but its not working
so any idea for this or if it has to be done by you, how would you do it?
Pls Help
Thanks in advance
Passing Parameters From Dreamweaver
I've got a Flash navigation bar in a dreamweaver 40 page web site. I want to make the name of page that the user is on a different color, but I don't want ot make 40 different Flash files. It seems to me that I should be able to pass a variable from Dreamweaver to Flash so a simple actionscript can change the color of the button, but I can't figure out how to make it work. I thought the parameters option in Dreamweaver would do it, but Flash doesn't seem to recognize the variable.
Does anyone know how to pass variables from an HTML file to Flash, and make Flash recognize them?
Passing Parameters From HTML
Just wanted to know if anyone can tell me how to pass general parameters from HTML to dynamically alter the embedded .swf. Specifically, I want to be able to have the movie pick up a color parameter and use that to change the background color in the movie. This would only have to occur at initialization.
Passing Parameters To Functions?
hey guys
i am using this script to play a movie in reverse. my question is, how would I go about writing this function only once, and passing the movie clip name of the clip i want to play in reverse as a parameter to the function?
thanks
butt_mc.onRollOut=function(){
revinterval=setInterval(rev,50);
function rev(){
if(butt_mc._currentframe>1){
butt_mc.gotoAndStop(butt_mc._currentframe-1);
}else{
clearInterval(revinterval);
updateAfterEvent();
}
}
}
Passing Parameters From An Embedded .swf?
Is it possible to retrieve a value of a parameter in flash through the asp page?
For example: Lets say I have an embedded .swf file and a read only text box on my asp page, I want the user to click button1 or button2 in the flash file and when they do, the text box fills with "One" or "Two" respectively, is this possible?
Keep in mind that the text box is not part of the .swf file, it's on the html page.
Please tell me there's a way to do this!
Passing Parameters Using FlashVar
Hi there
I want to pass parameters in html as
Code:
<param name="FlashVars" value="xmlFile=/directory/123.xml&auto=Y&redirect=
www.yourlisten.com&after=Y&pop=Y">
and i have code in flash like...
PHP Code:
var dd:Sound = new Sound();if(eval("soundfile")){ dd.loadSound(soundfile, true); dd.stop();}xx = bar._width;orginal_width = bar._width;_root.soundbtndis._visible = false;_root.soundbtndis.disabled = true;this.onEnterFrame = function() { t1 = int(dd.duration/1000/60); t1 = t1+" : "+int((dd.duration/1000-(t1*60))); ddf = int((dd.duration-dd.position)/1000/60); elapsed_sec = int((((dd.duration-dd.position)/1000/60)-ddf)*60); if (elapsed_sec<10) { elapsed_sec = "0"+elapsed_sec; } if (ddf<10) { ddf = "0"+ddf; } if (_root.stpd) { elapsed = _root.t1; } else { elapsed = ddf+" : "+elapsed_sec; } //mo=dd.position/1000 //elapsed = vol = dd.getVolume()+" %"; dur = dd.duration; pos = dd.position; per = (pos/dur)*100; m = (pos/dur)*100; bar._width = (m*xx)/100; drag._x = _root.bar._width+_root.bar._x; //drag._y = 136; if (stpd) { xx = 0; } else { xx = orginal_width; } // function keys if (Key.isDown(67)) { pauseit(); } if (Key.isDown(88)) { playit(); } if (Key.isDown(86)) { stopit(); } //************************************** };_root.shorba.art = "Artist :"+dd.id3.artist;_root.shorba.song = "Title :"+dd.id3.songname;_root.shorba.setMask(_root.loo7);_root.information.setMask(_root.infomask);
where and what code to be added in this script so that all above parameters will pass in html... pl. help
vimal
|