Archive Page 3

07
Feb

Error (#2148) Loading XML with Flex2 - Security Error

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

I had this problem and thought you would all like to know….. I was trying to load a local xml doc and this solution worked for me.

Posted on January 11th, 2007 by polyGeek

Error (#2148) Loading XML with Flex2

I was running through a simple tutorial for loading XML into Flex and displaying it in a DataGrid when I got the following error:

[RPC Fault faultString=”Error #2148: SWF file file:///C:/Documents and Settings/…/My Documents/xmlParsing/bin/xmlParsing.swf cannot access local resource Blades.xml. Only local-with-filesystem and trusted local SWF files may access local resources.” faultCode=”InvokeFailed” faultDetail=”null”]

If I go into the bin folder and launch the SWF directly then everything loads and works correctly. That right off is a tip that it’s probably a security issue. Sure enough. With a little research I found it.

  • In the Navigator panel Right-click and select Properties
  • In the lefNav select Flex Compiler
  • In the Additional compiler arguments: field add the following argument: -use-network=false

So my arguments read: -locale en_US -use-network=false

It would seem that this setting has to be made for each project.

Stupid security settings. :-)

When I Googled this problem I only got three hits back. My guess is that this will be a common problem so it wouldn’t hurt for others to duplicate this solution to make it easier for others to find.

Found this useful? How about buying me a coffee - simply click here.

07
Feb

Anatomy of an Enterprise Flex RIA Part 1: The Tools You’ll Want

Here the first in a series of installments that will shed some light on Enterprise Flex RIA’s

“In this installment of the series Anatomy of an Enterprise Flex RIA we’re doing a little grunt work and installing some tools we’ll be using later. Download them and read up a bit on what they do. These tools are some common “enterprise software” development tools that we’ll need to get the example software up and running.

In this series, we’ll look at a small application that integrates the technologies of LCDS and EJB 3.0, and we’ll cover some timesaving tools as well as discuss how to use them to achieve a lightweight development environment for integrating an RIA with an enterprise environment. Ready to get started?”

http://www.insideria.com/2008/01/anatomy-of-an-enterprise-flex.html

Found this useful? How about buying me a coffee - simply click here.

06
Feb

Drag in AS3

You can place this code in an AS3 document or a custom class, your choice. Thanks to Matt for the snippet Full code after the jump.

AS3 click and drag example
function initDragger(mc:MovieClip):void

{

 mc.addEventListener(MouseEvent.MOUSE_DOWN, function (e:MouseEvent):void

 {

 	e.currentTarget.startDrag();

 });

 mc.addEventListener(MouseEvent.MOUSE_UP, function (e:MouseEvent):void

 {

 	e.currentTarget.stopDrag();

 });}

// Set up drag
initDragger(cir_mc);

Found this useful? How about buying me a coffee - simply click here.

06
Feb

Convert degrees to radians & radians to degrees

These are two useful formulas that you will use more often than not.

degrees to radians

var degrees:Number =  radians * 180 / Math.PI

radians to degrees

var radians:Number = degrees * Math.PI / 180

Found this useful? How about buying me a coffee - simply click here.

06
Feb

Distance Between two Points

This is one of the most useful formulas that I use. This formula measures the distance between any 2 given points…

These points can be coordinates, movie clips, mouse position, ect…

Full code after the jump.

dx = x2 – x1;
dy = y2- y1;
Dist = Math.sqrt(dx*dx + dy*dy)

Found this useful? How about buying me a coffee - simply click here.

05
Feb

removeMovieClip() dosent work

So it would seem that when you publish your movies in flash, removeMovieClip() doesn’t seem to work properly or at all.

This is because you are more than likely using getNextHighestDepth() which is supposably perfectly fine. But in certain cases such as using v2.0 components or buttons this will cause problems. The reason is that when you use components the Flash DepthManager class automatically reserves the highest upper and lower depths available to Flash (-16383,1048575). So if you have a component in your fla and you call getNextHighestDepth() it will return 1048576 – this is now an out of range depth for removeMovieClip() making it unable to remove the clip. Also the call will fail silently (making it hard to debug)

 

Work Around Provide by macromedia

Use unLoadMovie() instead ofremoveMovieClip(). – I still have problems, but it might work for you.

Swap the depth of the movie clip to a level at or below 1048575 before doing removeMovieClip() – With a complicated movie can get interesting to sort sometimes

 

The easiest way I have found is to manage the depths manually, this approach is extremely easy and doesn’t cause any issues

var nDepth:Number = 100
var createEmptyMovieClip(“myClip_mc”, nDepth++);

Hope this shines some light on what can be an extremely frustrating problem.

 

Read some more about it here
http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_19435

Found this useful? How about buying me a coffee - simply click here.

04
Feb

Should I use scenes

I got asked the other day why don’t we use scenes?

Before getting into using scenes read below, this is a hotly contested area but is suggested best practice by adobe to steer away from scenes. Read below for adobes official thoughts and my own on scenes in flash…

Using Scenes
Using scenes is similar to using several SWF files together to create a larger presentation. Each scene has a timeline. When the playhead reaches the final frame of a scene, the playhead progresses to the next scene. When you publish a SWF file, the timeline of each scene combines into a single timeline in the SWF file. After the SWF file compiles, it behaves as if you created the FLA file using one scene. Because of this behavior, avoid using scenes for the following reasons:

  • Scenes can make documents confusing to edit, particularly in multiauthor environments. Anyone using the FLA document might have to search several scenes within a FLA file to locate code and assets. Consider loading content or using movie clips instead.
  • Scenes often result in large SWF files. Using scenes encourages you to place more content in a single FLA file and hence, larger documents to work with and larger SWF files.
  • Scenes force users to progressively download the entire SWF file, even if they do not plan or want to watch all of it. Your user progressively downloads the entire file, instead of loading the assets they actually want to see or use. If you avoid scenes, the user can control what content they download as they progress through your SWF file. This means that the user has more control over how much content they download, which is better for bandwidth management. One drawback is the requirement for managing a greater number of FLA documents.
  • Scenes combined with ActionScript might produce unexpected results. Because each scene timeline is compressed onto a single timeline, you might encounter errors involving your ActionScript and scenes, which typically requires extra, complicated debugging.

There are some situations where few of these disadvantages apply, such as when you create lengthy animations. If you create lengthy animations, you might find it adventageous to use scenes. If disadvantages apply to your document, consider using multiple FLA files, movie clips, or screens to build an animation instead of using scenes. For more information on using screens, see Working with Screens in Flash Help or the Flash 8 LiveDocs (Using Flash > Working with Screens).

Basically I think scenes are the devils spawn

Instead I would suggest that you break your file into manageable flash files (chucks) e.g make separate swf files. This will make it easier to create, edit, code and in end manage.

Hope this helps clear some things up

Found this useful? How about buying me a coffee - simply click here.

04
Feb

Email Validation in AS2

I Have just posted up a code snippet that validates general email addresses in AS2. [Update] - Click here for the AS3 Email Validation Code

Full code after the jump.

function validateEmail(emailStr:String) {
var errorCount:Number = 0;
//check to see if there are at least two chars be for the @ symbol
if (emailStr.indexOf("@")<2) {
errorCount++;
}
//check that the @ is not within 2 chars of .
if (emailStr.lastIndexOf(".")<=(emailStr.lastIndexOf("@")+2)) {
errorCount++;
}
//check length eg min aa@bb.cc
if (emailStr.length<8) {
errorCount++;
}
//check there is only one @
if (emailStr.indexOf("@") != emailStr.lastIndexOf("@")) {
errorCount++;
}
// return a T/F to the flash file
if (errorCount == 0) {
return true;
} else {
return false;
}
}

//to use it
if(validateEmail(email.text)){
trace("EMAIL VALID");
}else{
trace("EMAIL NOT VALID")
}

Found this useful? How about buying me a coffee - simply click here.

04
Feb

Out with the old and in with the new.

Hi if all. If you are looking for the old flash cs forums I am sorry to say that I have had to discontinue the site. This is due to my current workloads and commitments. But I will continue to post relevant and topical items here.

If you are new hi.

Found this useful? How about buying me a coffee - simply click here.





Close
E-mail It