Solved

How can I create a triggering method for Flash?

Posted on 2007-11-13
10
177 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
 
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Read about why website design really matters in today's demanding market.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

758 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

21 Experts available now in Live!

Get 1:1 Help Now