Wednesday, July 23, 2008

Issues

Sending Variables to PHP from Flash

To send variables from flash to php all you have to do is use the function

loadVariablesNum("url", 0, "POST");
this will load all the variables in the flash file to php.
They can be retrieved in php using $_POST[].
For example, if I have variables firstName, and lastName in the flash file, I can use the loadVariablesNum function to send the variables.
In php,
i use the code
$firstname = $_POST['firstName'];
$lastname = $_POST['lastName'];

This has been very helpful for me while using the twitter api which does not have a crossdomain.xml file. I had to post the variables from flash to php and then make the api calls.
It is also useful while accessing a database. I can have a nice flash application that takes in variables from flash, send them to a mysql database via php.


Could not send variables from flash to the server

I found out that I could not load or send variables to the server because crossdomain.xml file was missing in the server. It should be placed in the root directory. A simple crossdomain.xml file that gives access to all the websites looks like this:


< ? xml version="1.0"?>
< ! DOCTYPE cross-domain-policy SYSTEM " http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<>
< domain="*">
< / cross-domain-policy >


The above code can be copied into a text editor. It should be saved as crossdomain.xml in the root level.

(I will be updating this post as and when I come across more problems and manage to find a way around them, so that the next time I stumble upon them, I don't have to spend hours on google.)


Password Field in Flash

I had to take the username and password in a flash application. For that I created two input text fields (usernameTextfield , passwordTextfield). To ensure that the password does not show as plain text all you need to do is include the following code in the frame's actionscript
passwordTextfield.password = true;


Scrollbar for Dynamic Textfield in Flash CS3

Inserting a scroll bar for a dynamic text field which is not big enough to fit all your text is very easy in Flash CS3.
Create a dynamic text field.
At the bottom of the workspace set the properties of the textfield to multiline.
Go to Window-> Components on your file menubar. This should pop up a new components window.
Click on User Interface to expand it.
Find the UIScrollBar option and click and drag it on to the text field.
Thats it. When the dynamic text field has more text than it can fit, the scroll bar will show up.


1 comment:

Anonymous said...

Sounds great, also, other people can also build on your expertise, they could also comment on your solutions if they found alternative/better ones or to confirm that your solutions work for them. :-)