pq Flash >

Tech n mad stuff for mads like me ;) Here i will share tech problems i came across and how i solved em !

About Me

My photo
Think a lot but do less.Life full of downs and less ups but ups are stronger than downs.

Sunday, March 14, 2010

Simple View Stack Event Management In Flex

In the course of exploration into world of flex some of our novice developers face so many problems which results flex for them is a complex stuff ! But its not, flex is simple simpler than development of AS2 Flash application.

So Now we are gonna discuss a common problem many of us face
Event management between view stack component and main mxml class.
So the scenario is like we have a ViewStack in main application and it has a child component i.e FirstView (com.nectflow.eventest.views.FirstView)

Here is the eventTest.mxml










code here:



And the component FirstView (com/nectflow/eventest/FirstView.mxml)










Our task is to create an event in FirstView , dispatch it and listen it from main class i.e. eventTest ! Then we will do the reverse. create an event in main and do some changes in public variables in FirstView.


Now Lets create an event in FirstView
we have added a listener to TextInput named ChildText of FirstView called textUpdated()
here is the modified childText






and here is the function definition

private function textUpdated():void
{
typedText = childText.text;

}


Next comes the core part - dispatching an event
First Declare events as Static Metadata tags





so here we have registered a custom event named "typed", and what we got is














A event for the view element of the view stack in main mxml i.e. eventTest.mxml

now lets dispatch the typed event and make it work !
here is the code :

dispatchEvent(new Event('typed'));


this need following import to be included

import flash.events.*;



So lets dispatch this event in the TextInput change listener we have created last time so that the event will be dispatched whenever the TextInput text is changed

public var typedText:String = "";
private function textUpdated():void
{
typedText = childText.text;

//the event "typed" is dispatched here
dispatchEvent(new Event('typed'));
}


and now lets add a listener in main to listen to this dispatched event

/// trigger of fv
public function updateTypedText():void
{
status.text = "stack child said :"+fv.typedText;
}

private function textUpdated():void

{

}




mxml code



as
typedText is a static text component of FirstView we can acess it directly from main as fv.typedText
similarly lets use another public function of FirstView

private function textUpdated():void
{

fv.parentListener(parentText.text);
}




Above we have successfully dispatched an event and listened to it in first phase and then we called a public function from dispatcher object to listener object
now showing complete code
Main MXML ( src/eventTest.mxml)



And the component FirstView (src/com/nectflow/eventest/FirstView.mxml)



Hope this post gave you some clear concepts

please post comments

for better blog view and attachments switch to
http://sites.google.com/site/nectflowblog/home/eventtest




Thursday, October 29, 2009

Using open source flex sdk to compile flex apps in linux

I installed Fedora core 9 on the mission of trying to be open :)
The major challenge was how to do stuffs in linux which were in xp
Some how i installed tomcat,mysql and managed to run php apps
the next chellenge was flex !
thanks to Adobe for making flex sdk open source which allows user to compile as3 and flex
but it has its limitation
free flex sdk donot support advanced features like graphs and pie charts :(
so for simple applications and learning purpose its the best !

I downloaded latest flex sdk (version 4) from here and after a lots of google and struggle i found a simple way to compile and run flex apps.

extract the files to somewhere like your documents folder and give it a simple name(flex_sdk_4)

prepare the commands
export FLEX_SDK_HOME=/home/piyush/development/flex_sdk_4 (set this sdk home path)

and

alias mxmlc='/usr/lib/jvm/jre-1.6.0/bin/java -jar "$FLEX_SDK_HOME/lib/mxmlc.jar" +flexlib="$FLEX_SDK_HOME/frameworks" "$@"'

here /usr/lib/jvm/jre-1.6.0/bin/java is the path to java command, just find it in /usr/lib/jvm

and after you edited the paths run the above commands one by one
now we are all set to compile mxml apps :)

to check type mxmlc and if it shows following message then congrats


Loading configuration file /home/piyush/development/flex_sdk_4/frameworks/flex-config.xml
Adobe Flex Compiler (mxmlc)
Version 4.0.0 build 11120
Copyright (c) 2004-2009 Adobe Systems, Inc. All rights reserved.

Error: a target file must be specified

Use 'mxmlc -help' for information about using the command line.


be smart and go through help !!

or

to compile an mxml file give this command

mxmlc test.mxml

here text.mxml contains ur flex/mxml code !!

If u dont got java support then mxmlc will show errors ...

enjoy !!

related links :
http://asantoso.wordpress.com/2008/05/18/flex-3-sdk-command-line-development-with-example-on-linux/

Wednesday, September 2, 2009

Migrating your Flash/Flex Application From local/http server to https server

While working with a medical application I faced a lot of annoying situations. But somehow I managed to survive and completed the assigned work with good impression and lots of career defining lessons and this Https issue is one of them.

