Solved

passing variables in to flash using case statements

Posted on 2003-12-04
7
475 Views
Last Modified: 2008-03-10
Does any one know how to pass a variable into flash from a html file using javascript cases.  e.g:

I am trying to use:

<SCRIPT FOR="MediaPlayer"
        EVENT="ScriptCommand(sType, sParam)"
        LANGUAGE="JScript">
 switch (sParam)
    {
    case "Slide1":
       //variable i am trying to pass 'name = XXX' where slides is the id/name of the flash file.
       break;

    case "Slide2":
       //variable i am trying to pass 'name = YYY' where slides is the id/name of the flash file.
       break;       
                   
    }
</SCRIPT>


so as each different case statement is matched a different value for the variable is passed.

Does any one know the script i can use to do this?  I need an example.

Thanx
0
Comment
Question by:Jyontex
  • 4
  • 3
7 Comments
 
LVL 27

Accepted Solution

by:
negatyve earned 100 total points
ID: 9877570
<SCRIPT FOR="MediaPlayer"
        EVENT="ScriptCommand(sType, sParam)"
        LANGUAGE="JScript">
switch (sParam)
{
      case "Slide1":
            var myvariable = "hello"
            break;
      case "Slide2":
            var myvariable = "byebye"
            break;      
}
var IE = navigator.appName.indexOf("Microsoft") != -1;
var targetMovie = IE ? window.slides : window.document.slides;
targetMovie.SetVariable("variable_name", myvariable);
</SCRIPT>
0
 

Author Comment

by:Jyontex
ID: 9881303
Hi this looks like the kind of thing i want but still cannt get it to work.

i am using:

<HEAD>
<TITLE>Test</TITLE>

</HEAD>
<BODY bgColor=#FFFFFF text=#ffffff>
<SCRIPT FOR="MediaPlayer" EVENT="MarkerHit(lMarkerNum)" LANGUAGE="JScript">
{
      MediaPlayer.Play();
}
</SCRIPT>
<SCRIPT FOR="MediaPlayer"
        EVENT="ScriptCommand(sType, sParam)"
        LANGUAGE="JScript">
 switch (sParam)
    {
    case "Slide1":
       var frameName = "a1"
       break;

    case "Slide2":
       var frameName = "b1"
       break;

    case "Slide3":
       var frameName = "c1"
       break;

var IE = navigator.appName.indexOf("Microsoft") != -1;
var targetMovie = IE ? window.Slides : window.document.Slides;
targetMovie.SetVariable("frameName", frameName);       
                   
    }
</SCRIPT>
<table width="800" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><OBJECT ID="MediaPlayer" WIDTH=320 HEIGHT=240
    CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
    STANDBY="Loading Windows Media Player components..."
    TYPE="application/x-oleobject" align="middle" vspace="0">
        <PARAM NAME="FileName" VALUE="test.wmv">
        <PARAM NAME="ShowControls" VALUE=true>
        <PARAM NAME="DisplaySize" VALUE=0>
        <PARAM NAME="AutoStart" VALUE=true>
        <EMBED TYPE="application/x-mplayer2"
    SRC="test.wmv"
    WIDTH=320
    HEIGHT=240 align="middle" vspace="0"> </EMBED> </OBJECT></td>
  </tr>
  <tr>
    <td><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" width="80" height="20" align="top" id="Slides">
        <param name=movie value="test.swf">
        <param name=quality value=high>
        <embed src="test.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" align="top">
        </embed> </object></td>
  </tr>
</table>
</BODY>
</HTML>

and a simple dynamic text box in the flash to display the value passed in the parameter.

Can you see where i'm going wrong?
0
 
LVL 27

Expert Comment

by:negatyve
ID: 9881473
What does this script do?

<SCRIPT FOR="MediaPlayer"
        EVENT="ScriptCommand(sType, sParam)"
        LANGUAGE="JScript">
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:Jyontex
ID: 9881599
its picking up variables passed from the wmv and passing it to the switch statement.  (that works), so you can ignore that bit.  Only having problems passing new variables to the flash fom there.
0
 
LVL 27

Expert Comment

by:negatyve
ID: 9881812
Before I make any test, if you try:

switch (sParam)
{
      case "Slide1":
            var frameName = "a1"
            break;

      case "Slide2":
            var frameName = "b1"
            break;

      case "Slide3":
            var frameName = "c1"
            break;
}
alert(frameName)

what happens?
0
 

Author Comment

by:Jyontex
ID: 9881890
it doesnt work.  the alert needs to be within the case.

and your script works if i use:

<SCRIPT FOR="MediaPlayer"
        EVENT="ScriptCommand(sType, sParam)"
        LANGUAGE="JScript">
 switch (sParam)
    {
    case "Slide1":
       var frameName = "a1"
var IE = navigator.appName.indexOf("Microsoft") != -1;
var targetMovie = IE ? window.Slides : window.document.Slides;
targetMovie.SetVariable("frameName", frameName);
       break;

    case "Slide2":
       var frameName = "b1"
var IE = navigator.appName.indexOf("Microsoft") != -1;
var targetMovie = IE ? window.Slides : window.document.Slides;
targetMovie.SetVariable("frameName", frameName);
       break;

    case "Slide3":
       var frameName = "c1"
var IE = navigator.appName.indexOf("Microsoft") != -1;
var targetMovie = IE ? window.Slides : window.document.Slides;
targetMovie.SetVariable("frameName", frameName);
       break;
             
    }
</SCRIPT>

can this be simplified?
0
 

Author Comment

by:Jyontex
ID: 9881900
Its ok....i put the script into a simple function.

Thanx for your help
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now