Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Please HELP Me With This! Error 1046!

New Here ,
Feb 15, 2014 Feb 15, 2014

I cannot figure out what my problem is. When I check for errors its is not telling me any. But when I run it, it is saying: 1046: This was not found or was not a compile-time constant: home2.

import flash.events.MouseEvent;

import flash.display.Loader;

import flash.net.URLRequest;

import flash.events.Event;

var loadvar:Loader = new Loader();

var home1 = loadvar;

home1.load(new URLRequest("img/home1.jpg"));

home1.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);

var home2 = loadvar;

home2.load(new URLRequest("img/home2.jpg"));

home2.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);

function onComplete(e:Event):void

{

var img:Bitmap = Bitmap(e.target.content);

img.width = 100;

img.height = 100;

};

thumb1.addChild(home1);

thumb2.addChild(home2);

But it is working when I take our everything that has to do with home2.

TOPICS
ActionScript
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 15, 2014 Feb 15, 2014

you're assigning the same loader to three different instance names, loadvar, home1 and home2.  and you only have one loader while you need two if you want to see home1.jpg and home.jpg at the same time:

use:

import flash.events.MouseEvent;

import flash.display.Loader;

import flash.net.URLRequest;

import flash.events.Event;

var home1:Loader=new Loader();

home1.load(new URLRequest("img/home1.jpg"));

home1.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);

var home2:Loader=new Loader();

home2.lo

...
Translate
Community Expert ,
Feb 15, 2014 Feb 15, 2014

you're assigning the same loader to three different instance names, loadvar, home1 and home2.  and you only have one loader while you need two if you want to see home1.jpg and home.jpg at the same time:

use:

import flash.events.MouseEvent;

import flash.display.Loader;

import flash.net.URLRequest;

import flash.events.Event;

var home1:Loader=new Loader();

home1.load(new URLRequest("img/home1.jpg"));

home1.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);

var home2:Loader=new Loader();

home2.load(new URLRequest("img/home2.jpg"));

home2.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);

function onComplete(e:Event):void

{

var img:Bitmap = Bitmap(e.target.content);  // this does nothing useful.

img.width = 100;

img.height = 100;

};

thumb1.addChild(home1);

thumb2.addChild(home2);

// both will now load but you won't see both because they are positioned on top of each other.  ie, offset one of them.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 15, 2014 Feb 15, 2014

That was actually my first choice. I set a new variable to see if it would make a difference. I just used the code you gave me and I am still getting the same problem.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 15, 2014 Feb 15, 2014

that error's not from the code i suggested.

click file>publish settings>swf and tick "permit debugging".  retest.

the problematic line number will be in the error message.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 15, 2014 Feb 15, 2014

I tried that as well. It still did not work.

I think the problem is that I cannot load more than one images into the file.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 15, 2014 Feb 15, 2014

you can if you use the code i suggested.

anyway, after following the suggestion in message 3, copy and paste here the complete error message.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 15, 2014 Feb 15, 2014

Ok. I opened a new file and tested it again. It is working fine. I guess there is something wrong with the project I am working currently working on. It is air for android so maybe it works differently. Do you have any advice. If not, thank you very much for your help anyway.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 15, 2014 Feb 15, 2014

your current project has code somewhere causing the error.

if you would follow my suggestions, you would be able to find and correct the error.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 15, 2014 Feb 15, 2014

I opened a new file and started over. It is working fine now. Thank you so much.

I had another question.

I would like to have a shape with four dots on each end that can be dragged around. And then once the button is clicked telling the software the shape is finished, it will create a movie clip that shape at that exact stop and load a chosen image into that movie clip.

How is this possible?

Thanks again.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 15, 2014 Feb 15, 2014

convert your shape to a movieclip and you can use the startDrag() and stopDrag() methods to drag it.

i couldn't understand your 2nd sentence because i don't know what you mean by, "the button" and the "the shape is finished".

but you can load an image use the loader class.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 16, 2014 Feb 16, 2014

This is how it will have to work:

A user first takes a picture of something. Then they will click a button that will put a rectangle on top of the page. The user will then take each of the four points and drag them to form a shape. Then they fill click the finished button and a movie clip will be created according to those points. And it will be exactly placed where the shape was. Then the user will choose an image which will be loaded on to that movie clip the the shape of that picture must be altered to fit the movie clip.

Also, for some reason, when I type in all of the code in one frame, it is not working. But when I greate a new frame what is the same number as the frame with the content, it is working. How do I get all of the actionscript in just one frame?

Again, Thank you so much.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 16, 2014 Feb 16, 2014
LATEST

to reshape your images check the distordImage class, http://www.sheldonmckenzie.com/com/kiroukou/graphics/DistordImage.as

to code for objects in a frame where those objects do not exist, use the render event to trigger coding for those objects.  to use the render event you would do something like the following to code for a movieclip mc that exists in frame 20:

// frame 1 code

this.addEventListener(Event.RENDER, renderF);

goto_mc.addEventListener(MouseEvent.CLICK,gotoF);

function gotoF(e:MouseEvent):void{

stage.invalidate();

this.gotoAndStop(20);

}

function renderF(e:Event):void{

// coding for mc, which doesn't exist in this frame, can be used here

mc.addEventListener(MouseEvent.CLICK,mc_clickedF);

}

function mc_clickedF(e:MouseEvent):void{

// mc clicked

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines