Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 12-18-2008, 11:09 AM   #1
Senior Member
Join Date: Dec 2007
Posts: 129
Default [AS3] Show boundary around image?

Hi, I am loading an image onto one movieclip on the stage, from an external url. Now i'm wanted to show a boundary (thin stroke) around the image, so that it is added onto the same Movieclip where image is loaded. How can i do the same as AS3?
asscripter is offline   Reply With Quote
Old 12-18-2008, 12:41 PM   #2
Join Date: Oct 2007
Posts: 81

You can do that by creating a rectangle around it, here is a quick script I came up with; just paste it into flash (as3) to see how it works.

ActionScript Code:
// flash imports required for this example import flash.net.*; import flash.events.*; import flash.display.*; // first we create a loader object, which will // load our image, then we wait till it loads // which we then add it to the movieclip, once // its added to the movieclip, we add that to the stage. // afterwards, we call mcstroke which adds a stroke // in the same movieclip as the loader object var l:Loader = new Loader(); var mc:MovieClip = new MovieClip(); l.load(new URLRequest("http://www.huddletogether.com/projects/lightbox2/images/image-2.jpg")); l.contentLoaderInfo.addEventListener(Event.COMPLETE,imageLoaded); function mcStroke(mc:MovieClip,clr:int=0x888888, thickness:int=5,alpha:int=1){  var sprStroke:Sprite = new Sprite();  mc.addChild(sprStroke);  sprStroke.graphics.lineStyle(thickness,clr,alpha);  var r:Rectangle = (mc.getRect(sprStroke));  sprStroke.graphics.drawRect(r.x,r.y,r.width,r.height); } function imageLoaded(e:Event):void{  // add to the stage  mc.addChild(l);  stage.addChild(mc);    // downsize image  mc.width=300;  mc.height=250;    // center the image  mc.x = (stage.stageWidth/2-(mc.width/2));  mc.y = (stage.stageHeight/2-(mc.height/2));  mcStroke(mc);   }
tBeck is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Image zoom in/out and drag L_Tambiah ActionScript 1.0 (and below) 12 02-25-2011 02:31 AM
[AS3] How do I show hand cursor on textArea cmbarsotti Components 7 02-08-2010 07:36 PM
Adding link to image which is called upon XML file 21v ActionScript 1.0 (and below) 10 11-18-2008 05:12 PM
show preloading for an image anurag ActionScript 2.0 6 07-06-2007 12:33 PM
Open PowerPoint Show file when press image in flash .how ? Crimson Other Flash General Questions 0 09-17-2006 07:48 AM

All times are GMT. The time now is 11:42 PM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.