Actionscript 3 :: Flex's FileReference.save() Can Only Be Called In A User Event Handler

Jul 21, 2010

I need to call FileReference.save() after a web service call has completed, but this method has a restriction: "In Flash Player, you can only call this method successfully in response to a user event (for example, in an event handler for a mouse click or keypress event). Otherwise, calling this method results in Flash Player throwing an Error exception." (from the documentation here)

This restriction is a bit vague. Does it mean that I can only call the FileReference.save() method from within an event handler function that is registered as a listener for certain types of user events? If so then exactly which user events are valid? (Perhaps there's an event that will never be dispatched by user interaction with my application and I could register an event handler function for that event type and make the save() call from within that function?)

My difficulty is that I can't safely call the FileReference.save() method until my web service returns with the data that will be used as the argument of the FileReference.save() method call, so the event that triggers the FileReference.save() call is actually a ResultEvent rather than a user event, and I'm leery of dispatching a new (faux) user event type in order to be able to trigger the FileReference.save() call unless it's definitely a user event that would never be dispatched as a result of actual user interaction with my application.

In a nutshell what I'm doing now is this: I have a function that is registered as a handler for a button click. In this function I make my web service call to fetch data from the server. I also have a result handler function which gets invoked when the web service call completes, and it's in here that I want to call the FileReference.save() method since it's at this point that I know that the data is ready to be saved to a file. But the aforementioned restriction is blocking me from doing this -- I get an error:

Error #2176: Certain actions, such as those that display a pop-up window, may only be invoked upon user interaction, for example by a mouse click or button press.

I've tried many things to get around this such as creating a second mouse click event handler function with the FileReference.save() call within and calling it after a timeout interval (to give the web service time to complete), but I keep running into the same error -- maybe that approach doesn't work since the second function isn't registered as an event listener for the event type used as its argument.

View 3 Replies


Similar Posts:


Actionscript 3 :: Force Program To Wait Until Event Handler Is Called

Apr 3, 2010

I have an AS 3.0 class that loads a JSON file in using a URLRequest.

package {
import flash.display.MovieClip;
import flash.display.Loader;

[Code]....

When the file is finished loading, the mapHandler event makes changes to the class properties, which in turn are accessed using the getMapWidth function. However, if the getMapwidth function gets called before it finishes loading, the program will fail.

How can I make the class wait to accept function calls until after the file is loaded?

View 2 Replies

ActionScript 2.0 :: Referencing Movieclip Event Handler Is Called From When Using Delegate?

Aug 24, 2006

I'm using Delegates in a new project I'm working on to call an event handler in my class with the scope of the class.

I'm having an issue referencing which button is calling this handler. Since all of my buttons are created dynamicly, this is a big problem.

I'm used to using forms and components where I had no problem with this and could reference who was calling the event handler by using - event.target

This doesn't seem to be the case with movieclips though, is there another way to do this?

View 1 Replies

Flex :: Bypass The Save Dialog Box Of FileReference.save?

Jul 6, 2011

Can we Bypass the save dialog box of FileRefernce.save()? If not, then Is there any workaround to save a file from web application in Flex without asking user where to save file?

View 1 Replies

Flex :: Workaround On FileReference.save Dialog Box

Dec 14, 2010

Im still new in Flex and currently working on capturing a flash game into a flv video file. Im using FileReference.save() to write the captured file in the user's system. It is working as of now but not the way I want it to be.Is there a way to bypass or automate the save dialog box when invoking the save() api of fileReference?

View 1 Replies

Flex :: Unhanndled IO Error On FileReference.save()

Mar 4, 2011

I am using a filereference Object to export an excel file from my flex application. I am using fileReference.save() from Flash player 10. I am getting an error if the file i am trying to save is already open. This error is not getting handled even if i put a try catch block. I have tried adding a listener with IOErrorEvent.IO_ERROR. Still the error is happening. This is the Error message i am getting - "Error #2044: Unhandled IOErrorEvent:. text=Error #2038: File I/O Error."

View 1 Replies

Flex :: Flash Player 10 Filereference.save And File Extensions?

Jun 8, 2010

I'm using Filereference.save() to save a XML file. It's working fine with default filename.But is there a way to force a file extension on the saved file? I'm using "untitled.xml" as the default filename, but if the user changes it to say "myfile", it gets saved as "myfile", rather than "myfile.xml".

View 1 Replies

ActionScript 3.0 :: Save Images With My MyProject.as With FileReference.save?

Dec 20, 2010

i have movie clip with Images and button Save and class MyProject.as how save images with my MyProject.as, with help FileReference.save? what to write in code? how code should look like? tell me good people I want to write everything in a separate class

View 3 Replies

ActionScript 3.0 :: Get Rid Of Save Dialog Box In Filereference.save()?

Sep 22, 2010

Is there a way to get rid of the save dialog box in filereference.save()?I want to specify the filename and location rather then letting the user do it.

View 6 Replies

Flex :: Error 1061 Call To Possibly Undefined Method Save Through A Reference With Static Type Flash.net:FileReference

Jun 2, 2011

I want to save XML File using Flex 4 SDK

var fr:FileReference=new FileReference();
fr.save( newXmlRow, 'D:/Sample.xml' );

Error Shows :

1061 "Call to possibly Undefined method save through a reference with static type flash.net:FileReference"

View 2 Replies

Flex :: Overloading Event Handler Possible?

Jan 20, 2010

I want to extend my function to a better design to where I can pass a canvas object into so I don't have to write N functions.. I'm not sure as how to do this properly I've come up with a naive design with a switch but even then if I add another canvas I still need to write new code for the new canvas.

function fadeCanvasOut(event:TimerEvent):void
{
canvas1.alpha -= 0.1;

[code].....

View 2 Replies

Flex :: Event Handler Associated To DataGrid Row?

Jan 16, 2012

I'm loading some images from a database using a PHP script through CodeIgniter, but when I try to add an event handler to do some stuff with these images, Flex compiler is showing me an error:1180: Call to a possibly undefined method cloneCar.Why I can not add an event handler in this context?

<mx:Accordion>
<mx:Form id="menu5" label="Prueba" width="100%" height="100%" backgroundColor="#707070" icon="{roadIcon}">

[code].....

View 1 Replies

Flex :: Event Handler Execution Order?

Jun 23, 2009

I have been trying to understand the way ActionScript's events are implemented, but I'm stuck.I know that AS is single threaded, which means that only one event handler will be executing at a time, and also means that handlers will be executed in a deterministic order*.For example, consider the following code:

1: var x = {executed: false};
2: foo.addEventListener("execute", function(){ x.executed = true; });
3: foo.dispatchEvent(new Event("execute"));

[code].....

View 2 Replies

Flex :: F5 Refresh Event Handler Does Not Work In IE8?

Aug 4, 2010

I have an issue in handling the F5(Refresh) option in IE8 using FLEX. As i got some code by surfing..which is as follows

public function handleKeyDown(event:KeyboardEvent) :void
{
display.text = "Key was pressed: " + event.keyCode;
}
]]>

The main intention of the code is to handle F5(refresh) event. It works fine in Mozilla, GoogleChrome but not in IE8. When i execute the code in IE8 before the event handle by the FLEX the browser is handling the event.

View 1 Replies

Flex :: Passing Along Information On A FileReference Complete Event?

Nov 11, 2009

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 {

[code]........

View 1 Replies

Flex :: Find Out In The Event Handler If The Timer Is Running?

May 20, 2011

How do I access timer.running from inside event handler?

View 1 Replies

Flex :: Add A Click Event Handler To The Vertical Axis Of A BarChart?

Mar 15, 2010

add a click event handler to the vertical axis (or any axis) of a barchart in flex? If I add the handler to the BarChart itself, it looks as though the event doesn't fire unless you click on the actual chart, not the axes.

View 1 Replies

Flex :: Get The Label Of The Selected Radio Button In The Event Handler?

Mar 11, 2011

I have the following codes,

for (i=0; i<answerArray.length; i++) {
var myOptionButton1:spark.components.RadioButton = new spark.components.RadioButton();
myOptionButton1.label = answerArray.getItemAt(i).Answer_Choice;

[code].....

View 2 Replies

Flex :: 3 - Invalidation In Show Event Handler Breaks Lifecycle

Oct 20, 2011

Create a tab navigator (or viewstack, whatever) and add a couple tabs. On your tab add a show event handler. Inside the event handler call invalidateProperties() and invalidateDisplayList() on one of the children of your tab. Put a break point on the childs commitProperties() and updateDisplayList(). You'll notice that the updateDisplayList() gets called before commitProperties() which results in incorrect behaviour.

I noticed this problem when setting a DataGrid's dataprovider from inside the show handler. Setting the dataProvider causes the grid to invalidate both properties and displayList, updateDisplayList() will get called first, then commitProperties() which will result in the grid not updating the rows. It appears the root of the problem is that the show event gets dispatched from within LayoutManagers validateDisplayList() loop, so invalidating a child object from within the show handler results in its updateDisplayList() getting called immediately.

[Code]....

View 1 Replies

Flex :: SOAP Variables In Network Monitor But Not Making It To Event Handler

Aug 13, 2009

I am querying a 3rd party web service and not all the data seems to be making it to the event handler. When I view the request/response in the Network Monitor I see a collection of data objects each containing two string variables (name, url) and two arrays (counts, breakdown). When the result handler receives the data and I view it in debug mode, the collection of data objects each only contains one string variable (name). What happened to the other string var (url) and both arrays (counts, breakdown)? what would cause this since it seems to becoming corrupt before it reaches the event handler but after it is received by the network? Is this most likely an IDE issue?

View 1 Replies

Java :: Create One Event Handler For More Than One Button In Mobile Flex Programming?

Mar 10, 2012

I created a screen(calculator) with bunch of buttons,i can handle button event with one handler.But i want to know that can we do a one handler for all buttons......likein java
we can perform the task of perticular button by like this

if(event.source=="button1")
{
}

[code].....

View 2 Replies

Flex :: Save User Login And Password?

Jul 27, 2010

What's the best way to save user credentials in flex? Local storage doesn't seem like good place for storing confidential data, because it saves information as a plain text.

View 5 Replies

ActionScript 3.0 :: Why OnMetaData Handler Doesn't Be Called When Playing Some .flv

Dec 20, 2011

I am using NetStream to play some .flv files on local disc. My code skeleton is:

public class AdvertisPanel extends MovieClip
{
private var _video:Video;
private var _connection:NetConnection;

[Code].....

I used some .flv files that I download from YouTube to test; and I found that the handler metaDataListener would not be called when playing some .flv files, but some would. Is the problem caused by the video file? Because I may resize the video before play it on the screen, and I really need to know its original width & height.

View 3 Replies

Actionscript 3 :: URLLoader Handler In Child Movie Not Being Called?

Jul 16, 2010

I am writing a flex application that has a MainMovie that loads flex programs (ChildMovie) depending on what the user selects in the MainMovie.

class MainMovie{
private var request:URLRequest = new URLRequest();
public function callPHPfile(param:String, loader:URLLoader,

[code]....

I can see that the callPHPfile function is being executed and received xml data from in httpFox, the problem is that the code in the handlerInChild function is not being executed.

View 1 Replies

Flex :: Create A Single Class For Handling Fault Handler Event For All The Services?

Mar 29, 2011

According to Cairngorm architecture, we always have a fault handler in every command class for each service.How we can create a single Class for handling Fault handler event for all the services.

View 2 Replies

Flex :: Pass Event Handler To Dynamically Created Object Inside ItemRenderer

May 27, 2011

I have a Tree, which has an itemRenderer. On the itemRenderer, driven by the XML conditions, objects are created dynamically and added as a children to nodes. These new objects shall trigger an event handler ( some click events mostly ). How do I pass the event handler to the tree and later to the dynamically created new objects inside itemRendere?

Something like:
<mx:Tree x="534" y="49" newObjectsOnClick="newObjectsOnClickHandler">

View 1 Replies

Actionscript 3 :: Flex 4: Event Listener Created, But Not Being Called?

Sep 13, 2010

I'm trying to call an event I've created in another component. I've added trace() into my methods so I can see what's being called. Everything except for the event listener (myEvent) is being called.

// TestApp.mxml (application)
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"

[Code].....

View 1 Replies

Flex :: Loader Event Complete Function Only Being Called Once

Feb 21, 2011

So, I'm trying to load resources, add them to a dictionary, and have a drawing method search through that dictionary and draw based on certain predicates. I have a function that iterates through an Vector of Strings, calling on an instance of Loader to load them instantiated as a URLRequest.

private function loadImages(urls:Vector.<String>):void
{
var loader:Loader = new Loader();

[Code].....

So the issue is: Only the first images in my Vector are drawing. Upon further inspection, I found that the completeHandler was only being called once (I put a trace in the complete handler to check). However, the Loader is invoking load everytime the loop iterates. I tried instantiating separate loaders for each resource, just to see if it would work, but I had no luck with that. Do I need to make separate loaders and event handlers? Or am I just not using Loader correctly?

View 1 Replies

Flex :: FileReference.load() Not Populating FileReference.data?

Nov 11, 2009

I am trying to use the load method of FileReference object to load the data and use it to display a thumbnail of the selected image.However, after calling fr.load(), fr.data remains null.I'm using Flex Builder 3.0.2 on Windows 7 with Flex SDK 3.4 and Flash Player 10 Debug. If I evaluate fr.load() in Eclipse's watch variables list, I get an error reading "No such variable: load."

View 4 Replies

ActionScript 3.0 :: When The User Clicks The "exit" Button A Class File Is Called To Mark The User Complete In An LMS?

Oct 4, 2010

I have a problem with a dynamic video player that I have created in flash. The video player is "SCORM" compliant so that when the user clicks the "exit" button a class file is called to mark the user complete in an LMS.I have tested the SCORM Code previously and it works with out issue. Usually I have the completion code embedded in an Actions Layer of the movie. This is the first time I have attempted to call the completion status in a class file, I have added a "trace statement" when the movie is tested within flash it runs the trace statement properly, but when uploaded to the LMS environment the course does not complete properly

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved