Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How can I create a triggering method for Flash?

Posted on 2007-11-13
10
Medium Priority
?
186 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 2000 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
Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

 
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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
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 is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses

705 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