Solved

How can I create a triggering method for Flash?

Posted on 2007-11-13
10
179 Views
Last Modified: 2010-04-03
Hello group,

I'm not a Flash programmer so I will appreciate it if you help me to learn this. I just want to expeirment how it would be possible to create a custom method for a flash?

Let's say I have a widget or gadget made by flash. Now, I want to take an action when the flash is loaded int an HTML file. My question: "How can I can trigger or at least show a message when a flash  (embedded in HTML) is loaded ?

Regards,
ak
0
Comment
Question by:akohan
  • 5
  • 5
10 Comments
 
LVL 23

Accepted Solution

by:
Zeffer earned 500 total points
ID: 20276463
you can do this from inside the flash..eg..
this.onLoad = function(){
//show a message
}
this could then be made to go away with a timer..lot's of options here.
It would show the message whenever the flash is first loaded
Z
0
 

Author Comment

by:akohan
ID: 20282957


Hi Zeffer,

Thanks for your response. Considering this that I'm not a Flash programmer/designer:

This is what I did but when I goto Control -> Test Movie ,   I don't see the message while loading. Would you please give me some advice?

this.Onload = function()
{
      Alert.show("Hello, Flash object is loaded!");
      
}


Then I tried:


this.Onload = function()
{
      _root.createTextField("atext",1,200,200,300,100);
      atext.multiline = true;
      atext.wordWrap = true;
      atext.border = false;
      
      myformat = new TextFormat();
      myformat.color = 0xff0000;
      
      mytext.text = "Hello World";
      mytext.setTextFormat(myformat);
      
}


but as soon as I put the latter code out side the onLoad event it shows up on stage!

Any comments?



Thanks,
ak


0
 
LVL 23

Expert Comment

by:Zeffer
ID: 20287203
well the Alert.show approach is only going to happen if you have a javaScript function in the html..and you call it from flash ..eg..javascruipt in the html

function myMovie_DoFSCommand(command, args) {
      if (command == "message") {
            alert(args);
      }
}

in flash..
this.onLoad = function(){
fscommand("message", "Hello World.");
}

the textfield example has flaws in the code ..try this



Hi Zeffer,

Thanks for your response. Considering this that I'm not a Flash programmer/designer:

This is what I did but when I goto Control -> Test Movie ,   I don't see the message while loading. Would you please give me some advice?

this.Onload = function()
{
      Alert.show("Hello, Flash object is loaded!");
     
}


Then I tried:


this.Onload = function()
{
      _root.createTextField("atext",1,200,200,300,100);
      atext.multiline = true;
      atext.wordWrap = true;
      atext.border = false;
     
      myformat = new TextFormat();
      myformat.color = 0xff0000;
     
      atext.text = "Hello World"; // you had this named mytext
      atext.setTextFormat(myformat); // same
     
}
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 23

Expert Comment

by:Zeffer
ID: 20287210
sorry pasted part of the Q :)

well the Alert.show approach is only going to happen if you have a javaScript function in the html..and you call it from flash ..eg..javascruipt in the html

function myMovie_DoFSCommand(command, args) {
      if (command == "message") {
            alert(args);
      }
}

in flash..
this.onLoad = function(){
fscommand("message", "Hello World.");
}

the textfield example has flaws in the code ..try this..

this.Onload = function()
{
      _root.createTextField("atext",1,200,200,300,100);
      atext.multiline = true;
      atext.wordWrap = true;
      atext.border = false;
     
      myformat = new TextFormat();
      myformat.color = 0xff0000;
     
      atext.text = "Hello World"; // you had this named mytext
      atext.setTextFormat(myformat); // same
     
}

Z
0
 

Author Comment

by:akohan
ID: 20291511



Hi Thanks for your response.

Yes I have been impatient since had to take care of this and still wasn't working. Ok regarding your code.  I did try it and this is what I did but when I test in Flash during runtime nothing comes up as text.

this.Onload = function()
{

      _root.createTextField("mytext",1,200,200,400,300);
      mytext.multiline = true;
      mytext.wordWrap = true;
      mytext.border = false;
      
      myformat = new TextFormat();
      myformat.color = 0xff0000;
      myformat.bullet = false;
      myformat.underline = true;
      
      mytext.text = "Hello World";
      mytext.setTextFormat(myformat);

}

I was expecting to see this text (Hello, World ) in a window but it comes up blank.

Any suggestions?

Thanks.
ak
0
 
LVL 23

Expert Comment

by:Zeffer
ID: 20291753
Have just tested that and it works fine..?..perhaps we could take a new approach entirely..
put the message on a frame before your main content
this will display when loaded..then move to  the content frame with a timer.

http://www.redpearl.co.nz/ee/timer.zip

Z
0
 

Author Comment

by:akohan
ID: 20292222

Hi again,

Sorry if I keep asking questions.Ok, yes it works I tried in Dreamweaver Flash 8 environment but one thing I need to ask you is:

If I put the OnLoad() method can I call something before the whole flash thing happens?

my major problem is that when I use OnLoad event nothing happens.


Regards,
ak
0
 

Author Comment

by:akohan
ID: 20292312

Hi Z,

I did add an OnLoad() event to your code. This is what it does:

I'm assuming as Flash component being loaded into html it will send a request to my server. when  I run it on my system (locally) it works but when I put it on server it won't send the request.

Here goes the code:


this.Onload = function()
{

      var sender = new LoadVars();
      sender.x="xxx";
      sender.send("http://www.myserver.com/cgi-bin/asp/tagx/_/BS3628LK8U?2=http%3A//gadget/", "", "post");
}


stop();


function wait() {
        trace("interval called");
        clearInterval( thisInterval );
            _root.gotoAndStop(10);
}
var thisInterval;
thisInterval = setInterval(wait, 5000 );

Looking forward to have your suggestions.

Regards,
ak


 

0
 
LVL 23

Expert Comment

by:Zeffer
ID: 20293182
>>If I put the OnLoad() method can I call something before the whole flash thing happens?<<
no..the onLoad will trigger once the movie is fully loaded..not before.
try taking your 'sender' code out of the onLoad function
The player will step through all the code when the swf has loaded and it
doesn't really need the function to make it work.
It can't be called again unless you returned to the frame it's on.
bit wierd it works locally but not online.

Z
0
 

Author Comment

by:akohan
ID: 20537170

Hi Zeffer.

The main issue was caused by the server since there everything was being cached and for security reason the server side software block some activities.

Thanks indeed for your help.

Regards,
ak
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SharePoint 2013 Searchbox Branding 11 77
contractual requirements for app hosting 3 104
Easy responsive table out of existing table 28 55
how to build a intranet site 8 37
Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The goal of the tutorial is to teach the user how to how to record live broadcast.

773 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