ActionScript 2.0 :: Sending "for()" Variable To Function.
Jun 17, 2010
The title is vague but what I want to do is, send a variable that's created inside a for to a function that's called within the for...
I use the following example to give certain actions to buttons or mc's, for example I call my buttons all btn1, btn2, btn3 etc. then call a for loop to cycle through them, but I still want to figure out a way to call the for variable for(i,b,z...etc) inside itself into a function...
What's happening is that the *z* inside the function always equals the maximum value of the for loop + 1, no matter how I've done it, in this case if I do trace(z); it will return undefined, if I do trace(_root.z) it will return 4.
I have two classes one called 'LoaderSwf.as' which is used to talk to all the other classes im using. I also have a 'GeneralTimer.as' which works fine from a stand alone 'GeneralTimer.swf' file. What I am trying to do is send a value of 10ms to the 'GeneralTimer.as' which will then run the timer and when complete send a value back. But for simplicity im trying to send a 10 ms value to trace("tick") and trace("tock").
I keep getting error "TypeError: Error #1034: Type Coercion failed: Cannot convert 10 to GeneralTimer." this is according to Adobe "1034 Variables cannot be native." What does that mean for starters?
Here's my code:
in LoaderSwf.as
Code: var w:Number = 10; GeneralTimer(w); in GeneralTimer.as
[Code].....
so as you can see I want to send the number 10 to be used in the GeneralTimer. I am sure I have used this before (in CS3) and its worked but am now using CS4
I have two classes one called 'LoaderSwf.as' which is used to talk to all the other classes im using. I also have a 'GeneralTimer.as' which works fine from a stand alone GeneralTimer.swf' file. What I am trying to do is send a value of 10ms to the GeneralTimer.as' which will then run the timer and when complete send a value back. But for simplicity im trying to send a ms value to trace("tick") and trace("tock").I keep getting error "TypeError: Error #1034: Type Coercion failed: Cannot convert 10 to GeneralTimer." this is according to Adobe "1034 Variables cannot be native." What does that mean for starters?Here's my code:in LoaderSwf.as
I have a flash file where I can pass xml from file : script type="text/javascript"> var flashvars = {}; flashvars.xmlSource = "XML.xml"; ... /script>
Can I send xml from php in varible to flash example: $xml = "?xml version="1.0 ..."; script type="text/javascript"> var flashvars = {}; flashvars.xmlSource = ?php echo $xml; ?>; ... /script>
Code: save_all.onRelease = function(){ for(var n=0;n!=cArr.length;n++){ ///some other stuff
[Code].....
I want the php file to be sent the variable and loaded as many times as the length of the array cArr... lets say cArr is 16 pockets long... only the 16n from textsave array gets sent to flash via the lv5.specialVariable... I'd like the script to run 16 times, each time with the value of n getting sent as the specialVariable..
I am trying to post the score that the player achieves to a database. I have set a web page "highScores.aspx" which gets a query string variable "webScore" and puts it in a database. This works fine as tested in a browser.
The problem I have is getting the correct information into the query string variable. I have:
where the text in question is located inside "form" (which is a movie clip). I've been following this tutorial [URL] and while not really relevant, it's got me further than anything else. The problem with this tutorial is it relies on the user entering text, whereas I am just displaying out the score in some dynamic text. This means that in output I get the following error:
[Code]....
I should point out, I do not need to read the text to get the value as it is stored in a variable beforehand, I just display it to the player via some dynamic text, but I'm not sure how to use this to my advantage.
for example i have 2 swf file a.swf and b.swf can a.swf sending variable to b.swf? can a.swf control some movieclip in b.swf? in a case a.swf is loadMovie to b.swf...
This is going to sound like a really stupid query, but I'm totally new to this. I can grab the contents of a single variable from a php page and display it in a field in Flash, which works great. I do this using the echo command and placing an & before the variable to be sent. e.g. echo "&textData=$contentSenttoFlash";
When I embed the flash movie into the php page though, the echo command also prints that variable to the screen, so that it appears both in the flash movie (which I want), and again as a text string on the page (which I don't want). Is there any way to prevent the php printing the variable as well whilst using this method?
I'd like to enable the user to enter several parameters within the flash plugin. These influence the flash movie. The flash file itself works perfectly fine. But now I also want to access and process these parameters on a Javascript function.
I tried the external.Interface and navigatetoURL method but couldnt achieve the required result. (The 'link' between flash and javascript doesn't seem to work...)
So how / which is the best way to transfer parameters from AS3 to Javascript on the server ?
I have an issue on sending variable from flash to HTML. For example I have a main.html page with flash Object. In this flash there is a search text field. When you enter some text and click on Go button, It will go to search.html page and it should show the text value in this page.
I'm using a preloader SWF to load my content SWF and XML file, and when the COMPLETE event fires I'm using the following code to send my XML data to the content SWF -ActionScript Code:evt.target.content.sendXML(XMLData);I then have a sendXML function in the content SWF that picks up the data.This works - but I can't access XMLData right away (it's null if I trace it). But if I set up a timer with a tiny delay which then checks XMLData, the information is there.It seems to be a bit of a dumb way to do things. Has anoyone else got a better solution or a way that will allow access to the variable right away?
I've had success doing this by just adding the variable to the end of the embedded SWF URL (.../mymovie.swf?variable=value), but what I need is the ability to send the swf variables when certain links are clicked, without the page refreshing.
I'm guessing this has to be done somehow with a javascript onClick function.
I've looked into using externalInterface, but it seems overly complicated for this application.
I want to find out whether my swf was loaded locally or from another swf. For this purpose I have declared a variable 'parentType' in my fla. var parentType:String = String(parent); There is a function in the document class that determines whether swf was loaded locally or from another swf. The name of the function in the document class is 'externalOrInternal'. The varaible parentType is passed as a parameter to the function externalOrInternal externalOrInternal(parentType); The name of the document class is Main. In the constructor of Main I have the function pollResize() (the use of this function is to listen for the resizing event. That part of the code is not shown in the snippet given below).
[Code]...
I see that swfParentType is has value insde the function externalOrInternal. My doubt is why null is traced inside the function pollResize. Why is it not [object Stage] as inside externalOrInternal. Due to this I am not able proceed further with the stage resizing event.What needs to be done so that proper value is traced in the function pollResize.
I have an input box with a variable name. When the user enters some text and presses a button that variable is sent to a php file using the GET method. Then the info is put into a database. When I checked my database, I found that a load of styling html tags has been included. I want for my input text box to have styled text, but I don't want that styling /html tags to be sent to the php file. I know I could use strip_tags in php to get rid of the html tags, but surely there's a way of not sending the tags at all, just the text content of my variable?
How can i send variables from flash to a php page. I want it to be done in the standalone flash player and not the browser and also I don't want the browser to pop up like when we use getURL. Is there any possible way of doing it. It seems I cannot find way to sned variable to php except using the following method which opens a browser.[code]...
I have some simple function in Flex in which I would like to send one of my variables to all the components used in my app... The problem is that there is lots of components in my app, and I'm not sure how to reference to my component's id... Basically, is there an easier way to do this;
private function preloadStuff():void{ // populating of bulkLoader var var preloaderItemsList:XMLListCollection = new XMLListCollection(preloaderItems.children()); var item:XML;
[URL]. I am trying to make the code into a function so that I can place it in a frame instead of attaching it to a mc.
onClipEvent(data){ this.sendSent.text = "MESSAGE WAS SENT"; this.textEmail.text = "EMAIL"; this.textSubject.text = "SUBJECT"; this.textName.text = "NAME"; this.textMessage.text = "MESSAGE"; } on (release) { // send variables in form movieclip (the textfields) // to email PHP page which will send the mail this._parent.form.loadVariables("email.php", "POST"); }
I am using a form I made in flash to send variables to a MySql Database. Code for form: trace(email1.text+", "+question1.text+", "+check1.selected); status1.text send1.onPress = function () { status1.text = "sending.."; var ld:LoadVars = new LoadVars (); [Code] .....
All of the tutorials I have found re: local connections seem to outline 1 swf sending info & the other swf receiving. Is it possible to have two swfs using exactly the same action script for their variables to effect each other? I've got two swfs with 2 different sets of buttons who react the same way on roll over. Once a button is selected it remains highlighted. I want to know if I can have a button in swf 1 highlighted but un-highlight when a button in swf 2 is selected?
I'm trying to make a small email capture form, but I'm having trouble getting Flash to pass the email address to the server. I've since given up trying to use getURL and I'm simply trying to trace the variable instead. The form consists of a text box w/ instance name "email_txt" and a button w/ instance name "btnSignUp." the actionscript is placed on the button.
I am sending a name of a function via parameters to another function. This allows more usage of a single function. However, the button commands work every-so-often. The message appears everytime with no problem.
Code: _root.msgReveal("This is just a random message. Click the ok button to close.", false, true, false, false, _level0.msgHide(), false);
But there will be hundreds of these objects, so I'd like to have each one call a global function, so I tried code for each button like this:
on (release) { GlobalFunctionName(this._name); }
But for some reason, the value being passed is null. (Although if I switch "this._name" for a string, that works correctly.) Question: How can a drone object pass its name to a central function? Should I be using "on (release)" or should I use a listener within each object instead? Also, is it best to make them Buttons or Graphics or Movie Clips since there will be so many of them?
In my code there's a function that shows an image on the screen (or loads the image and shows a progress bar). This function is called by clicking on a thumbnail, and it uses a parameter [e.target.name] refering to the property "name" of the thumbnail clicked, which is an integer (or I believe so). The thumbnails are placed inside the cointaner_mc MovieClip.
Code: container_mc.addEventListener(MouseEvent.CLICK, clickThumb); function clickThumb(e:MouseEvent):void{ if (my_full_images[e.target.name] == undefined){[code]...
but I want to call this function by clicking on a button, which would need to pass another type of parameter, in this case, a variable which refers to the number of the image displayed on the screen plus one.I tried this:
Code: clickThumb(image_num + 1); But it doesn't work, I get the following error:
1067: Implicit coercion of a value of type Number to an unrelated type flash.events:MouseEvent.
How could I call the function clickThumb and make it use "image_num + 1" instead of "e.target.name" ?
Could I dispatch the event (MouseEvent.CLICK, clickThumb), passing this value "image_num + 1" ?
I have set up a functioning xml image gallery with simple left and right arrows. I am now trying to make it an infinite looping gallery swapping the first and last sprites in an array and + and - their x value so they "physically" move in the photos container.
All of this works fine except for the actual loaded image. The xml data, name description, and image to be loaded are set up in one function and all the data is added to the sPhotoSprite (sprite) in this function. This All works perfectly..
A second function is then called to add the current image:
var currentImage:Loader = Loader(evt.target.loader); then currentSprite.addChild(currentImage); (the sprite is declared at the start)
The problem being that the sPhotosSprite is no longer reference-able. I've tried :
But this only ever returns the final sprite. The same problem of only ever returning the final sprite occurs when I try setting an external sprite to hold the current sprite in it and then referencing it in the second function.
how you would target a function's local variable through a concatenated variable string.For example:
var txt = "Hello World"; function testing(msg) { var test1 = msg;[code].........
I'd expect the trace to be "Hello World" but rather is given "undefined". So if variables created outside functions are created on the main timeline, where are local function variables created and how would you access them?