Solved

How can I create a triggering method for Flash?

Posted on 2007-11-13
10
184 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

 
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

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

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

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
The viewer will learn how to count occurrences of each item in an array.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

628 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