Adobe Dreamweaver Forums



Last 10 THreads :         Re: Colour differences on the web (Last Post : Ann_Shelbourne@adobeforums.com - Replies : 0 - Views : 1 )           »          cs4 full screen mode isn't saved in workspaces, unlike cs3 (Last Post : Ann_Shelbourne@adobeforums.com - Replies : 1 - Views : 2 )           »          help me with adjustments layers in CS4 (Last Post : eddie caruso - Replies : 5 - Views : 6 )           »          delete all channels previously created by "save selection" (Last Post : John_A_Horner@adobeforums.com - Replies : 2 - Views : 3 )           »          Just a small 3D project I have completed (Last Post : Ziggi - Replies : 0 - Views : 1 )           »          Change custom Vector class to new Vector class in player10 (Last Post : VarioPegged - Replies : 3 - Views : 4 )           »          CS4 Motion Editor issues (Last Post : aaronlyon - Replies : 2 - Views : 9 )           »          Looping through results with "Next" button (Last Post : Fetch - Replies : 1 - Views : 2 )           »          Writing a Dreamweaver Extension, where to start? (Last Post : Randy Edmunds - Replies : 1 - Views : 2 )           »          Focus, Browsers & Spry Accordion (Last Post : Randy Edmunds - Replies : 6 - Views : 7 )           »         


User Info Statistics
Go Back   Adobe Dreamweaver Forums > Macromedia Software > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 11-04-2008, 09:02 AM
++ Barry ++
 
Posts: n/a
Diggs:
Default DropShadow with imported AS3

Hi.

I have successfully applied a drop shadow to a canvas with actionScript in a
<mx:Script> tag block. However I want to keep the actionScript external to the
MXML code. I have tried importing the drop shadow as code as shown below but I
cant get the drop shadow to appear. If I include 'this.backgroundCanvas.filters
= filters; in AddDropShadow.as as shown in the attached code I get the
following error:

1042: The this keyword can not be used in static methods. It can only be used
in instance methods, function closures, and global
code. PlayAIR/src/actionscript/com/barrygee/UI AddDropShadow.as line
24 1225277979009 855

If i leave that line so that it only has filters = filters; no drop shadow
appears.

any help very welcome.

Thanks

Barry.

MXML
-----------------------------------------------

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
showFlexChrome="false"
creationComplete="init()">

<mx:Script>
<![CDATA[

import actionscript.com.barrygee.UI.AddDropShadow;

public function init():void
{
AddDropShadow.addShadow();
}

]]>
</mx:Script>

<mx:Canvas
id="backgroundCanvas"
left="5"
right="5"
top="5"
bottom="5"
backgroundColor="#000000"
backgroundAlpha="0.9"
cornerRadius="10"
alpha="1.0"
borderStyle="solid"
borderThickness="0"
mouseDown="nativeWindow.startMove()"/>

</mx:WindowedApplication>


AddDropShadow.as
-----------------------------------------------

package actionscript.com.barrygee.UI
{
import flash.filters.DropShadowFilter;

public class AddDropShadow
{
public function AddDropShadow():void
{
super();
}

public static function addShadow():void
{
var filters:Array = new Array();
var dFilterropShadowFilter = new DropShadowFilter();
dFilter.angle = 0;
dFilter.alpha = 0.5;
dFilter.blurX = 5;
dFilter.blurY = 5;
dFilter.distance = 0;
dFilter.strength = 2;
dFilter.quality = 3;
filters.push(dFilter);
this.backgroundCanvas.filters = filters;
}
}
}



This works

// With as in script block
----------------------------------------

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
showFlexChrome="false"
creationComplete="init()">

<mx:Script>
<![CDATA[

//import actionscript.com.barrygee.UI.AddDropShadow;

public function init():void
{
var filters:Array = new Array();
var dFilterropShadowFilter = new DropShadowFilter();
dFilter.angle = 0;
dFilter.alpha = 0.5;
dFilter.blurX = 5;
dFilter.blurY = 5;
dFilter.distance = 0;
dFilter.strength = 2;
dFilter.quality = 3;
filters.push(dFilter);
this.backgroundCanvas.filters = filters;
}

]]>
</mx:Script>

<mx:Canvas
id="backgroundCanvas"
left="5"
right="5"
top="5"
bottom="5"
backgroundColor="#000000"
backgroundAlpha="0.9"
cornerRadius="10"
alpha="1.0"
borderStyle="solid"
borderThickness="0"
mouseDown="nativeWindow.startMove()"/>

</mx:WindowedApplication>



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-04-2008, 09:02 AM
++ Barry ++
 
Posts: n/a
Diggs:
Default Re: DropShadow with imported AS3

OK, So I have figured it out. I simply passed the canvas object to the method
as shown below and replaced the 'this.backgroundCanvas' with the object in the
actionscript code.



MXML
---------------------------------

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
showFlexChrome="false"
width="800"
height="600"
creationComplete="init()">

<mx:Script>
<![CDATA[

import actionscript.com.barrygee.UI.AddDropShadow;

public function init():void
{
AddDropShadow.addShadow(backgroundCanvas);
}

]]>
</mx:Script>

<mx:Canvas
id="backgroundCanvas"
left="5"
right="5"
top="5"
bottom="5"
backgroundColor="#000000"
backgroundAlpha="0.9"
cornerRadius="10"
alpha="1.0"
borderStyle="solid"
borderThickness="0"
mouseDown="nativeWindow.startMove()">
</mx:Canvas>

</mx:WindowedApplication >


AddDropShadow.as
-----------------------------------------------

package actionscript.com.barrygee.UI
{
import flash.filters.DropShadowFilter;

import mx.containers.Canvas;

public class AddDropShadow
{
public function AddDropShadow():void
{
super();
}

public static function addShadow(canvas:Canvas):void
{
var filters:Array = new Array();
var dFilterropShadowFilter = new DropShadowFilter();
dFilter.angle = 0;
dFilter.alpha = 0.5;
dFilter.blurX = 5;
dFilter.blurY = 5;
dFilter.distance = 0;
dFilter.strength = 2;
dFilter.quality = 3;
filters.push(dFilter);
canvas.filters = filters;
}
}
}

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 12:33 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk