Jake Churchill

… on Flex, ColdFusion, FarCry, and much more …

  • Home
  • About

12

Aug

Flex calls to Javascript

Posted by Jake Churchill  Published in Flex, Javascript

Flex is great! Javascript can be great! What if two great things got together?

This is a simple code hint which shows how to call javascript functions from Flex and pass data back and forth:

MXML Button:

<mx:Button
id = "button"
label = "Click Me!"
click = "handleButtonClick(event:MouseEvent)
/>

Flex Function:

private function handleButtonClick(event:MouseEvent):void
{
var functionName:String = "handleButtonClick";
var returnData:String = ExternalInterface.call(f, "You clicked the button!");
}

Javascript Function:

function handleButtonClick(message)
{
alert(message);
}

That’s really all there is to it. the ExternalInterface.call() handles everything for you.

By the way, if you wanted to actually return data from the javascript function, you’d just do a standard return and it’d be available in the returnData variable in Flex:

function handleButtonClick(message)
{
alert(message);
return "success";
}

1 comment

26

Mar

Javascript Popup with graceful fallback

Posted by Jake Churchill  Published in Javascript

I’ve struggled with popups for some time now. I’ve never really found a good way to handle popping up a new window when clicking a link. Sure, there is the target=”_blank” method but I’ve heard that in XHTML1.0 that is not actually valid. That tells me that browsers can still handle this but might not sometime in the future (or it might end up being included in some kind of quirks rendering mode in the future). A standard Javascript popup is another option but is too easily disabled.

This method will actually do both by creating an event handler.


continue reading "Javascript Popup with graceful fallback"

2 comments

31

Jul

CSS close window link

Posted by Jake Churchill  Published in CSS, Javascript

Honestly, I am blogging this to satisfy a coworker (Axel) who thought this was really cool.

You see this kind of thing all the time, a little X on a window that gets open that allows you to close it. Not the X close button on the title bar of the window but a little close link with an x. I’m a bit of a CSS geek so I made this in CSS. Here’s the code:

<a href="Javascript:window.close()" style="text-decoration:none;">close <span style="border:1px solid gray;width:15px;text-align:center;font-size:8pt;cursor:hand;">X</span></a>

Test It!

no comment

12

Jan

Use javascript to embed a flash object

Posted by Jake Churchill  Published in Flash, Javascript

I’m sure everyone’s been browsing the net using Internet Explorer and noticed that annoying “Click to activate the ActiveX Control” thing. This was implemented by Microsoft due to a security flaw but what if you happen to know that what you are embedding is secure?

In this case, use Javascript to embed your flash object. The javascript has to be in a seperate .js file.

Example:

<!-- include .js file -->
<script type="text/javascript" src="/js/writeFlash.js"></script>
.
.
.
<!-- call function -->
<script language="JavaScript" type="text/javascript">
RunFlash(#flashwidth#, #flashheight#, "#flashmovie#");
</script>

And here’s the JavaScript code:

function RunFlash(flashWidth, flashHeight, flashMovie) {
    var oeTags = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
    + 'width='+flashWidth+' height='+flashHeight+' '
    + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
    + '<param name="movie" value="/files/'+flashMovie+'" /><param name="quality" value="high" /><param name="bgcolor" value="##ffffff" /><param name="wmode" value="transparent">'
    + '<embed src="/files/'+flashMovie+'" quality="high" bgcolor="##ffffff" '
    + 'width="'+flashWidth+'" height="'+flashHeight+'" align="left" wmode="transparent"'
    + 'play="true"'
    + 'loop="false"'
    + 'quality="high"'
    + 'allowScriptAccess="sameDomain"'
    + 'type="application/x-shockwave-flash"'
    + 'pluginspage="http://www.macromedia.com/go/getflashplayer">'
    + '<\\/embed>'
    + '<\\/object>';
    document.write(oeTags);   // embed the flash movie
}
no comment

Search

Blog Feed

  • Add blog to any reader
  • Comments Rss
November 2008
M T W T F S S
« Oct    
 12
3456789
10111213141516
17181920212223
24252627282930

Subscribe to Blog

Your email:  
Subscribe Unsubscribe  

Archives

Categories

  • Browsers (2)
  • CFEclipse (1)
  • ColdFusion (5)
  • CSS (8)
  • Farcry (32)
    • Farcry Examples (2)
    • Farcry Users (1)
  • Flash (1)
  • Flex (8)
  • Javascript (4)
  • Life & Fun (3)
  • Microsoft Office (1)
  • Misc (3)
  • Random Posts (1)
  • SQL (2)

Recent Posts

  • Flex Metadata - Default Property Values
  • VPN Network Routing Step-by-Step
  • VPN Connection Route Fix (Windows Vista)
  • VPN Connection Route Fix
  • SQLite Administrator Recommendation

Recent Comments

  • chris on VPN Network Routing Step-by-Step
  • 3of7 on IE6 PNG Transparency Fix
  • chris on VPN Connection Route Fix
  • Jake Churchill on Flex Menu Expanding Over HTML content
  • James on Flex Menu Expanding Over HTML content

Recent Post

  • Flex Metadata - Default Property Values
  • VPN Network Routing Step-by-Step
  • VPN Connection Route Fix (Windows Vista)
  • VPN Connection Route Fix
  • SQLite Administrator Recommendation
  • Flex Graduated Slider
  • Flex Menu Expanding Over HTML content
  • Flex - Modify your default build template
  • Flex calls to Javascript
  • Custom Object Parsing Function

Recent Comments

  • chris in VPN Network Routing Step-by-Step
  • 3of7 in IE6 PNG Transparency Fix
  • chris in VPN Connection Route Fix
  • Jake Churchill in Flex Menu Expanding Over HTML content
  • James in Flex Menu Expanding Over HTML content
  • ron in Flex Datagrid Sorting
  • Jake Churchill » Post Topic &… in Flex calls to Javascript
  • Dan Wilson in Custom Object Parsing Function
  • Jake Churchill in Javascript Popup with graceful fallback
  • Jake Churchill in Farcry Custom Config
© 2008 Jake Churchill is proudly powered by WordPress
Theme designed by Roam2Rome