Its like this
We completed a flex application with alpha testing in a remote server using IP Adress. It was working well and our QA team gave it a green light. But suddenly client wanted to make it secure as they were planning to make a beta release of the application.

They set up a https server and when we uploaded the application it shown us an error like
"This page contains both secure and ..." Well our application is ofcourse not a spam !! and we dont distribute viruses or malwares through our page !!!

After a little google we found out its because of any http link in the application.
So we checked all the http requests and changed them to relative path i.e. placed the backend pages in child directory so that all the requests would automatically be https.
but still same dialogue!!

Then we thought there might be some server setting issue, so we kept running the application pressing "ok" button. and it worked as it was in https in firefox browser but IE started showing its color !! It simply blocked our application in the client end!!
It blocked all http requests giving us hundreds of runtime error by flash player debugger!!
So we got another more issue !!

After a long google with complete frustration i found a lifesaving post which discussed briefly about that bug in IE(even in the latest version 8).
IE says its a security feature but its actually a bug .. he he

What I simply understood is : ie keeps a quick cache whatever the server page header may be(no-cache or blank). And in https secure connections caching is like banned ! so requests with no cache header are kept in cache braking security code and blocking all such server requests with no-cache header(which is deafult).

So they suggested to use a Pragma header as blank .
php code:
header("Pragma: ");


So we included this code to all the requests and we solved the IE bug !
Now pressing "ok" in IE works well and accept result of all the requests.

But What to do with secure non-secure dialogue ??
And I found it !
I checked the html page in which the flex app was embeded got some http links
we didn't checked it as the page was auto generated by Flex Builder 3

The interesting thing in the auto generated page was this :

!--
Smart developers always View Source.

This application was built using Adobe Flex, an open source framework
for building rich Internet applications that get delivered via the
Flash Player or to desktops via Adobe AIR.

Learn more about Flex at http://flex.org
// --



hmm.. smart generators !! :)
but am i ?

So we removed all http reference in the source page but still the dialougs !! :(
I also removed ExpressInstall feature from the page but still same...

Then what i did is ran the swf directly in the browser and it worked with no error !!
so I got confident !!
Then i straight used swfObject and error gone !!
So I solved both the issues
But I am still not sure why swfobject worked ?



Thursday, August 27, 2009

simple ip tracking facility by gmail

This is a simple feature by gmail !
using this you can know which IP logged in to ur gmail account on which date.
to checkout this
scroll down to the extreme end of ur gmail home page and there you will find
"Last account activity: " and in the end there is a link for "Details"
as in the screen shot below

click on "Details" for list of some more last login details like below




Friday, May 22, 2009

Problem with setting status of gtalk to currently playing song in Windows Media Player ?

Its not that hard! So that you need me to invite to your home for a dinner to solve this ;)

While installing Gtalk , you install a plug-in for Windows Media Player(version 9+) in the background, which allows you to set the song details in Gtalk status message.


If you still couldn't solved your problem
here are the steps.

1. Go to Windows Media Player Plug-ins tab from Tools>Options...
or Tools>Plug-ins>Options...

2.There from the category list select "Background and" there you will find a plugin named "Google Talk music Plugin" if its not checked check it and you are done !
3. Do Apply>Ok and you are all set
4.Restart both Gtalk and Windows Media Player, play a song and login to Gtalk and there set your status to "Show current music track" and gtalk will give a confirmation as in the screenshot below:



if you find any problem then comment me, and dont hesitate to comment if i helped you :)

~ With Love Piyush

Tuesday, December 2, 2008

CS3 to CS4

Flash CS4 :: added features

3D transformation : We can show 2d objects in 3d space without using any external libraries or game engines !!

Procedural modeling with Deco and Spray Brush : Quickly create kaleidoscope-like effects and apply fills using the Deco tool, or randomly spray symbols across any defined area using the Spray Brush. Coool !!

Authoring for Adobe AIR : No need to install AIR separately !!

Inverse kinematics with the Bones tool : Specially for cool chain-like animation effects programmatically !!

Motion editor : for more control over timelines and key frames.

H.264 support : specially to show mp4 files on video playback componant !! i am not sure

Friday, June 13, 2008

Why AS3 ??

ActionScript 3.0 is designed to address the following goals:

  • Safety: The language supports type safety so developers can write unambiguous, easily maintainable code.
  • Simplicity: The language is intuitive enough for developers to be able to read and write programs without constantly consulting a reference manual.
  • Performance: The language enables developers to write complex programs that perform efficiently and responsively.
  • Compatibility: The language provides a short backward and forward compatibility path and a significant overlap with industry standards. ActionScript 3.0 is a dialect of ECMAScript which formalizes the features of ActionScript 2.0, adds the capabilities of ECMAScript for XML (E4X), and unifies the language into a coherent whole.