Solved

Flash5 communicating with program

Posted on 2001-06-30
14
269 Views
Last Modified: 2008-02-01
I have Flash 5, and I have built some software in Borland's Delphi.  I am using the ActiveX component to run my .swf file.

I want to be able to read a person's name from the database and give it to the .swf file and have it just repeat an effect on it, like it glowing in and out.

I can get the data fine.  I have not done anything with Flash and would appreciate a tutorial on how to do this.  I have read through the basic tutorials and help, so I am somewhat familiar with Flash.

In Delphi I have an event called "OnFSCommand".  If I go into Flash it has an Action called FSCommand.  I am guessing that I can use this somehow to pass it the name and use it.

Maybe it would be simpler if someone just made a simple flash file so that I can see how it was done, rather than trying to explain everything.  Just tell me what parameter I need to send and I can do that part of it.
0
Comment
Question by:perkley
  • 5
  • 5
  • 3
  • +1
14 Comments
 
LVL 3

Expert Comment

by:jeffbeasley
Comment Utility
If you can wait till Monday I can create you a sample file; or I can give you some minor assistance here
You would start by importing the variable from Flash and wrighting to a text field you do this by
creating an asp file or cf file or even txt file  that gives you the var being drawn from the database as follows
some_var=some name
where as some_var is your variable name and "some name" is your string being passed

you would then type this action script in your
loadVariables("document.asp",some_var);
this should load your var you can test to see if loaded typing
trace(some_var);
this will show up in an output window when you execute a publishing of flash within flash by pressing  
<ctrl> and <enter>

you would then create  a text field with you text tool
and go to the panel were you adjust text from static text to dynamic text or input text
choose dynamic text
this will give you the option of giving the text a variable name (in the panel)
you would name it some_var
the string "some name" will show up as text in your text field when published

you can then mess with creating glowing animations by creating various colors and layers of text

This is fairly simple when you are able to import your var
the problem with using fscommands is that it has problems executing on the Mac  

the key to getting your var to load is to create a program that will execute a page that loads your var into a web page thats code and output is equal to some_var=some name when viewed outside the programs environment

Hope this makes since I don't have my flash manuals or flash in front of me to be more precise
I can expand later if you need more assistance;
however this should point you in the right direction
(if it makes since ;)
Good Luck
Jeff
0
 

Author Comment

by:perkley
Comment Utility
I can wait till Monday, however the FSCommands will work for me as it is a program that is Windows based and is only used by us, it is not given out to others.  I can customize it to my machine.

The name will change quite often, so I need to be able to just give it the new name and it shows it with the effects.

Thanks for any help you can give.  How would I do it with the FSCommand?
0
 
LVL 5

Expert Comment

by:stef4s
Comment Utility
the fscommand is used to communicate from flash to host. You get other methods for the control to send messages from the host to flash. What is your email I can send you some documentation on these methods.
0
 
LVL 5

Expert Comment

by:stef4s
Comment Utility
for example to set a variable in the flash movie you use the following (VB code) movie.setvariable(varname,value)
0
 
LVL 6

Expert Comment

by:Jaymol
Comment Utility
This is sooooooo simple.

I created a movie clip with a button on it.  I added the following actionscript to the "MouseUp" event of the button....

    onClipEvent (mouseUp) {
        fscommand ("MessageDlg", "This is a test message box, run from within Delphi.");
    }

Then, I put this code within the "OnFSCommand" event of the Delphi app....

      If Command='MessageDlg' then
        MessageDlg(Args, mtInformation, [mbOk], 0);

I ran the application, clicked the button and got the message box.  That's all there is to it.  You handle the different events yourself within the "OnFSCommand" event.

If you need more help, give me a shout.

John.
0
 
LVL 6

Expert Comment

by:Jaymol
Comment Utility
Oh yeah, have a look at this link too.  VERY useful for the Flash/Delphi programmer.

    http://www.delphipages.com/news/detaildocs.cfm?ID=38


John.
0
 
LVL 6

Expert Comment

by:Jaymol
Comment Utility
Oops...I actually added the actionscript to the "OnRelease" event of the button, not "OnMouseUp".  (There is no mouseUp for buttons!)

John.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 6

Expert Comment

by:Jaymol
Comment Utility
Sorry to keep posting to the same question when there's not been any other comments, but I though you may like this link too....

        http://www.geocities.com/jaymol/

There's a component called "TFlashPlayer" which is just a wrapper for the ActiveX component.  The only difference to using this rather than importing the ActiveX directly is that this component will install & register the ActiveX on the target machine if it is not presently installed.

Enjoy,

John.
0
 
LVL 5

Expert Comment

by:stef4s
Comment Utility
Jaymol, do you add any functionality to this OCX
0
 
LVL 5

Expert Comment

by:stef4s
Comment Utility
Because I am busy with my own ax wrapper that will allow me to stream video with flash
0
 

Author Comment

by:perkley
Comment Utility
Thank you for all the comments.  I have a question for Jaymol though.  You are using Flash to reproduce a Delphi dialog box.  What I want to do though is have Delphi give Flash some text (a person's name specifically).  How does Flash know when to start the repeated effect over with the new text.  I need to somehow tell my Flash File to go and run the OnFSCommand again and start at Frame 0 again.  This may be simple, but I have never done much with this stuff so any help would be appreciated.
0
 
LVL 5

Expert Comment

by:stef4s
Comment Utility
you need the active x methods

here is an example for some of them



GetVariable
 4, 5   4, 5
  Syntax  GetVariable(varName)
 
       
  Description  Returns the value of the Flash variable specified by varName. Returns null if the variable does not exist. The argument type is string.
 
       
  Example  var firstName = movie.GetVariable("FirstName");

var radioButtonValue = movie.GetVariable("/Form/RadioButton:Value");




       
    GotoFrame 2,3,4, 5   2,3,4, 5
  Syntax  GotoFrame(frameNumber)
 
       
  Description  Activates the frame number specified by frameNumber in the current movie. If the data for a requested frame is not yet available, the player goes to the last frame available and stops, causing unexpected results during playback. Use the PercentLoaded() method to determine if enough of the movie is available to execute the GotoFrame() method.
The argument frameNumber is zero-based; that is, frameNumber is 0 in the first frame of the movie, 1 for the second frame, and so on. This differs from the Goto action within Flash, which begins at 1. The argument type is integer.
 

       
  Example  movie.GotoFrame(24);



       
    IsPlaying 2,3,4, 5   2
  Syntax  IsPlaying()
 
       
  Description  Returns true if the movie is currently playing.
 
       
  Example  if (movie.IsPlaying()) { alert("movie is playing"); }



       
    IsPlaying NA   3,4, 5
  Syntax  IsPlaying()
 
       
  Description  Returns true if the movie is currently playing.
 
       
  Example  if (movie.IsPlaying()) { alert("movie is playing"); }


I can email you the full documentation


 
0
 
LVL 6

Accepted Solution

by:
Jaymol earned 100 total points
Comment Utility
Here's what I did....

Let's do layer1 first.
------------------------------------------
Frame 1, empty keyframe.
Frame 2, this actionscript...

if (MyName=="") {
    gotoAndPlay (1);
}

Frame 3, this actionscript...

TextField1 = MyName;
stop ();


Now let's do layer2.
------------------------------------------
Frames 1 & 2 are blank.
Frame 3 has a Dynamic Text Field (named TextField1).

That's the flash movie done.

In Delphi, I have a form with the Shockwave component on it.  This component has been set to Embed:=True and Movie:=That one above.

In the FormCreate event, I have this following line of code...

  ShockwaveFlash1.SetVariable('MyName', 'John');

Run it!

Delphi tells Flash the contents of "MyName", and Flash is saying "until you tell me, I ain't moving!".  It gets the name and continues to play, setting the TextField1 variable to the name specified by Delphi.  (In this case, John.)

Hope this clears things up a bit.  If there's anything else, just ask away.

Stef: I've just wrapped the OCX with the installation code.  That's all I've done.  Let's face it, the OCX itself is not pretty in Delphi, but there's ways and means around the nasty stuff it does/doesn't do.  Have a look at DelphiPages.com as there's a few articles in there about some of the problems and how to get round them.

Thanks,

John.
0
 

Author Comment

by:perkley
Comment Utility
Thanks for your help.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
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.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

772 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

10 Experts available now in Live!

Get 1:1 Help Now