Question Updating FLASH Variables VB 2008 Express

Askjerry

New member
Joined
Apr 19, 2010
Messages
2
Location
Kyle, TX, USA
Programming Experience
5-10
Just getting started in VB .NET and was making good progress. Got a real head scratcher here.

Made a simple form with the following items...

Shockwave Flash (flash_movie)
Button (Button1)
Label (Label1)

The FLASH movie consists of a single text item (mytext) which I want to change the value of. Currently it has the text "DEFAULT" in it... and I want to click the button and have it say "Hello". If I can get that far... I should be able to do something more complex.

Here is the current VB code... the remarked items all failed... no errors... they just didn't work at all.

VB.NET:
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        flash_movie.Movie = Application.StartupPath() + "\DSP.swf"
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Label1.Text = "Button Clicked"
        'flash_movie.SetVariable("_root.mytext", "Hello")
        'flash_movie.SetVariable("mytext", "Hello")
        'flash_movie.FlashVars = "_root.mytext=hello"
        'flash_movie.FlashVars = ("_root.mytext=hello")

    End Sub
End Class

I created another FLASH movie which was exactly the same except that I created a rectangle, and from within FLASH told it that if clicked to change the text value of "mytext" to "Hello"... it worked flawlessly. So I know the variable is definitely _root.mytext it's just that I can't seem to get to it from VB.NET

Here is the file if you want to download it and try it yourself: http://askjerry.info/files/DSP.swf

I know it's something simple I'm missing... please help! :cool:
Thanks,
Jerry
 
I figured it out!!!

You need to do something when making the FLASH that I simply forgot... you need to define a VARIABLE. Looking at it now it seems so obvious.

So I created the dynamic text box called "mytext" and I was trying to poke text into it via the SetVariable() command... but it didn't have a variable... so the data got passed... but FLASH had no place to put it.

I recreated the DSP.SWF file (flash object) but this time I hit advanced properties and created a variable "the_text" assigned to the dynamic text box. Then... I modified my code like this...

VB.NET:
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        flash_movie.Movie = Application.StartupPath() + "\DSP.swf"
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Label1.Text = "Button Clicked"
        flash_movie.SetVariable("the_text", "Yahoo!")
        Label2.Text = flash_movie.GetVariable("the_text")
    End Sub
End Class

Now I was able to shove the text "Yahoo!" into the variable and it displayed nicely. I also pulled the data back out with the GetVariable() command and popped it into a second label (Lable2) in the VB form.

Both worked flawlessly.

So... in review...

1) Create your FLASH with variables assigned to the dynamic text boxes.
2) Send data with the SetVariable() command
3) Read data with the GetVariable() command

Jerry ;)
 
Back
Top