Pass filename as a variable to a swf file
I want to pass a variable which will represent a filename to
a swf file from a hypertext link in an HTML document.
When the user clicks on the link which has
?variablename=filename_to_use appended to a "normal" link to a
page,
this variablename will be passed to the swf file.
I've already created this target swf file to have an
actionscript with a FLVPlayComponent with the filename hard-coded
in the actionscript. I want the actionscript to use the variable
representing the filename_to_use that was passed to from the URL
line.
The following is the actionscript that plays the flv file
taken from the Flash Help: Creating an Application with an
FLVComponent
ORIGINAL VERSION:
import mx.video.*;
this.attachMovie("FLVPlayback", "my_FLVPlybk", 10,
{width:320, height:240, x:100, y:100});
my_FLVPlybk.skin = "file:///install_drive|/Program
Files/Macromedia/Flash
8/en/Configuration/Skins/ClearOverPlaySeekMute.swf"
my_FLVPlybk.contentPath = "
http://www.helpexamples.com/flash/video/water.flv";
VERSION USING THE FILENAME FROM THE PASSED VARIABLE INSTEAD
OF WATER.FLV
import mx.video.*;
this.attachMovie("FLVPlayback", "my_FLVPlybk", 10,
{width:320, height:240, x:100, y:100});
my_FLVPlybk.skin = "file:///install_drive|/Program
Files/Macromedia/Flash
8/en/Configuration/Skins/ClearOverPlaySeekMute.swf"
my_FLVPlybk.contentPath = "
http://www.helpexamples.com/flash/video/variable";
I currently can play videos with this actionscript at my
school website but must make a separate swf for each video.
I want to be able to have one swf file that will play which
video was passed from the link in the HTML page.
I am using HTML page to lower the bandwidth so that users
won't have to load a swf file to see curricular material and then
perhaps choose a video on the topic.
http://www.wearekennedy.com/kent/whatsup.htm
click the link to the Spring curriculum map with resources
and then click on e.g. The_Food_Web video
Thank you,
Kevin Kent
Educator, John F. Kennedy H.S., Bronx, NY
You can use Liskov substitution/polymorphism:
DROP TYPE DEMO_T2
DROP TYPE DEMO_T1
DROP TYPE DEMO_ST
CREATE TYPE DEMO_ST AS OBJECT
( ID NUMBER,
MEMBER PROCEDURE THIS_PROC)
NOT FINAL NOT INSTANTIABLE
CREATE TYPE DEMO_T1 UNDER DEMO_ST
( OVERRIDING MEMBER PROCEDURE THIS_PROC )
CREATE TYPE DEMO_T2 UNDER DEMO_ST
( OVERRIDING MEMBER PROCEDURE THIS_PROC )
CREATE TYPE BODY DEMO_T1 AS
OVERRIDING MEMBER PROCEDURE THIS_PROC AS
BEGIN
DBMS_OUTPUT.PUT_LINE('DEMO_T1');
END;
END;
CREATE TYPE BODY DEMO_T2 AS
OVERRIDING MEMBER PROCEDURE THIS_PROC AS
BEGIN
DBMS_OUTPUT.PUT_LINE('DEMO_T2');
END;
END;
CREATE OR REPLACE PROCEDURE DEMO_PRC ( P_OBJ DEMO_ST) AS
V_OBJ DEMO_ST := P_OBJ;
BEGIN
V_OBJ.THIS_PROC;
END;
-- TAKES AN OBJECT, NOT A PROCEDURE PER SE
-- BUT ALLOWS THE PROCEDURE TO BE PASSED WRAPPED IN AN
-- OBJECT
BEGIN
DEMO_PRC( DEMO_T1(1) );
DEMO_PRC( DEMO_T2(1) );
END;
DEMO_T1
DEMO_T2I believe that this is superior to the passing of function wrapped procedures as arguments because it is according to the intention of object orientation, whereas wrapping a procedure in a function is contrarty to the principles of good functional programming. Good practise in functional programming is to return a single strongly typed result, and produce no side effects. Since the procedure wrapped in a function is a procedure, it therefore implicitly have side effects.
Similar Messages
-
How to pass Variable value to SWF file in Eclipse development
We are creating Widget file in Eclipse by using SAP Widget Foundation .
We included one SWF file in Widget & it is working fine.
But we are not able to pass the values to SWF file variables.?
How to pass variables to SWF file let us know.
Thanks & regardsWe are creating Widget file in Eclipse by using SAP Widget Foundation .
We included one SWF file in Widget & it is working fine.
But we are not able to pass the values to SWF file variables.?
How to pass variables to SWF file let us know.
Thanks & regards -
FB4 Beta 2: Variables accessed across swf-files are null.
I’ve been working on an ActionScript project and just recently switched from FB4 Beta1 to Beta2. The project is made up of multiple swf-files that are loaded into shell.swf. When compiled with FB4 Beta1 variables are accessible across the loaded swfs and shell.swf but they just turn up as being null when compiled with FB4 Beta2. What causes this behavior and how do I go about it?
If you are using Marshall Plan functionality, it is no longer available by default. You have to add the MXMLC option
-includes=mx.managers.systemClasses.MarshallingSupport
Alex Harui
Flex SDK Developer
Adobe Systems Inc.
Blog: http://blogs.adobe.com/aharui -
How to pass the value of variable to another java file?
Hi. I have 2 java files (LogonAction.java and PCAction.java). The value of variable(String getrole) depends on the logon user. How can I use this value of variable in PCAction.java? I want to execute a sql statement in PCAction.java which is (String sql="Select * from PP where role"+"='" + getrole + "'") Thanks a lot.
LogonAction.java is below:
package test;
import test.jdbc.util.ConnectionPool;
import java.sql.*
import java.util.*;
import javax.servlet.http.*;
import org.apache.commons.logging.*;
import org.apache.struts.action.*;
import org.apache.struts.util.*;
import org.apache.commons.beanutils.PropertyUtils;
public final class LogonAction extends Action {
private Log log = LogFactory.getLog("org.apache.struts.webapp.Example");
private ConnectionPool pool;
public LogonAction() {
pool = ConnectionPool.getInstance();
public String getrole;
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
Locale locale = getLocale(request);
MessageResources messages = getResources(request);
ActionErrors errors = new ActionErrors();
String username = (String)PropertyUtils.getSimpleProperty(form, "username");
String password = (String)PropertyUtils.getSimpleProperty(form, "password");
String getusername=CheckUser(username,password);
getrole=getusername;
java.lang.System.out.println(getrole);
if ("".equals(getusername))
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError("error.password.mismatch"));
getusername=username+getusername;
// Report any errors we have discovered back to the original form
if (!errors.isEmpty()) {
saveErrors(request, errors);
return (mapping.getInputForward());
// Save our logged-in user in the session
HttpSession session = request.getSession();
session.setAttribute(Constants.USER_KEY, getusername);
if (log.isDebugEnabled()) {
log.debug("LogonAction: User '" + username +
"' logged on in session " + session.getId());
// Remove the obsolete form bean
if (mapping.getAttribute() != null) {
if ("request".equals(mapping.getScope()))
request.removeAttribute(mapping.getAttribute());
else
session.removeAttribute(mapping.getAttribute());
// Forward control to the specified success URI
return (mapping.findForward("success"));
* Look up the user, throwing an exception to simulate business logic
* rule exceptions.
* @param database Database in which to look up the user
* @param username Username specified on the logon form
* @exception ModuleException if a business logic rule is violated
public String CheckUser(String username,String password){
Connection con = null;
try
con = pool.getConnection();
String sql = "SELECT * from user WHERE userid = ? AND password= ?";
PreparedStatement ps = null;
ResultSet rs = null;
try {
if (con.isClosed()) {
throw new IllegalStateException("error.con.isClosed");
ps = con.prepareStatement(sql);
ps.setString(1,username);
ps.setString(2,password);
rs = ps.executeQuery();
String returnstr="";
while(rs.next())
returnstr=rs.getString("role");
java.lang.System.out.println(returnstr);
return returnstr;
} catch (SQLException e) {
e.printStackTrace();
throw new RuntimeException("error.ps.executeQuery");
} finally {
try {
if (ps != null)
ps.close();
if (rs != null)
rs.close();
} catch (SQLException e) {
e.printStackTrace();
throw new RuntimeException("error.rs.close");
catch (SQLException e)
e.printStackTrace();
throw new RuntimeException("Unable to get connection.");
finally
try
if (con != null)
con.close();
catch (SQLException e)
throw new RuntimeException(e.getMessage());
}You can use PreparedStatement and
String cmd = "select * from PP where role=?";
PreparedStatement stmt = conn.prepareStatement(cmd);
stmt.setString(1,theRole); -
Passing variable information to swf
I've created a flash file that imports photos from a database
where the user is able to merge the photos with a variety of photo
templates. I can pass the db info directly to the swf file with no
problem, but if I use the html file with all the related flash code
I can't seem to pass the code to the swf file. I'm not sure what
I'm doing wrong and would appreciate any help........ThanksThanks so much for replying. The code I'm using to pass the
information is below. The information pulls from a DB into an asp
page. Here's a url:
http://www.pixstarr.com/details_mx.asp?event_Desc=SFDR100508&img_Name=S516_DSC0204-3.jpg.
If you click the "Customize Prints" button on the left you'll see
what it does....hopefully.
It works fine if I pass the info to master.swf, but if I try
to pass it to master.htm which contains master.swf I run into
problems....Thanks again. -
Passing Captivate Variables to Embedded swf
Hello,
How can i read a captivate variable in embedded swf file like cpInfoCurrentSlide;
Thanksvar cpRoot:Object = MovieClip(root);
var mainmov:Object = MovieClip(cpRoot.parent.root);
mainmov.cpInfoCurrentSlide
mainmov.rdinfoCurrentSlide
Some things only work with the old rd variables.
This works for 6 and 7, I haven't tested on 8 yet. -
Pass Passord Variable to a Batch File using Execute Process Task
I have an FTP batch file that I want to execute using Execute Process Task. The content of the ftp (ftpscript.cmd) is as below:
open ftpsite
UserName
Password
ASCII
get file c:\temp\test.txt
bye
Using SSIS Execute process task, I was able to download data. I configured the Execute Process task as follows:
Executable: ftp.exe
Arguments: -s:"c:\temp\ftpscript.cmd"
The above works fine. But the problem is that I don't want to store the password value in the batch file for security/policy reasons. Please, is there a way I can pass the password value to the ftp executable or the batch file at run time?
I know how to get and store variables in SSIS but I don't know how to pass this kind of variable to the batch file just before execution.
Any suggestions will be appreciated. Thanks.you can dynamically generate the source (CMD) for the FTP and delete after the execution. The password can be stored in a secure database for example, not 100 % secure, but the best you can do.
Another option I did was an encrypted VBScript (also quite easy to open in plain text to some people).
Finally it can be a binary e.g. an EXE with the FTP called as process in it.
Arthur My Blog -
I'm trying to create a navigation file that is used to navigate to several applications. Each application is stored as a separate swf on the server. I need to send password data to each of the apps and I'm using the following code connect to each file and to send the password.
var variables:URLVariables = new URLVariables();
variables.connectionInfo = connectionPw
var urlRequest:URLRequest = new URLRequest("http://... filename.swf");
urlRequest.method = URLRequestMethod.POST;
urlRequest.data = variables;
navigateToURL( urlRequest );
My problem is that I am unable to access the data when I am in the connected file.I'm using
password=Application.application.variables.connectionInfo
but the variables are not showing up. How should I be doing this?
Thank you!forty6n2,
I tried to do the same thing, eventually after much searching
I ran across something called flashVars. Essentially, you can pass
values into flex and then do what ever you want with them. I
wrapped my .swf file in an .asp page so that I could pass in the
userID and ip address.
Example:
<object
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
id="MiscControls" width="362" height="280"
codebase="
http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name='flashVars' value='myName=<%=
Response.Write(Request.ServerVariables("REMOTE_ADDR"))
%>&myIP=<%=
Response.Write(Request.ServerVariables("LOGON_USER")) %>'/>
<param name="movie" value="MiscControls.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#869ca7" />
<param name="allowScriptAccess" value="sameDomain" />
<embed src="MiscControls.swf" quality="high"
bgcolor="#869ca7"
width="362" height="280" name="MiscControls" align="middle"
play="true"
loop="false"
quality="high"
allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="
http://www.adobe.com/go/getflashplayer">
</embed>
</object>
Good luck!
- Mike -
Passing variables from one swf to another
I am facing problem to pass variable from one swf to another.
I am using loadMovie to load another swf. how can I pass a variable
value to another swf. Can anyone help me plz? It is somewhat
urgent.
thanx in advance.first of all:
this is the Flash Media Server and your problem is not
related to FMS....
second thing related to the "somewhat urgent" :
we, users on this forum, are not there to do your job... so
calm down otherwise no people will answer your question. This forum
is a free support forum that community of Flash developer use to
learn tricks and to solve problems.
Possibles solutions:
If the two swf are seperate you can use LocalConnection to
establish a connection between different swf.
If you load a second swf into the first one you can interact
like a standard movieClip(only if there from the same domain or if
you a policy file on the other server)
You can use SetVariable(via Javascript) to modify a root
variable on the other swf and check with an _root.onEnterFrame to
see if the variable had changed in the second swf.
* MovieClipLoader will do a better job, in your specify case,
than the loadMovie. Use the onLoadInit event to see when the swf is
really totaly loaded into the first one otherwise you will have
timing issues.
My final answer(lol) is the solution 2 with the
notice(*) -
Hi all,
I have basic knowledge of Flash and AS3.0.
Suppose i have a flash swf file(main.swf). In this main.swf
file, i loaded another swf file(sub.swf) by writing the following
code snippet in main.swf file as shown in Attach Code:
Now, how to acess the data present in main.swf into sub.swf.
Note: Here data represents values/data stored in
variables/objects of main.swf file.Does this actually work -- assigning variables directly on the loader? I'm interested in setting flash variables on the loaded SWF, but I get a compilation error when trying something similar:
Error: Access of possibly undefined property x through a reference with static type flash.display:Loader.
[exec]
[exec] textLdr.x = 50;
I also tried casting the loader to Object, which compiles but then fails at runtime.
-Dave -
Filename generation with variable substitution.
Hi,
I am currently working on a senerio in which file is receiver.The requirement is to generate file at target with the file name as message id.How can i use VARIABLE SUBSTITUTION and acheive this.
(Add message id in configuration should not be done.)Hello shruthi,
Please try this for the filename creation,
1. Create a UDF in the message mapping named getFileName, select only one input (to pass the messageid) and paste this coding there;
/* getFileName User Defined Function
// function to create name of output file
String filename;
filename = strFile;
try {
// initialize DynamicConfiguration for create file with given name
DynamicConfiguration conf = (DynamicConfiguration) container
.getTransformationParameters()
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "FileName");
//create file with the specified name
conf.put(key, filename);
} catch (Exception ex) {
return filename;
2. In the target structure header field perform this mapping,
Messageid -> getfFileName UDF -> Target Structure Headerfield
3. Then in the Integration directory under the target tab
check the Use - adapter specific message attributes and File Name
Please follow the steps and let me know if u still face the same problem. -
Passing data parameter between SWF files
Hello Xcelsius Gurus,
Is it possible to pass data parameter between SWF files?
If possible, how to achieve it?
Thank you.
JustineHi,
Thank you for the reference. Little bit confused, please let me clarify.
I do not understand how the receiver SWF receieved the data parameter and process.
For example, I have a parent dashboard and a child dashboard. In the parent dashboard, I have set up combo box to filter the data. And I want the data that I have selected in combo box to the child dashboard.
To do this, first I need to setup the flash variable at the parent dashboard to fetch the data I selected.
After this, how to link this data to the child dashboard?
Furthermore, after the child dashboard received the data parameter, I need this data to insert into the spreadsheet so I can filter the data. Is this possible?
Thanks.
Edited by: Justine Liu on Jan 19, 2010 3:11 PM -
Calling functions / setting variables in loaded SWF
You know how you can create a Movieclip object, add a
function or variable to it, then call that function or change that
variable from within the SWF that includes it? I wanna be able to
do that, only with SWFs that are loaded at run time.
My "main" SWF is simply a menu-type thing. The user clicks a
button in my MAIN.SWF, and the MAIN.SWF then loads the SWF that's
associated with that button, using the AS 3.0 prescribed
Loader()-URLRequest()-addChild() method that everyone always asks
about.
This works great. But now I've got some custom objects and
such (ie., not just strings) within my MAIN.SWF that I'd like to be
able to share with the loaded SWFs. Preferably, I'd like to use an
accessor-type function (ie.,
LoadedSWF.GiveMeTheCoolObject(MyCoolObject);), though at this point
I'm willing to hack into the object itself (ie.,
LoadedSWF.CoolObject.CoolField = MyCoolObject.CoolField;) if that's
what it takes.
I've tried just calling the functions and setting the fields,
but the AS 3.0 compiler doesn't care for that sort of nonsense on
it's generically-defined objects. Notice also that, at run time, a
call to LoadedSWF.hasOwnObject("GiveMeTheCoolObject") returns true.
So my big-brained colleagues, what's the magic?
In advance, thanks for the help!
ScottKglad,
quote:
Originally posted by:
kglad
from that error message it appears your function is expecting
a member of the MyCoolObject class, correct?
and MyCoolObject is not an instance of that class. so, you
need to fix that. ie, create a member of that class and use that
class member as the function parameter.
Heh, that's what the error message says all right. But the
object actually IS a MyCoolObject class object. I stared at this
thing for hours, and MyCoolObject IS an instance of that class. I
tried various casting combinations (including casting it to an
Object and passing that) but had no luck whatsoever.
So I googled this particular runtime error message ("Error
#1034: Type Coercion failed: cannot convert ") and found a ton of
links to other people having a similar issue. Typically, the
problem was just as you said, someone passing a button as a string,
that kinda thing. But one guy had a problem with an object he
derived from the Event class. After hours spent trying to get it to
work, he tried overriding the base class' clone() method and got it
to work:
http://www.asserttrue.com/articles/2006/10/14/custom-events-in-actionscript-3-0
As for my project, I took a long hard look at the overall
architecture of my project and decided that it was best if all the
"real work" took place in the MAIN.SWF file. This approach would
solve a couple of other problems, and it just makes sense in a
"separate the display from the data" mentality.
So (and this is the interesting part) I changed the API for
the LOADED.SWF to accept String pairs (ie.,
LoadedSWF.AddToDisplay(Name:String, Data:String) ) instead of
accepting MyCoolObj. Ran it, and Viola, now we're working without
any run time exceptions. After that glorious moment, I created a
couple of other APIs that just accepted base classes (one an int
type, the other a function type) and was happily on my way.
From this, I gather that passing non-base class (ie, derived
class) objects to loaded MovieClips via custom function APIs is...
maybe not as straightforward as we'd expect. In the grand scheme of
things though, not a big deal: As far as I'm concerned AS3 rocks.
Again Kglad, thanks for all the help: Your input on how to do
this was the big push that I needed to get over the last technical
hurdle of this project.
To those who are reading this topic for the "how do I call
functions and/or set variables in a loaded SWF?"
The short answer is to cast the loaded SWF's content object
as a MovieClip and then call the function or alter the variable:
//Load the SWF (you've seen this code a million times)
var LoadedSWFObj:Loader = new Loader();
var MyURL:URLRequest = new URLRequest("LoadThisSWF.SWF");
LoadedSWFObj.load(MyURL);
//This is within your Event.COMPLETE handler:
//Cast it as a MovieClip object and work with that.
var LoadedSWF:MovieClip = LoadedSWFObj.content as MovieClip;
// or another way to cast it is:
var LoadedSWF:MovieClip = MovieClip(LoadedSWFObj.content);
//Call yer function:
LoadedSWF.CallMe(); -
Listing all the populated variables when a swf is loaded from an embed tag ?
Hello,
well, everything is in the title, I've been wondering how I
could possibily do this for some time now.
and all I tried or thought of went nowhere.
I'd like to list all the variables an html embed tag passes
on to the swf file called, whatever they are named and how many
there is.
<EMBED
src="example.swf?var="varcontent",var2="var2content">
it's not life-threatening, but I hate using things that work
when I have an idea for things that would work better x)thanks, I didn't think it would be this simple to list all
var in _root.
the only issue remaining is the case where I have more than
one url passed on to my swf file, and how to distinguish which one
is the one to use, but that's not really feasible (and anyway I
can't think of a case where more than one var would be passed to
the swfs I work on, let alone populated with an url). -
Passing value to bind variable of another table from one table
hi,
I have a multi select table. When one row is selected from this table (no button is clicked, only selection is done), an attribute from that selected row (say userid) should be passed to the bind variable of another table and the corresponding details of that particular userid should be displayed in the other table. When more than one row is selected, the other table should display no rows.
My main problem is what code has to be written to pass value to bind variable and where it should be written.
Please give me a detailed explaination as soon as possible.
Thank you.Sorry, didnot add this. The table is multi select table.
Maybe you are looking for
-
Error F5 037 while doing manual clearing of GL with F-03
Hi All, My client is trying to clear a Balance sheet account and getting the below error Account & for deductions/discounts must not be tax-relevant Message no. F5 037. Only the message is displayed and there is no help in the 'performance assistant'
-
Hi, I'm a beginner in DW so please bear with me! I'm getting used to DW by learning to create HTML emails. I've made my first 'test' email (by going File > Preview in Browser > IExplorer..... then in Explorer, I went Page > Send Page by Email). It
-
Installing patch set 9.0.4.2
I'm trying to install the patch set 9.0.4.2 over our single-box installation of 9.0.4.1. I launch the installer with: /mnt/cdrom/runInstaller But I get this error: There are no patches that need to be applied from the patchset Oracle Collaboration Su
-
HP deskjet 990cxi - won't print in just black and white
Hi I've currently run out of coloured ink and don't have any budget to buy more at this time however I do have plenty of black. Unfortunately despite changing the print settings in the control panel and in word to black and white only, the printer i
-
People and Groups or Hybrid (DB Design)
Consider the following tables tblPerson(PersonId, GroupId, Forname, Initial, Surname, DOB, etc) A Person belongs to a group (like employee to employer) tblGroup(GroupId, GroupName) In the past we have used the following table such that a Supplier is