Solved

How can I create a triggering method for Flash?

Posted on 2007-11-13
10
182 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP Curl to output a url 7 123
How to use NFS (Network File System) in Asp.net mvc 5? 4 72
CD Rom not playing 13 90
Adobe Connect add-in only works in admin accounts 4 47
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
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 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.

752 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