pass FileReference between two flash movies - apache-flex

I have an html page with a flash object that provides video chat using stratus.
I want to enable file sharing from a different UI on the same html page.
I want to use the same stratus connection to send the file.
Is it possible to create a small flash object that will present a browse button and let the user choose a file and then pass the FileReference or file details to the stratus object to send it?
Thanks

If the two SWFs are on the same page, you should be able to the LocalConnection API to allow two way communication between the two movies.
I have not directly tried this approach for passing a FileReference object, but it is worth noting that there is a filesize restriction of 40K when using LocalConnection.send() - you may be able to get around this by serialising your FileReference object first and sending it over in chunks.

Related

Implementing back-forward in a Flex application

I'm responsible for a Flex application which shows cards/tiles. A click on each card sends a request to the server and then the Flex app renders new cards from the data returned from the server.
Now I need to add a back-forward functionality, so that after several clicks on cards, I will be able to return to the previous requests. As I understand it, I just need to save some kind of a stack of URLs which were sent to the server.
The need is for regular back-forward, so that if I'm viewing card X, then click back and then click on a different tile, I can drop card X from my data structure and forget it.
What data structure would you recommend using? Any examples?
Thanks.
Use SWFAddress and simply use the browser's back/forward functionality. Here's a video tutorial to get you started.

Create dynamic PDF in Flex

Trying to understand from a high-level how this would be accomplished.
Use case:
Flash application embedded in HTML used to create Certificates (just an example).
User enters a bunch of data into a form (Name, Address, What certificate is for, etc.).
User clicks a button which causes the application to create a Certificate in PDF form, with the form data displayed in a format that I define with a bunch of different images).
Ideally, Flex could use the browsers functionality to prompt the user with "What would you like to do with this document, 'Download', 'Open'. So it would function just like clicking on a link to a PDF document inside of a web page.
I already have the form and everything, its just a matter of how I create a PDF from that data. Is there a certain function that can take the current screen and create a PDF image of it? Or is there a certain library for creating PDFs? If anyone can point me in the right direction it would be much appreciated.
There is a AS3 PDF generator library called AlivePDF and can be found here.
Purepdf
is another actionscript library for creating Pdf file.

Client side images in Flex

I am developing an application that includes JPG and TIFF image size validation.
The backend is done is done in PHP. I am wondering if there is anyway to
validate the minimum width and height of those images in Flex or if they have to
be uploaded to PHP and validated there.
Thank you in advance for any assistance,
Orville
In Flash Player 10 the application can gain direct access to data on the client's machine. The new API methods are FileReference.load() and save(); you'll want to use load() to access the file off the user's machine and examine its properties. Details here:
http://livedocs.adobe.com/flex/3/langref/flash/net/FileReference.html#load()
After the FileReference dispatches its complete event, the "data" property will be populated with a ByteArray of the file's contents. If you can find or write suitable libraries for JPEG and TIFF files then you should be able to examine the dimensions.
For Flash Player 9 and earlier, FileReference is limited to upload() and download().
Assuming you're talking about client-side validation, you could always load the image to an object in flex and test the width and height of the loaded image object manually.
However, this should be done in addition to server-side checking if this limit is important, as client-side checks can be circumvented by crafty users.

Performing function on node click in tree and then showing results in text box

I have a tree object which is bound to an XML list. The XML list contains a name for the type of code I have written (e.g. IM client) and also a path to the file where I have some code.
When the user selects a node's child in the tree, I want to load the file from the path of the selected node's child and then show the text in a text box.
How can I go about this? Is it possible without a server side language?
Thanks
All the relevant files are sitting on the server (e.g. code samples). I don't need to get anything from the user's PC.
You need to use HTTPService or a similar object to make a call to your server and when loading is complete you can display it.
Flash is really restrictive on fetching files from the user's computer. To get around this, I have an application running on the user's computer that acts as the middle man between my Flex app and the files on the computer.
Edit: If you want to load files that you have on the server, then you would need something on the server side to relay that information back to your flex app. Flash runs in the browser, on the client-side, therefore it really doesn't have knowledge of where it actually lives.
Though, since you have those file paths, could you just put a relative path from the root of your server on the end of your domain name to find the files?
http://domain.com/path/file.jpg
It's hard to give a solution without knowing the XML data structure. However, a good place to start is to listen to the tree's change event. You can then get the selectedItem from the tree and that should be the XML node which was clicked.
You say you should have a path to the file at this point, so it's just a matter of loading the file with a request using the URLLoader class.

flex - check image dimensions before upload using filereference

In my Flex application, I use a FileReferenceList that the user can populate with multiple files using fileList.browse() before upload.
I check each file's size and use fileList[i].upload() to upload to my server, this works fine.
I have a suspicion that this is not possible, but before upload I would like to convert each FileReference into an Image in order to check it lies within certain dimension tolerances.
I realise I can do this server side, but ideally I would like the check to appear on both client and server. Can anyone offer any help?
Thanks!
Take a look at this post at the Yahoo! Flash Blog. Flash 10 lets you work with images locally. They give a nice example with code of how you can process FileReference objects, specifically image files.

Resources