A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: SWF address problem

  1. #1
    Junior Member
    Join Date
    Aug 2004
    Posts
    5

    SWF address problem

    Hello - First, I am not really a programmer, more like an intermediate level timeline actionscripter. 2nd, I am new to SWFAddress, so this question may be quite elementary to some people.

    I successfully set up a project that enables the browser history buttons from within flash using SWFAddress and SWFObject. What I can't seem to be able to do, is have some buttons add their behaviour to the browser history list and some that don't. This seems like it should be trivial, but I am stumped.

    First I created an extremely simple project, just to get the back button working. I am using SWFAddress 2.1 and SWFObject 1.5 and I am testing this on a mac in both Safari and FireFox.

    NOTE: I know that the current version of SWFObject is 2, but I couldn't find much in the way of tutorials on this, so I couldn't get it working.

    Here is the actionscript 3 code for this first attempt:
    Code:
    stop();
    
    import SWFAddress;
    import SWFAddressEvent;
    
    btnPage1.addEventListener(MouseEvent.CLICK, turnPage1);
    btnPage2.addEventListener(MouseEvent.CLICK, turnPage2);
    btnPage3.addEventListener(MouseEvent.CLICK, turnPage3);
    
    function turnPage1(e:MouseEvent):void {
    	SWFAddress.setValue("page 1");
    }
    
    function turnPage2(e:MouseEvent):void {
    	SWFAddress.setValue("page 2");
    }
    
    function turnPage3(e:MouseEvent):void {
    	SWFAddress.setValue("page 3");
    }
    
    SWFAddress.addEventListener(SWFAddressEvent.CHANGE, handleSWFAddress);
    
    function handleSWFAddress(e:SWFAddressEvent) {
    	copyText.text = SWFAddress.getValue();
    }
    This worked great. So I then wanted to make one of the buttons perform an action but not add its behaviour to the history list. So I just changed the code for button 2 to be:
    Code:
    function turnPage2(e:MouseEvent):void {
    	copyText.text ="page 2";
    }
    All this does is omit the setValue for button 2 and instead do its behaviour (putting some text into a text field) directly. There was a problem with this. Keep in mind that the following problem happens in the Flash IDE, so I know it is not a javaScript issue. When I test this, if I hit, say, button 3 (textfield updates, back button becomes enabled), then button 2 (textfield updates, button 2 does NOT become added to the history list - so far so good), then button 3 again, this second time that I hit button 3, nothing happens. The textfield does not update, nothing.

    This is my guess as to what's happening: I hit button 3 the first time, and it sets a value, a change event is dispatched and the listener gets the value. I hit button 2 and no value gets set (so far so good). I hit button 3 again and it sets the same value that was set previously, and since it is the same value, it does not register as a change, and so no change event gets dispatched. Or maybe this is due to some other issue, but this is my best guess.

    An example of this can be seen at: http://www.fisheyemedia.net/test

    As I write this, it occurs to me that I could append some incrementing variable to the string value that gets set (so that every time it is a unique value) and then strip it out at the other end when the getValue happens, but that seems like a clumsy way to handle it. How do people do this?

    BTW - not sure if upgrading to swfObject 2 would help or not - if that is the solution, then I am going to need some help setting it up right.

    So, I haven't found much in the way of documentation or tutorials on swfAddress, so I am appealing to this forum for help. Anyone?
    Last edited by fisheye999; 09-05-2008 at 07:29 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center