Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Flex > Flex 2, 3 & 4

Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
Old 01-07-2012, 11:16 AM   #1
Registered User
Join Date: Jun 2006
Posts: 4
Red face Error 1000: Ambiguous Reference when embedding from a package

Hello everybody,

I am encountering an issue I really can't find a solution to. When embedding assets in a class file and assigning them to a variable of the Class type, I get a compiler error 1000 "Ambiguous Reference". This ONLY happens when I move the class file into a package. Leaving the class file in the main source folder results in no errors, but I am not satisfied with this solution. Here's the source code for one of my classes.

Some clarifications:
I am not using any namespaces, at least not explicitly.

My first assumption was there would be a problem with the build path, so I added the "assets" folder to the project paths and tried referencing the embedded files directly (just source="filename.png"). Again, this works flawlessly from the default package, but not from any other package.

Flash Builder 4.5 shows two errors for each embedded asset. These for example relate to IMG_COMPASS_ARROW:
1000: Ambiguous reference to GravityCompass_IMG_COMPASS_ARROW.
Can not resolve a multiname reference unambiguously. GravityCompass_IMG_COMPASS_ARROW (from GravityCompass_IMG_COMPASS_ARROW.as) and comp:GravityCompass_IMG_COMPASS_ARROW (from comp\GravityCompass_IMG_COMPASS_ARROW.as) are available.

ActionScript Code:
package comp  {     import flash.display.Bitmap;     import flash.geom.Matrix;     import flash.geom.Point;         import mx.core.UIComponent;         public class GravityCompass extends UIComponent     {                 [Embed(source="assets/img_compass_bg.png")]         private static const IMG_COMPASS_BG:Class;         [Embed(source="assets/img_compass_arrow.png")]         private static const IMG_COMPASS_ARROW:Class;                 private var _backgroundImage:Bitmap;                 private var _arrowImage:Bitmap;                 private var _arrowRotation:Number;                 private var _bgCenterX:Number;                 private var _bgCenterY:Number;                 private var _arrowCenterX:Number;                 private var _arrowCenterY:Number;                         public function GravityCompass()         {             super();         }                 override protected function createChildren():void {             _backgroundImage = new IMG_COMPASS_BG();             _arrowImage = new IMG_COMPASS_ARROW();                         _bgCenterX = .5 * _backgroundImage.width;             _bgCenterY = .5 * _backgroundImage.height;             _arrowCenterX = .5 * _arrowImage.width;             _arrowCenterY = .5 * _arrowImage.height;                         _arrowImage.x = _bgCenterX - _arrowCenterX;             _arrowImage.y = _bgCenterY - _arrowCenterY;             addChild(_backgroundImage);             addChild(_arrowImage);         }                 override protected function measure():void {             measuredWidth = _backgroundImage.width;             measuredHeight = _backgroundImage.height;             measuredMinWidth = _backgroundImage.width;             measuredMinHeight = _backgroundImage.height;         }                 public function set direction(p:Point):void {                         // Calculating the angle between p and the upward             // pointing vector (0, -1) using the well known formula             // cos(angle) = v1 * v2 / |v1| * |v2|             var angle:Number = Math.acos(-p.y / p.length);                         if(p.x < 0) {                 angle = -angle;             }                         var m:Matrix = new Matrix();             // Moving the graphic's center to the origin             m.translate(-_arrowCenterX, -_arrowCenterY);             // Rotating around the origin             m.rotate(angle);             // Moving the graphic's center back             m.translate(_arrowCenterX, _arrowCenterY);             // Then move it to the background graphic's center             m.translate(_bgCenterX-_arrowCenterX, _bgCenterY-_arrowCenterY);             // Write the result back to the graphic's transform matrix             _arrowImage.transform.matrix = m;         }     } }

Last edited by Wastelander; 01-07-2012 at 11:34 AM.
Wastelander 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

All times are GMT. The time now is 04:40 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, 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.