Not signed in (Sign In)

Vanilla 1.0.3 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthoralchris
    • CommentTimeMar 8th 2008
     
    I need help to now how to best add a variable for onPress. My current code for my buttons are below.

    I want to use swfobject to control the active state for my flash navigation on a xhtml base website. I thought I just need to put so.addVariable("b1.onPress", "press"); but that didn't work I am missing something. Any help is appreciated.



    b1.onRollOver = over;
    b1.onRollOut = out;
    b1.onPress = press;
    b1.onRelease = release;
    b1.buttText.buttonText.text = "PORTFOLIO";

    function over() {
    if (_global.selectedBtn != this) {
    this.gotoAndPlay(2);
    }
    }

    function out() {
    if (_global.selectedBtn != this) {
    this.gotoAndPlay(7);

    }
    }

    function press() {
    if (_global.selectedBtn != this) {
    this.gotoAndPlay(17);
    }
    }

    function release() {
    if (_global.selectedBtn != this) { // this prevents you from setting it twice, which is unnecessary (especially if you have an animation playing)
    this._parent._global.selectedBtn.gotoAndPlay(7);
    this.gotoAndPlay(18);
    _global.selectedBtn = this;
    }
    }
    • CommentAuthorAran
    • CommentTimeMar 8th 2008
     
    Variables you pass to a swf from SWFObject are used only at creation time of the swf. It basically adds the variable(s) to the main timeline of your swf on frame 1. Do a Google search on "flashvars", as this is what SWFObject is actually adding for you by implementing so.addVariable().

    You cannot modify button functions via so.addVariable(). If you want true browser to flash communication, you will need to use something like ExternalInterface. See more here http://blog.deconcept.com/swfobject/forum/discussion/499/flash-to-browser-communication-with-swfobject/#Item_1

    That being said, if you are completely reloading your HTML page on a menu item click, you can just pass a certain var value to flash to say which menu item should be highlighted etc.

    if you passed something like : so.addVariable("section", "portfolio") into your swf (the value of section changes based on the page), you could then add some logic in flash to go to a certain frame/ change text etc.

    Does this make sense?

    Aran