hello,
please help me
When running my application I encountered this problem "Cannot read property ‘parentAllowsChild’ of null"
** ******’
Because loaderInfo is null so how can solve this problem?
hello,
please help me
When running my application I encountered this problem "Cannot read property ‘parentAllowsChild’ of null"
** ******’
Because loaderInfo is null so how can solve this problem?
From LoaderInfo.hx parentAllowsChild :
/**
* Expresses the trust relationship from Loader(parent) to the content
* (child). If the parent has allowed the child access, <code>true</code>;
* otherwise, <code>false</code>. This property is set to <code>true</code>
* if the parent object called the <code>allowDomain()</code> method to grant
* permission to the child domain or if a URL policy file is loaded at the
* parent domain granting permission to the child domain. If child and parent
* are in the same domain, this property is set to <code>true</code>.
*
* <p>For more information related to security, see the Flash Player
* Developer Center Topic: <a
* href="http://www.adobe.com/go/devnet_security_en"
* scope="external">Security</a>.</p>
*
* @throws Error Thrown if the file is not downloaded sufficiently to
* retrieve the requested information.
*/
from DisplayObject.hx re loaderInfo…
/**
* Returns a LoaderInfo object containing information about loading the file
* to which this display object belongs. The <code>loaderInfo</code> property
* is defined only for the root display object of a SWF file or for a loaded
* Bitmap(not for a Bitmap that is drawn with ActionScript). To find the
* <code>loaderInfo</code> object associated with the SWF file that contains
* a display object named <code>myDisplayObject</code>, use
* <code>myDisplayObject.root.loaderInfo</code>.
*
* <p>A large SWF file can monitor its download by calling
* <code>this.root.loaderInfo.addEventListener(Event.COMPLETE,
* func)</code>.</p>
*/
So possibly… wait for an Event.COMPLETE if you’re downloading an asset, or try yourDisplayObject.root.loaderInfo rather than yourDisplayObject.loaderInfo
hi David,
I tried to replace DisplayObject.root.loaderInfo by DisplayObject.loaderInfo but i had another error
"Uncaught TypeError: Cannot read property ‘get_loaderInfo’ of null" but i think it is related to the first
I did the following test, and it seemed consistent on Flash and other platforms:
package;
import openfl.display.Sprite;
class Main extends Sprite {
public function new () {
super ();
trace (loaderInfo);
trace (root);
trace (root.loaderInfo);
var sprite = new Sprite ();
trace (sprite.loaderInfo);
trace (sprite.root);
addChild (sprite);
trace (sprite.loaderInfo);
trace (sprite.root);
}
}
If you find a difference between Flash and other targets we could resolve, let me know!
As for your function, perhaps you should try something like this:
private function get_parentAllowsChild ():Bool {
if (loaderInfo != null) return loaderInfo.parentAllowsChild;
return false;
}