Measure a particular Layer Properties (width & height) through coding
Hi,
I am working on the Apparel Model images. Everyday we work with different models. Once done with the shooting process, we make the required correction on it so obviously we come across height issues at the retouch (Photoshop CS5) end.
The following steps will describe the process on how we do it. We have a template for the image cropping (Template's Width X height: 3700 X 5000 pxls). Usally we used to drag the template to the apparel images then will make a proportianate tranform for the template according to the model's height and crop it. this is what we are doing in the manual process. We have an idea of creating a script for this category. the same steps will be executed by the script. First Select the appropriate folder which will be processed by this script. application will open the images one by one. Steps: Open the Template image, copy and paste it on the another document. According to the Model's height make a proportianate transform to the template layer (In this step, we need to know about the particular layer properties for ex: (if the activeDocument's height is 3000pxls. the tranform will happen proportianately to the template layer).
My Question is How do we measure a particuler layer properties and how to access it through coding?
My Second Question is : How do we get the properties data and how it will be applied through coding?
I am waiting your reply.
thanks,
Rajiv.s
Open the Template image, copy and paste it on the another document.
Copy/pasting via Script is not such a great idea, the method duplicate may be a better fit to duplicate a layer into another file or group.
My Question is How do we measure a particuler layer properties and how to access it through coding?
Layers habe a property called bounds, this describes the left, top, right and bottom coordinates.
It may be prudent to set the unitRulers via the Script to make sure they are always the same units (px, pt, mm …).
#target photoshop
var theBounds = app.activeDocument.activeLayer.bounds;
var theWidth = theBounds[2] - theBounds[0];
var theHeight = theBounds[3] - theBounds[1];
alert ("layer is " + theWidth + " x " + theHeight);
Similar Messages
-
Access to x/y & width/height through CSS
Why is it that setting a component's x, y, width and height is not supported through CSS when it is possible to alter its position and dimensions using left, right, top, bottom, horizontalCenter, verticalCenter etc?
Obviously I understand that x,y, width and height are not styles, but given that they could easily be controlled by styles, I can't understand why this capacity is missing.Isn't it quite a high price to pay for losing the ability to write fully semantic code? In many situations it becomes impossible to separate position and dimension declarations from the tags representing the components. Ideally shouldn't we be able to perform all styling and layout from CSS as per HTML?
Is this something that is set in stone, or is it something that might change at some point? Most CSS styles are set once at startup, so performance wouldn't be too much of a problem in a lot of cases. -
How do i flip a layer in vertical direction through Coding?
Hi,
I would like to make a mirror effect for the foreground. so i have to flip a layer in vertical direction, by move the anchor position to the bottom center.
Could you please help me on this?
thanks,
rajiv.sIf I recall correctly both me & mike had a play about with a similar request over at PS Scripts… There may be something in this that you can utilise… In my case it was just for pretty much square on product stots…
#target photoshop
app.bringToFront();
var userRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var whiteRef = new SolidColor();
whiteRef.rgb.red = 255;
whiteRef.rgb.green = 255;
whiteRef.rgb.blue = 255;
var blackRef = new SolidColor();
blackRef.rgb.red = 0;
blackRef.rgb.green = 0;
blackRef.rgb.blue = 0;
app.backgroundColor = blackRef;
app.foregroundColor = whiteRef;
var docRef = app.activeDocument;
if (docRef.layers[0].isBackgroundLayer == false) {
if (docRef.layers[0].allLocked == true) docRef.layers[0].allLocked = false;
//if (docRef.layers[0].pixelsLocked == true) docRef.layers[0].pixelsLocked = false;
//if (docRef.layers[0].positionLocked == true) docRef.layers[0].positionLocked = false;
docRef.trim(TrimType.TRANSPARENT, true, true, true, true);
docWidth = docRef.width;
docHeight = docRef.height;
docRef.layers[0].duplicate();
docRef.resizeCanvas(docWidth, (docHeight * 2), AnchorPosition.TOPCENTER);
docRef.layers[1].translate(0, docHeight);
FlipLayer('Vrtc');
docRef.channels.add();
DrawGradient(docWidth*.5, docRef.height, docWidth*.5, docRef.height*.5, 50); //Adjust to tast
docRef.activeChannels = docRef.componentChannels;
docRef.resizeCanvas(docWidth + 50, (docHeight * 2) + 50, AnchorPosition.MIDDLECENTER);
docRef.layers[1].opacity = 75;
docRef.layers[1].blendMode = BlendMode.SCREEN;
docRef.selection.load(docRef.channels.getByName('Alpha 1'));
MakeLayerMask('RvlS');
docRef.channels.getByName('Alpha 1').remove();
SolidFillLayer(0, 0, 0);
docRef.layers[1].move(docRef.layers[2], ElementPlacement.PLACEAFTER);
app.preferences.rulerUnits = userRulerUnits;
function FlipLayer(direction) {
// direction = "Vrtc" or "Hrzn"
function cTID(s) { return app.charIDToTypeID(s); };
function sTID(s) { return app.stringIDToTypeID(s); };
var desc01 = new ActionDescriptor();
var ref01 = new ActionReference(); ref01.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt') );
desc01.putReference(cTID('null'), ref01);
desc01.putEnumerated(cTID('Axis'), cTID('Ornt'), cTID(direction));
executeAction(cTID('Flip'), desc01, DialogModes.NO);
function MakeLayerMask(maskRef) {
function cTID(s) { return app.charIDToTypeID(s); };
function sTID(s) { return app.stringIDToTypeID(s); };
// maskRef = RvlA, HdAl, RvlS, HdSl
var desc01 = new ActionDescriptor();
desc01.putClass(cTID('Nw '), cTID('Chnl'));
var ref01 = new ActionReference();
ref01.putEnumerated(cTID('Chnl'), cTID('Chnl'), cTID('Msk '));
desc01.putReference(cTID('At '), ref01 );
desc01.putEnumerated(cTID('Usng'), cTID('UsrM'), cTID(maskRef));
executeAction(cTID('Mk '), desc01, DialogModes.NO);
function DrawGradient(x1, y1, x2, y2, midPoint) {
function cTID(s) { return app.charIDToTypeID(s); };
function sTID(s) { return app.stringIDToTypeID(s); };
var desc01 = new ActionDescriptor();
var desc02 = new ActionDescriptor();
desc02.putUnitDouble( cTID('Hrzn'), cTID('#Pxl'), x1 );
desc02.putUnitDouble( cTID('Vrtc'), cTID('#Pxl'), y1 );
desc01.putObject( cTID('From'), cTID('Pnt '), desc02 );
var desc03 = new ActionDescriptor();
desc03.putUnitDouble( cTID('Hrzn'), cTID('#Pxl'), x2 );
desc03.putUnitDouble( cTID('Vrtc'), cTID('#Pxl'), y2 );
desc01.putObject( cTID('T '), cTID('Pnt '), desc03 );
desc01.putEnumerated( cTID('Type'), cTID('GrdT'), cTID('Lnr ') );
desc01.putBoolean( cTID('Dthr'), true );
desc01.putBoolean( cTID('UsMs'), true );
var desc04 = new ActionDescriptor();
desc04.putString( cTID('Nm '), "Foreground to Background" );
desc04.putEnumerated( cTID('GrdF'), cTID('GrdF'), cTID('CstS') );
desc04.putDouble( cTID('Intr'), 4096.000000 );
var list15 = new ActionList();
var desc05 = new ActionDescriptor();
desc05.putEnumerated( cTID('Type'), cTID('Clry'), cTID('FrgC') );
desc05.putInteger( cTID('Lctn'), 0 );
desc05.putInteger( cTID('Mdpn'), midPoint );
list15.putObject( cTID('Clrt'), desc05 );
var desc06 = new ActionDescriptor();
desc06.putEnumerated( cTID('Type'), cTID('Clry'), cTID('BckC') );
desc06.putInteger( cTID('Lctn'), 4096 );
desc06.putInteger( cTID('Mdpn'), midPoint );
list15.putObject( cTID('Clrt'), desc06 );
desc04.putList( cTID('Clrs'), list15 );
var list16 = new ActionList();
var desc07 = new ActionDescriptor();
desc07.putUnitDouble( cTID('Opct'), cTID('#Prc'), 100.000000 );
desc07.putInteger( cTID('Lctn'), 0 );
desc07.putInteger( cTID('Mdpn'), 50 );
list16.putObject( cTID('TrnS'), desc07 );
var desc08 = new ActionDescriptor();
desc08.putUnitDouble( cTID('Opct'), cTID('#Prc'), 100.000000 );
desc08.putInteger( cTID('Lctn'), 4096 );
desc08.putInteger( cTID('Mdpn'), midPoint );
list16.putObject( cTID('TrnS'), desc08 );
desc04.putList( cTID('Trns'), list16 );
desc01.putObject( cTID('Grad'), cTID('Grdn'), desc04 );
executeAction( cTID('Grdn'), desc01, DialogModes.NO );
function SolidFillLayer(r, g, b) {
function cTID(s) { return app.charIDToTypeID(s); };
function sTID(s) { return app.stringIDToTypeID(s); };
var desc616 = new ActionDescriptor();
var ref58 = new ActionReference();
ref58.putClass( sTID('contentLayer') );
desc616.putReference( cTID('null'), ref58 );
var desc617 = new ActionDescriptor();
var desc618 = new ActionDescriptor();
var desc619 = new ActionDescriptor();
desc619.putDouble( cTID('Rd '), r );
desc619.putDouble( cTID('Grn '), g );
desc619.putDouble( cTID('Bl '), b );
desc618.putObject( cTID('Clr '), cTID('RGBC'), desc619 );
desc617.putObject( cTID('Type'), sTID('solidColorLayer'), desc618 );
desc616.putObject( cTID('Usng'), sTID('contentLayer'), desc617 );
executeAction( cTID('Mk '), desc616, DialogModes.NO ); -
Revision: 3411
Author: [email protected]
Date: 2008-09-29 16:44:01 -0700 (Mon, 29 Sep 2008)
Log Message:
* Change layout-related width/height, explicit width/height, measured width/height properties from post-scale to pre-transform. yay!
* Flex3 containers are updated to support the new behavior.
* Repeatedly scaling a component can differ from before, since we no longer accumulate rounding errors.
* The change is gated by a version flag, in compatibility mode these properties don't change.
Reviewed by Glenn, Ely
Modified Paths:
flex/sdk/trunk/frameworks/projects/flex4/src/flex/layout/LayoutItemUIC.as
flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/Accordion.as
flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/Box.as
flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/DividedBox.as
flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/FormItem.as
flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/Tile.as
flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/utilityClasses/BoxLayout.a s
flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/utilityClasses/CanvasLayou t.as
flex/sdk/trunk/frameworks/projects/framework/src/mx/core/Container.as
flex/sdk/trunk/frameworks/projects/framework/src/mx/core/UIComponent.as
Added Paths:
flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/utilityClasses/PostScaleAd apter.asI am sorry to have to point out to you that you have changed SpryMenuBasicSkin.css so much that it is impossible to render any assistance.
To start with, the menubar has an ID of MenuBar, yet in the CSS I only see this referenced as a CLASS as in
.MenuBar {
background-color:#cccccc;
font-family: Arial, Helvetica, sans-serif; /* Specify fonts on on MenuBar and subMenu MenuItemContainer, so MenuItemContainer,
MenuItem, and MenuItemLabel
at a given level all use same definition for ems.
Note that this means the size is also inherited to child submenus,
so use caution in using relative sizes other than
100% on submenu fonts. */
font-weight: normal;
font-size: 16px;
font-style: normal;
padding:0;
border-color: #ffffff #ffffff #ffffff #ffffff;
border-width:0px;
border-style: none none none none;
I would suggest to start again.
Once you have done that, supply a link to your site and we will assist you further.
Gramps -
Revision: 14871
Revision: 14871
Author: [email protected]
Date: 2010-03-19 01:05:54 -0700 (Fri, 19 Mar 2010)
Log Message:
Fixing anchoring 'right' and 'bottom' properties not being applied on items that don't have a width/height and position set.
Modified Paths:
osmf/trunk/framework/OSMF/org/osmf/layout/LayoutRenderer.asIf you're just doing it in a back and forth or spiral fashion, you don't need to check whether a square's been filled in. You just go from a start point to an end point. Those points and the squares in between are determined by simple arithmetic.
If you're doing it randomly, I wouldn't use the GUI elements themselves. I'd have, for example, and array of booleans that tells whether each square has been filled in. -
How to export layer width, height, and position to a text document?
I am working on an automated workflow for which I need to know the exact width, height, and position in pixels of certain layers in a PSD.
I am pretty sure this is possible with applescript but does anyone know of a way to have this info included automatically in the documents metadata?
thanks,
ryanHi Gabriele - how did you add the subs to FCP? if you added them using the text tools built in then you need to try to extract those first. Neither FCP or DVDSP are good places to create subtitles, but apps like STL Edit and Belle Nuit are. These will both create subs that can be imported into DVDSP. You can also use a text file to import the subs as long as the text file is set up correctly. The precise format is listed in the manual for DVDSP and a tool like BBEdit is ideal if you want to do the subs this way. Some folk even use Excel to set up the timecodes, etc, but personally I find that too distracting, preferring to work with STL Edit when I need to add subs.
One thing is almost universally agreed upon in here - create the subs outside of DVDSP and import them in, since if you need to move, alter or otherwise change them it is a lot easier from within a text file than from within DVDSP. -
Get image properties (width and height)
Hi there,
Does anyone know if there is a way that I could get the width and height of an image to be displayed in a JSP.Image has methods to get the width & height.
-
How to know the whole selection x/y/width/height properties ?
Hi,
I would like to know the x/y/width/height property of the rectangle that surround the "select all"
I select all my components like this :
For Each artItem In docRef.PageItems
If Not artItem.Locked Then 'Selecting a locked item crashes
artItem.Selected = true
End If
Next
How can I know the whole size and position ?
ThanksOk I found something that does the trick.
To know the bounds of all items, actually you don't need to select them.
Dim bound, x, y, width, height
bounds = docRef.visibleBounds
x = bounds(0)
y = -bounds(1)
width = bounds(2) - bounds(0)
height = -(bounds(3)-bounds(1)
And it works ^^ -
Why can't I import anything? "File video dimensions (width/height) too large"
New to PP CS4 here (that will be obvious momentarily...). I can't seem to import any footage into any project (well, at least none of the bits I've tried, and I don't think there's anything 'wrong' with them). Every time I attempt to do so, I get the error:
Dialog title: File Import Failure
Error Message: File video dimensions (width/height) too large.
This occurs with every files I've thrown at it - admittedly, they all have a lot in common, but they're not particularly exotic.
The files are (mostly) AVI files (I know, I know...before I get jumped, I understand it's just a wrapper, etc.). The files come from two cameras:
1. A Sony DCR-TRV20. Opening up the AVI in QuickTime Player, I see it's listed as "DV/DVCPRO - NTSC 640X480"
2. Canon PowerShot A620. Opening up the AVI in QuickTime Player, I see it's listed as "MotionJPEG OpenDML 320x240"
3. I somehow managed to get the AME to spit out a FLV file. That failed to import with the same error message, too.
I tried running these files through AME, and got the same results (although never having used AME previously, I have a question on that, below).
New project, settings are all (I think) the defaults: Preset DV-NTSC/Standard 32kHz
New installation of PP CS4, with the 4.1 update, on a PC running Vista 32 with all the endless MS updates applied.
Related question: I've skimmed other threads here, and noted the advice to "always convert any non-standard footage to DV-AVI Type II" before importing....however, I see no such option for that output format in AME....only generic things like "Microsoft AVI" and "Uncompressed Microsoft AVI".
Codec issues? I'm a little skeptical, since these AVI files play just fine in Windows if I double-click them. Does that not suggest that there's a codec there for them? The files are from (what I believe to be) garden-variety consumer cameras (these devices are a bit old and certainly not high-end, but they're hardly exotic formats, I think). The files are small, short clips I'm attempting to use just to learn Premiere, but it gags on every one of them, every time.
PP is so insistent that every file I throw at it has improper dimensions, but these files appear to be perfectly reasonably sized, and I assume it's operator error (I'm withholding judgement on the quality and accuracy of the error string it's presenting me). But I'm not sure where to look for the right knob to twist. Pretty frustrating to be stuck on Square 1 (actually, Square Zero).
Can someone point me in the right direction?
Please be gentle, it's my first time....Thanks, but....mmmm....maybe not.
I've tried multiple settings for New Projects. Just created a new one using the preset for DV-NTSC/Widecsreen 48kHz (frame size 720 x 480, 48 kHz audio). Exactly the same results.
You say "To point you in a certain direction, DV from a TRV is 720x480, not 640x480." However, according to QuickTime's Movie Inspector panel, the file is 640x480. This clip was captured through Premiere - that wouldn't change its aspect ratio, would it?
The files from the Canon still camera are AVI files, not still images (so I don't see how the reference to Photoshop applies, or perhaps I misunderstood your point). They are 320x240, according to QuickTime's Movie Inspector panel. If they're 320x240, wouldn't that be the same aspect ratio as 640x480? Attempting to import them, I get the same error....
While not exactly Hollywood quality, I just need files to play with as I attempt to learn the program, and it's not clear to me why these files should not work - other than the fact that NO files seem to work. Also, I'm not sure what your reference to "exporting" pertains to - I can't get anything imported, I'm not trying to export anything that (I'm aware of) - I'll worry about exporting once I've managed to get something, ANYTHING to import.
I've got some PP training videos (from "you-probably-know-who.com"). Following along using their project files and their video assets (MOV files in this case), I still get the exact same error.
So to summarize, so far, I've seen no evidence that this copy of PP can import ANY video file.
While I'm sure I would benefit from spending more time with the fine manual, I think there's something wrong here that's not going to be addressed in the introductory documentation. If I can't import any footage into any project, progress is going to be slow.
How about this: is there some known-to-be-good test file I can grab and try importing that? I've got very strong suspicions that I'll get the same error message.
Thanks again. -
Getting incorrect coordinates, width/height of page-item in actionscript.
Hi,
I am developing a Flex extension for InDesign CS5. I am trying to get the coordinates and width/height of a page-item. But, I keep getting incorrect data. Please refer screenshot. The coordinates as I see in the InDesign application are 38.8, 66.02, 117.5, 160.5.
I used the geometricBounds method to get the coordinates and width/height, but I am getting 29.70, 40.26, 222.07, 178.11. Please refer the screenshot.
I read somewhere that the coordinates can change with respect to the ruler settings, i.e., it depends on Ruler per Spread, Ruler per Page or Ruler on Spine. But, I couldn't find anything related to this with respect to actionscript.
How can I get the coordinates and width/height that I see in the InDesign application through actionscript?
Thanks!@poortip87 – make a rectangle with the coordinates ActionScript is suggesting on your page together with your placed image. Then you can see how this correlates to the path points of the rectangle that holds the image.
Further reading on geometricBounds and their relationship to other geometric properties of page items can be found here:
Marc Autret:
Work Around the Width/Height Gap
http://www.indiscripts.com/post/2009/10/work-around-the-width-height-gap
Uwe -
Script to receive width, height, movie url
I'm a complete Flash neophyte, but despite this I've been
tasked at work with creating an actionscript for a fla file that
will receive width, height, and URL (of a .flv file) as arguments
so that the file can dynamically display video based on the
arguments passed. I have to have this done by tomorrow...would
anyone be kind enough to throw me a clue or two on how this could
be done? I'm looking through the tutorials and documentation, but
they all look like they're for intermediate to advanced Flash
users. I know javascript fairly well, so I think I get the general
concept, but I'm in the dark as to syntax, proper object and
properties to refer to, what the function would look like or where
to save it...
Any help would put me way in your debt.
Thanks,
Christophefunction setVideo(newWidth, newHeight, newURL)
_root.videoGizmo._height = newHeight;
_root.videoGizmo._width = newWidth;
//then set the filename. That will be different depending on
what video component you are using. If you are using flash 8 and
using the flash 8 video playback component then it will be the
contentPath like so
_root.videoGizmo.contentPath = newURL;
Keep in mind that if you are using flash 8 and that's OK for
users then then video playback component will autosize for you if
you set its autosize property to true. -
Hi all,
I have written a Acrobat plugin using PDFEdit APIs to extract x, y co-ordinates, width and height of all elements(objects) in a PDF document.
Now, I wanted to make the same working on Adobe Reader.I have added the READER_PLUGIN macro enabled in Project settings.
When I re-compiled the code, I got a bunch of errors saying all PDFEdit APIs are not available under Adobe Reader.
My objective is to parse through the entire PDF document and get x, y co-ordinates, width, height of all PDF objects (especially Image and Text objects).
Can anybody help me how to achieve this ?
Thanks
PrasanthI know that we cannot obtain the PDEContent of a PDF page from Adobe Reader, as PDEContent is modifiable content and as such it cannot be accessible from Adobe Reader.
Also, as PDFEdit API's does not work for Adobe Reader, we are trying to figure out a way to achieve this for Adobe reader.
I am curious to know if the COS APIs can help us in this task.
I tried to read the stream content using PDPageStmGetToken API. I get the data of this format:
344.88 0 0 91.44 71.882 41.92cm
Here, as per PDF reference, I am getting only distance from X Axis and distance from Y Axis. But not width and height.
Can you knidly let us how to get the image attributes (primarly read only attributes like x and y co-ordinates, width and heoght) with Cos APIs.
Thanks
Prasanth -
Hello
--- First: Please, im very sorry for my bad spelling - english is not my native language! Hope u can understand, what i mean. If it sounds bad or yelling someone - its not my intention! ---
My Question:
If i do Strg+T with a layer (ie. image or shape) in previous version you have the width & height in top bar and can easily read it or change when typing a new value in. With right mouse (Win) you can change % in px or em etc.
In my Photoshop CC 14.2 i have only % and cant change this.
If i try to read the dimension i can only see it on the info-panel.
Its confusing. Is it a Bug or Feature?
MJanyone?
.... alone .... -
Setting width/height of a control with CSS
Hi,
I am styling a button a button in CSS and set a background-image for the button in my stylesheet.
The problem is, that the button should scale to the width/height of the image.
I added:
-fx-width: 32px;
-fx-height: 32px;
but it has no effect.
I also tried it with
-fx-min-width: 32px;
-fx-min-height: 32px;
If I use setMinWidth(32); in Java, it works.
But I rather want to set it in my stylesheets, because the image can change, if we use another skin.CSS documentation (http://docs.oracle.com/javafx/2.0/api/javafx/scene/doc-files/cssref.html) states:
"JavaFX CSS does not support CSS layout properties such as float, position, overflow, and width. However, the CSS padding and margins properties are supported on some JavaFX scene graph objects. All other aspects of layout are handled programmatically in JavaFX code."
I thought you might be able to do something using the -fx-shape property, but the shape does not affect the size of the button - so that didn't work.
I had more luck with the -fx-graphic property - you could try to enhance the stylesheet below to get what you want.
.root { -fx-background-color: azure; -fx-padding: 20; }
#smurf-button { -fx-graphic: url("http://bluebuddies.com/smurf_fun/smurf_race/jpg/Smurf_Race_100x100.jpg"); -fx-background-color: transparent; }
#smurf-button:hover { -fx-effect: dropshadow( three-pass-box , rgba(184,134,11,0.6) , 20, 0.0 , 0 , 0 ); }
#smurf-button:armed { -fx-effect: innershadow( three-pass-box , rgba(0,200,0,0.6) , 30, 0.0 , 0 , 0 ); }
public class ButtonStyle extends Application {
public static void main(String[] args) throws Exception { launch(args); }
public void start(final Stage stage) throws Exception {
final Button button = new Button();
button.setId("smurf-button");
final Scene scene = new Scene(StackPaneBuilder.create().children(button).build());
scene.getStylesheets().add(this.getClass().getResource("style.css").toExternalForm());
stage.setScene(scene);
stage.show();
} -
Width/height/x/y value mismatch with the reality and what is coded
hello there everyone,
hope i got the title right..,
so here goes the problem i need your opinion and help to solve:
application definition:
i have this desktop flash application that will go fullscreen what this application do is loading external asset (mostlySWF) and play it inside this application. Each external asset will be place inside a container/holder (empty movie clip created by code), each of this container have it's own dimension ( width, height, x, y).my code all working without any warning nor error.oh and i also have an image.jpg/png as it's background and place at the bottom of display list (depth = 0), the image is customly made with using photoshop and each container location and dimension also measured there so it just needed to be writen down is the XML file..,
the problem:
the bug is when i loaded some image of those background image each container width,height,x,y will mismatch with what i have in the XML file.
the funny thing is when i trace the value of each container width,height,x,y it value is the same with what the XML has yet by seeing with eye you know that is wrong..,
here's the code i used:
var myXML:XML; //to hold the loaded xml file
var SWFList:XMLList; //used to hold a list of all external swf source,atribute and etc
var xmlLoader:URLLoader = new URLLoader(); //intance of URLloader class used to XML file
var totalSWF:int; //hold the total number of external swf there is to be loaded
var mainContainer:MovieClip =new MovieClip();//act as the main container
var SWFContainer:MovieClip; //hold the loaded SWF as it's child
var swfLoader:Loader; //instance of loader class used to load the external swf
var myCounter:int = 0; //used to track how many external swf has been loaded and added to stage
var bgImageURL:String;//hold the url of the background image
var imageLoader:Loader;//intance of loader class used to load background image
// Stage Setting
//========================================================================================
this.stage.align = StageAlign.TOP_LEFT;
this.stage.scaleMode = StageScaleMode.NO_SCALE ;
this.stage.displayState = StageDisplayState.FULL_SCREEN;
//load the xml file
//======================================================================================== ==
xmlLoader.load(new URLRequest("FlashBlock[s].xml"));
xmlLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void
e.target.removeEventListener(Event.COMPLETE , processXML);
myXML = new XML(e.target.data);
bgImageURL = myXML.Background.text();
SWFList = myXML.BLOCK;
totalSWF = myXML.BLOCK.length();
doSizeUpMainContainer();
loadBackgroundImage();
function doSizeUpMainContainer():void
//resizing the mainContainer dimension
//in this case i just make the size the same as the screen dimension
addChild(mainContainer);
mainContainer.graphics.beginFill(0xFD562D, 0);
mainContainer.graphics.drawRect(0,0, stage.stageWidth, stage.stageHeight);
mainContainer.graphics.endFill();
function loadBackgroundImage():void
//load the background image
imageLoader = new Loader();
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onBgImageLoadComplete);
imageLoader.load(new URLRequest(bgImageURL));
function onBgImageLoadComplete(e:Event):void
e.target.removeEventListener(Event.COMPLETE, onBgImageLoadComplete);
mainContainer.addChild(imageLoader.content);
imageLoader.x = (stage.stageWidth - imageLoader.content.width)/2;
imageLoader.y = (stage.stageHeight - imageLoader.content.height)/2;
loadSWF();
function loadSWF():void
swfLoader = new Loader();
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE , swfSetting);
swfLoader.load(new URLRequest(SWFList[myCounter].@source));
function swfSetting(e:Event):void
e.target.removeEventListener(Event.COMPLETE , swfSetting);
SWFContainer = new MovieClip();
mainContainer.addChild(SWFContainer);
// i did this so i can resize the movieclip size to what i need..,
SWFContainer.graphics.beginFill(0xff6633, 0);
SWFContainer.graphics.drawRect(0,0, Number(SWFList[myCounter].@width), Number(SWFList[myCounter].@height));
SWFContainer.graphics.endFill();
SWFContainer.x = SWFList[myCounter].@left;
SWFContainer.y = SWFList[myCounter].@top;
SWFContainer.addChild(e.target.content);
//load and add another SWFContainer untill all swf listed in the swf added
if(myCounter < (totalSWF-1))
myCounter++;
swfLoader = null;
loadSWF();
i really do not have any idea why this could happen and how to solve it..,
any help would be greatly apprecited cause i'm literally meeting a dead end with this bug..,hello there kglad,
thanks for responding in this thread..,
i did what you told me :
i did check all of my loader instance till myLoader.parent.parent.parent and it return 1 for every single one of them
but by removiing the "this.stage.displayState = StageDisplayState.FULL_SCREEN;"
i do get new error which is:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at slideshow_fla::MainTimeline/doAspectRatio()
well from what it tokd me it came from my slideshow swf..,(this swf also fully code and has nothing placed on stage by manually)
the thing is in my mine swf code i never refer to what external asset property, i just told to load it and when the load is complete i put it in the display list..,
from googling i suspect that it played to early beacause i put the script in the first frame of the timeline of slideshow.swf
and for the moment i'm trying to find what error do cause it..,
(but why this didn't happen all the time??)
here is the slideshow code:
import fl.transitions.*;
import fl.transitions.easing.*;
import flash.display.*
import flash.utils.Timer;
import flash.events.TimerEvent;
//list of global variables
var mySlideSpeed:Number; //determine how long each image displayed
var myTransitionName:String; //the name of the transition to be used
var myxmlList : XMLList;//reference to the list of the image
var myTotal:int; //total of image to be displayed
var myImage:Loader;//load the image into the container
var tempWidth:int;
var tempHeight:int;
var myTraansitionInDuration:int = 2;//the duration of transition in effect
var myTraansitionOutDuration:int = 2;//the duration of transition out effect
var myThumbHolderArray : Array = [];//to hold each thumbimage of the image
var Counter : Number = 0; //to count how many image has been successfully loaded
var myMC : MovieClip = new MovieClip(); //as the container of the picture so that it can be manipulated with transition manager
var container: MovieClip = new MovieClip();//hold the image after transition
var myImageTracker :Number = 0; //to know which image is in the stage
var myTimer :Timer; //the timer
var myTM:TransitionManager = new TransitionManager(myMC);//instance of transitionmanager class;used to give transition effect the image
//creating the loader instance n loading the file
var myXML:XML;
var XMLLoader :URLLoader = new URLLoader();
XMLLoader.addEventListener(Event.COMPLETE, processXML);
var base:String = this.root.loaderInfo.url;
base = base.substr(0, base.lastIndexOf("/") + 1);
XMLLoader.load(new URLRequest(base + "slideshow.xml"));
function processXML(e:Event):void
e.target.removeEventListener(Event.COMPLETE, processXML);
XML.ignoreWhitespace = true;
myXML =new XML(e.target.data) ;
mySlideSpeed = Number(myXML.transition.@slidespeed) + myTraansitionInDuration + myTraansitionOutDuration ;
myTimer = new Timer (mySlideSpeed*1000);
myTimer.addEventListener(TimerEvent.TIMER, imageRemover);
myTransitionName = myXML.transition.@name;
myxmlList = myXML.IMAGE;
myTotal = myXML.IMAGE.length();
imageLoader();
function imageLoader():void
for (var i:Number = 0; i < myTotal; i++)
var imageURL:String = base + myxmlList[i];
var myLoader:Loader = new Loader();
myLoader.load(new URLRequest(imageURL));
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete)
//transfering each thumb image loaded to a variable to be able to be refered back when the show is running
myThumbHolderArray.push(myLoader);
function onComplete(e:Event):void
Counter ++;
if(Counter == myTotal)
e.target.removeEventListener(Event.COMPLETE, onComplete);
showStarter();
function showStarter():void
addChild(container);
addChild(myMC);
// myMC.x = container.x = myMC.y = container.x = 0;
doAspectRatio();
imageSlider();
function doAspectRatio():void
for (var i:Number = 0; i < myTotal; i++)
myImage = Loader (myThumbHolderArray[i]);
if (myImage.width > myImage.height)
tempWidth = myImage.width;
tempHeight = myImage.height;
//supposedly to access the container dimension holding this swf as it's child
myImage.width = this.parent.width;
myImage.height = (tempHeight * this.parent.height)/tempWidth ;
else if (myImage.width < myImage.height)
tempWidth = myImage.width;
tempHeight = myImage.height;
myImage.height = this.parent.height;
myImage.width = (tempWidth * this.parent.width)/tempHeight ;
function imageSlider():void
if (getChildIndex(container)== 1)
swapChildren(myMC, container);
myImage = Loader (myThumbHolderArray[myImageTracker]);
myMC.addChild(myImage);
//center the image
myImage.x = (this.parent.width - myImage.width)/2;
myImage.y = (this.parent.height - myImage.height)/2;
if (myTransitionName == 'Fly')
myTM.startTransition({type:Fly, direction:Transition.IN, duration:myTraansitionInDuration, easing:None.easeIn, startPoint:7});
else
if (myTransitionName == 'Zoom')
myTM.startTransition({type:Zoom, direction:Transition.IN, duration:myTraansitionInDuration, easing:Strong.easeIn});
else
if (myTransitionName == 'Photo')
myTM.startTransition({type:Photo, direction:Transition.IN, duration:myTraansitionInDuration, easing:None.easeIn});
else
if (myTransitionName == 'Squeeze')
myTM.startTransition({type:Squeeze, direction:Transition.IN, duration:myTraansitionInDuration, easing:Strong.easeIn, dimension:0});
else
myTM.startTransition({type:Fade, direction:Transition.IN, duration:myTraansitionInDuration, easing:Strong.easeIn});
myTM.addEventListener("allTransitionsInDone", holdDelay);
function holdDelay(e:Event):void
this.removeEventListener("allTransitionsInDone", holdDelay);
myTimer.start();
container.addChild(myImage);
if (getChildIndex(myMC)== 1)
swapChildren(container, myMC);
function imageRemover(e:Event):void
myImageTracker ++;
if (myImageTracker == myTotal)
myImageTracker =0;
imageSlider();
and by the way can you tell me the reason you told me to remove "this.stage.displayState = StageDisplayState.FULL_SCREEN;" line ??
Maybe you are looking for
-
Since I installed version 3.6.13, I can't download ANYTHING. Firefox shows the Downloads window and that the file is downloaded, but there is NOTHING, and I'm sure it's not an AV problem...
-
Exchange 2010 - Export a list of delegates for a given group of users
I am trying to export a list of delegates on a list of mailboxes in Exchange 2010, and cannot get it to work. This is the most promising one I'm working with. $list = import-csv c:\day1.csv $list | foreach-object {get-mailbox -ResultSize unlimited |
-
RTMT error: not collecting session traces
Hi, I have a problem with RTMT that complicate my troubleshooting of calls since some weeks. When I open or try to generate a session trace of calls, the RTMT dont show any call output, only the following messages: Before this happen the session trac
-
[Spotlight] searching on a remote Volume and printing results
Morning. I want to search on /Volumes/Server$ for all files with the extension .tex created after 2008-30-04 and print the results in a list containing the full paths of all items. How can I do that? TIA and kind regards, Friedrich
-
Query for FREE_SELECTIONS_INIT function for selection screen
Hi , I am calling this function FREE_SELECTIONS_INIT for implementation of selection screen , but when I am trying to pass a "QUAN" datatype in FIELD_DESC table for TYPE Parameter as importing parameter, its giving a dump . But for other types of dat