How to read SCENES via XML into a Flash interface?

  • I've got 3 rooms, with a before and after of each room. (total 6 panos) They are linked together via hotspots + a custom flash interface. I'm planning to have a before and after toggle switch within my Flash interface .... but my flash needs to know which scene is currently loaded to determine which pano to load when the toggle switch is clicked.

    So basically, the short question is .... how do I tell my flash interface which scene in my xml is currently loaded?

    Help! *confused*

    Say "Hi!" on twitter

    3 Mal editiert, zuletzt von mds (4. August 2010 um 21:37)

  • Solution 1:
    Create a plugin with keep=false with an id in it, put this in every scene.

    <plugin name="SceneManager" scenename="kitchenbefore" keep="false" />

    Then let flash read out this variable.

    Solution 2:
    Send variable to flash

    <hotspot onclick="events.setstate("before")"

    then let your interface store the string
    flash as3 (I assume you've loaded krpano in your interface)
    krpano.set("loadphoto", LoadPhoto());
    var currentphoto:String = "" //either before or after

    function LoadPhoto(str:String):void
    {
    currentphoto = str;
    }
    //somewhere else
    function onswtichbuttonclick():void
    {
    if(currentphoto == "before"
    {

    }
    }

  • i've got a before/after toggle switch built within my flash interface (krpano loaded)

    basically i need to know (and this could be elementary) how to read <scene name="entranceAfter" > from my xml into my flash and then send a command from flash to xml

    xml would have 6 scenes:
    <scene name="entranceAfter" >
    <scene name="entranceBefore" >
    etc.

    my flash would need to be something like this:

    Code
    var currentScene = myXMLSceneThatIsCurrentlyLoaded; //<- pulling the currently loaded scene variable from the krpano xml into flash 
    
    
    if (currentScene == entranceAfter)
       {
          loadEntranceBefore(); // <- right here I need to send a command from flash to my xml telling it which scene to load
       }
  • ok .... after doing a little more reading through the documentation i realized that i need to do this:

    //as3
    krpano.get(variable:String):*

    the one remaining question is: how do i format * to be <scene name=" "> ?

    Say "Hi!" on twitter

    Einmal editiert, zuletzt von mds (10. August 2010 um 17:21)

  • Alrighty. Another update.

    in my flash interface i've got:

    ^ this doesn' work with the if statement currently ...
    if i remove the if statement it works ... but i need the conditionals to know which pano to load *confused*

  • update for anyone curious:

    i was never able to figure out how to read in properly the <scene name=" "> attribute so I did it another way. not as clean as i'd like but it works.

    I used 4 different swfs for my before and after toggle.

    1 - beforeActive.swf
    2 - beforeInactive.swf
    3 - afterActive.swf
    4 - afterInactive.swf

    And for each <scene/> I used to <plugins/> (one active and one inactive depending on the pano) The active one had an <action/> attached to it and the inactive one did not.

    Each scene has two of the above mentioned plugins. There is a slight flicker when going from pano to pano ... but that is the trade off by not having it baked into my interface.

    I would still LOVE LOVE LOVE if someone could help me get my variable to read in correctly ... it would be sooo much cleaner with no flicker! I'll post and example soon after client signs off on it! *smile*

  • Hi,

    I think the best way to let your plugin now that the scene has changes is a callback,

    in your plugin you could add a function to krpano, which is callable from xml,
    e.g.
    as3:

    Code
    krpano.set("scenehaschanged", as3_scenehaschanged);
    ...
    function as3_scenehaschanged(currentscene:String):void
    {
     // do anything you want in AS3...
     // currentscene is the parameter that was passed in the xml
    }

    load your plugin in the xml (using preload="true" would be recommend to be sure that the "scenehaschanged" function has added added before first usage, include the <plugin> outside the scenes)

    Code
    <plugin name="yourplugin" url="yourplugin.swf" keep="true" preload="true" />

    then either make a own loadscene action (e.g. "myloadscene") and call your "scenehaschanged" function after loading the scene there,
    e.g.

    Code
    <action name="myloadscene">
      loadscene(%1,null,MERGE,BLEND(1));
      scenehaschanged(%1);
    </action>
    
    
    ...
    myloadscene(scene1);
    ...
    myloadscene(scene2);

    or add a "onxmlcomplete" event in each scene and call there the "scenehaschanged" function,
    e.g.

    Code
    <scene name="scene1">
      <events onxmlcomplete="scenehaschanged(scene1);" />
      ...
    </scene>
    <scene name="scene2">
      <events onxmlcomplete="scenehaschanged(scene2);" />
      ...
     </scene>

    best regards,
    Klaus

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!