ActionScript 3.0 :: XML - Using Outside Event Function - Use The Information That GotList Provides Outside Of GotList Itself?
Jul 20, 2010
I'm having a major issue with my XML.. I want to load it up and then be able to use it elsewhere outside the function that is called by the loader.. but so far haven't had any luck on this whole thing. I've tried static, global, etc. Even did a return within the "gotList(evt:Event);" function... so how do I use the information that gotList provides outside of gotList itself? Full code is below.
1021: Duplicate function definition function onComplete1(event:Event):void { 1021: Duplicate function definition function stopSound1(event:MouseEvent):void { 1021: Duplicate function definition function backSound1(event:MouseEvent):void {
codes i used:
Code: var thereReq:URLRequest = new URLRequest("SOUNDS/how.mp3"); var there:Sound = new Sound(); var thereControl:SoundChannel = new SoundChannel();
Everything is brilliant, object loads on the stage, changes product photos but when I click addtocart btn it should trace me info about current photo and it traces just first object loaded into the stage. I am fresh to AS3 and I am bit confused with this one. I have atttached class file to this post.
I need to pass along a string with my FileReference, or provide that string as an argument when an event fires. To be clear, it really annoys me that AS3 doesn't allow you to pass parameters on events.Right now, I've extended the FileReference class to include an additional variable. I'm trying to get this to compile, but it won't compile; I think I don't know how to import this class correctly. If you can tell me how to import this class correctly so that I no longer get Error: Type was not found or was not a compile-time constant at compile time that would be great.
This is the extended FileReference class: import flash.net.FileReference; public class SxmFR extends FileReference {
Is it possible to access the type of object being interacted with so I can create a new instance of the same object? So for example in the code below I have the movieclip myItem. After it's clicked it is removed from stage and then moved to the inventory. When I click on it there, is it possible to create a new instance of mcItemToDuplicate using the event information parameters? (while allowing myItem to be where it is).
My code looks something like this:
public function moveclip() { var myItem:mcItemToDuplicate = new mcItemToDuplicate(); stage.addChild(myItem);
I load image - and need its width and height in global variables, i dont know the image width and high that will be loaded; does enyone can explain me why it get NaN NaN or 0 0 or how can I retrieve this information outside from function loadComplete()?
I have a web page with a couple of Flash Input TextFields. When I press a button on my web page, I am using javascript (jQuery) to get all the values from the text fields and checkboxes etc on the page.
In order to get a value out of my Flash TextField, I understand that I have to use the ExternalInterface API. I am using ActionScript 3.0 and Flash CS4.
In the flash IDE, I have a layer with just the textbox instance and another layer 'actions', which has all the actionscript.
As soon as I put: import flash.external.ExternalInterface
in my code, then the textfields full functionality does not seem to work on the webpage.
I assumed what I had to do was something like:
import flash.external.ExternalInterface; ExternalInterface.addCallback("getFlashFieldText", getText); function getText():String { return myTextField.text; }
then I thought that perhaps I had to call a javascript function to return the textfields value like so:
function getText():void { var word:String = myTextField.text; ExternalInterface.call("alert", word); }
but nothing is working, and I think it is strange that the textfields functionality (some letters being styled) does not work as soon as I import the ExternalInterface class. I have tried putting the ActionScript 'actions' layer in a package, but it didn't help. As you can probably tell I am new to Flash and Actionscript, and I would be very greatful if someone could point me in the right direction.
I am trying to send some information to a javascript function on the same html page as the swf file is in. I used the tutorial here on Kirupa but for same way it doesnt work.
I'm kinda noobish when it comes to getting information from XML information sent to my flash file from the socket server. OK so for example the server sends me this:
[Code]...
I want to get the name of the user and the X and Y position! Is there a way I can get this information without a load of fuss from functions and other junk remember im kinda noobish.
I want to build a program built around my pc specs. Is there a way to access such information as how much ram I have or how much cpu usage is being consumed, etc.?
I'm moving on to my next massive programming project and I'm trying to decide whether I should code it in as 2.0 or 3.0. I came across the new click event model in 3.0. Right now it's looking like a pain in the butt to me. So now I have to make a function and add it as an event listener? what the hell? What's the benefit? I understand stuff like this makes AS a more complete language but it's kinda annoying.
I have some mouseclick event, and within the function that handles this event there's a combobox appearing. after the combobox appeared, I want to be directed to another listevent which is triggered when there's a change in the selection, but, I also want to pass the previous mouseclick event for there is some information in that event that I want to use within the listevent handling function.
As I understand, you cannot pass parameters along to eventhandlers, so I was wondering what is the best way to operate in this case. I've read you can make custom events, but never saw an event passed as a parameter, and was wondering if that's even possible.
I have a question about making a function for two different kinds of event. It's not critical but I would like to reduce my lines of code and just be more efficient. Basically I have a button on the stage called "Enter". I also want the user to have the option of hitting the enter button. I don't have a problem making these two separate handlers for these events (i.e. one handler for the KeyboardEvent and one handler for the MouseEvent):
I need to return to my original function after capturing an event (downloading something) with another function. The original function needs to return a value, which depends on the downloaded data. So, I'd like to pause original function for the time needed for the download and the eventhandler function to complete it's work, and resume it afterwards.
The obvious way is to set a flag value (both the original function and the eventhandler are within the same class) and make the original function check it until the eventhandler function changes the flag. But that would be wasteful, and my AS is slow enough already:) [other parts of the application utilise some heavy graphics]. Is there another way? Like an event that gets captured "in the middle" of the function? Or some other form of flow control?
so today my question is how can we have 1 function triggered by both a Timer event and a Mouse event? 'm trying to avoid having to re-write/re-name a function just because I also have a Mouse event that triggers it and not just a Timer event.
Issue:
I have a addThis bubble fade in with icons on a button rollover, the addThis bubble will fade out after the timer is finished, but I also have a close button in that bubble which needs to use the same function that the timer uses. (want to avoid writing 2 exactly alike functions)
I'm hoping this there is an easy workaround for this like event:null or something.[code]./...
Forgive me for this stupid noob question but I want to call a function (loadList) that originally gets triggered after a mouseevent from another function (addToXML) that does not have an event.
The loadList function takes info from a XML var, sticks it into an array which then gets loaded into a tile list and that is working fine.
The addToXML function when called adds elements to the XML var after which I want to call the first function with the event parameter so it refreshes the items in the tile list.
I know it can do this by creating a new array and loading that into the tile list in the addToXML function, but it be much simpler to just recall the function.
but all the event constants I have tried give me error messges like "1061: Call to a possibly undefined method addEventListener through a reference with static type Function."
i have a password game where users need to select the correct 3 buttons to progress to the next stage. The 3 buttons that need to be selected are: pwd_btn1, pwd_btn2,pwd_btn3. After, the user must click on "submit_btn" to verify if they have chosen the correct buttons. So far everything works fine. So what i would like to happen is that once the 3 buttons are selected, and before the submit_btn is clicked, a function is triggered that will apply a glow effect to the submit_btn, indicating to the user to click on it.[code]
there are 2 functions in my code that dispatch a TweenEvent. each function dispatches the same tween and adds the same TweenEvent.MOTION_FINISH event listener. however, the event listening function must act according to which function dispatched the event. is it possible to get the function of the event dispatcher from the event listener? i could use a flag to make this work if there are no other elegant solutions.
I am trying to build a simple application. The first phase is selecting to upload a file from the user desktop or from the site's gallery.
The question is if the user chose to upload from the gallery, say, go to an PHP page gallery, choose a photo and then redirected to the Flash app. How would you trigger the Flash up to know there was an image chosen and it should load it?
Does PHP send a variable or create an XML based on a choice and pass it via Flash variable, or does it need JavaScript to tell Flash that if the Flash var is not empty run this function?
If you solved it right, a message pops up telling you "Well done" (or something in Dutch).You can close the message with a left-click.Now i want it to close with "esc" too (for the troubled users not realising you can just click).[code]...
Is there a way to get the handler(s) function(s) of an event listener?
I'm trying to find a way to remove them without knowing what they are.
For example:
ActionScript Code: if (mc.hasEventListener(MouseEvent.CLICK)){ // this object has a MouseEvent.CLICK listener mc.removeEventListener(MouseEvent.CLICK, null ); }
Instead of null, I was hoping to find some function that retrieves the handler function.
Does anyone know how to call a function setup to accept an event argument without triggering it through the event?
Example... I have a button with a CLICK event. When you click on the button, the associated function is executed. Now say I want to call that function from within another function. Is there a way to "send" the event information manually?
Right now I have the CLICK function simply call another function that would then be available to be called from any other location. Below is a code example of what I am trying to accomplish.
Code: Select allbutton.addEventListener(MouseEvent.CLICK, doButtonClick); function doButtonClick(e:MouseEvent):void {