Omar,
This is what I do, this works for me but do with it what you want.
This is not the exact code but a general sequence...

On the loading of the site I have an initialization of listeners and included is the following...

SWFAddress.addEventListener(SWFAddressEvent.CHANGE, navigateToSection);


After all intro animations are complete ( if you have any) I get the address
from the address bar and set a variable...
//var for the website address/ title

var _siteTitle:String = "Comany Name | 123 Main St. MyTown, NJ 08234";
var initial:String;
var _string:String;

initial = SWFAddress.getValue();

Then I'll send the current value to SWFAddress...

SWFAddress.setValue(initial);

Now my function that is associated with swfaddress events handles everything

private function navigateToSection(e:SWFAddressEvent):void {
                        //set section from swfaddress event
                        _string = e.value;
                        
                        var addrString:String = _string.split("/").join("");

//Here I have a switch to show whatever section the user wants to view
                
                        switch (_string) {
                                        
                                case "/About/" :
                                        
                                        //Load the About section
//The following will concat the variable for the site title and add the current section and update the page title

                                        SWFAddress.setTitle(_siteTitle+" | 
"+addrString);
                                        //call proper functions
                                        dispatchEvent(new Event("open 
section"));
                                        OR
you could call a specific function to display the About section contents
                                        break;

                                case "/Contact/" :
                                        
                                        //Load the Contact section
//The following will concat the variable for the site title and add the current section and update the page title

                                        SWFAddress.setTitle(_siteTitle+" | 
"+addrString);
                                        //call proper functions
                                        dispatchEvent(new Event("open 
section"));
                                        OR
you could call a specific function to display the About section contents
                                        break;
                                        //more cases below for each section of 
your site
                        }
}

You could have an eventListener for the dispatched event (above) to listen for "open section" then that function could load data using the _string info as a value to determine what to load.. I'm only on my first cup of coffee so if this doesn't make any sense let me know.


-Gerry
www.thespikeranch.com


On Jun 13, 2009, at 8:04 AM, Omar Fouad wrote:

Hi,

I've been involved into a project where the client required the deep linking
feature.
The project is built with pure AS3 embedding symbols from a SWF library
file, ZendAMF php and mysql,
Now the question is how can I sync the address with the current state of my flash movie. All I know is that I have two things to do, which are to change the flash state then change the address, and at the other hand to listen for
address changes and change the state based on that change.

What sounded logical to me is to change the link address directly when
changing the state so that when the address changes, the listener handler
logic brings the right flash state... like this:

HomeButton.addEventListener(MouseEvent.CLICK, onButtonClick);
SWFAddress.addEventListner(SWFAddressEvent.CHANGE, onAddressChange);

private function onButtonClick(e:MouseEvent):void {
   //changes the address here to "www.mysite.com/#/home
}
private function  onAddressChange(e:SWFAddressEvent):void {
//reads the address, understands that refers to home, and changes the
state to home.
}

I don't know if this is the right thing to do in this case. I just need some
advice because things are too much buggy.

Cordially.



--
Omar M. Fouad - Adobe Flashâ„¢ Platform Developer
www.omar-fouad.net
Cellular: (+20) 1011.88.534
Mail: m...@omar-fouad.net

This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by, any other party. If you are not an
intended recipient then please promptly delete this e-mail and any
attachment and all copies and inform the sender. Thank you.
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to