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

trying to pass a array string and not getting anywhere

Participant ,
Oct 19, 2024 Oct 19, 2024

Copy link to clipboard

Copied

clearly im too tired to be trying this or something obvious is escaping me here....

 

wanting to make an array to put the loading object into :

 

the code as it should look post the arrays dropping their data as this.....

 

 

 

var fl_MyInstance:Front_Arm_1 = new Front_Arm_1();
addChild(fl_MyInstance);

 

 

**clap and look at the arm appear**

 

(

*wHAT I NEED TO WORK*

 

var A =[Front_Arm_1];
trace(A[0]);
var fl_MyInstance:A[0] = new A[0]);
addChild(fl_MyInstance);

 

I've tried using var with "" around, thats not fixing it(its class front_arm_1 now, in quotes its just Front_Arm_1.. How i got the list generator to work and failing at this is beyond me but i guess thats luck on my part and books that have whole chapters on arrays but this....losing hair oh did i mention i haven't even TRIED the x and y coordinate arrays yet?

 

so the thing needs to grab the class, then when its trying to place the art, it also needs x and y placements as other art is going to grab a swf and replace whats in the class with new contents, but i can't even get this so far,.

 

 

TOPICS
ActionScript

Views

525

Translate

Translate

Report

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 , Oct 21, 2024 Oct 21, 2024

you're welcome.

Votes

Translate

Translate
Community Expert ,
Oct 20, 2024 Oct 20, 2024

Copy link to clipboard

Copied

the first problem is

 

var A =[Front_Arm_1];

 

that makes no sense.  you have a class name, but aren't using it correctly.  you use:

 

var A:Array = ["Front_Arm_1"];

var C:Class = Class(getDefinitionByName(A[0]));

var instance:* new C();

 

 

Votes

Translate

Translate

Report

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
Participant ,
Oct 20, 2024 Oct 20, 2024

Copy link to clipboard

Copied

anything standing out here as a trap for the multi symbol loader? i have not yet tried external loading from a file with this, but the three  paws are different and are loading off the array. note" i did not ATTEMPT to loop this using for, so i'm aware the multiple D++'s are the not the most pragmatic way to do this , but i wanted to see it generate images before i even tried the looping. nor are the paws in any specific spot yet. more of a "is everything loading here"....

terryw30405050_0-1729440165990.png

 

 

 

 

var A:Array = [Front_Arm_1,Front_Arm_1copy];
var B = [500,100];
var C = [800,300];
var D = 0;
var image :Sprite = new A[D] ();
addChild(image);
image.x=B[D];
image.y=C[D];
var image2:Sprite = new A[D++] ();
addChild(image2);
image2.x=B[D++];
image2.y=C[D++];

 

 

 

 

Votes

Translate

Translate

Report

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 ,
Oct 20, 2024 Oct 20, 2024

Copy link to clipboard

Copied

same mistake.  read my post.

Votes

Translate

Translate

Report

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
Participant ,
Oct 20, 2024 Oct 20, 2024

Copy link to clipboard

Copied

if i can get the file to come up, i would have it attached here. its not letting me put the fla.it uploads and striips it off.

 

trace commands on what im running:

[class Front_Arm_1],[class extra_arm],[class extra_red_arm]
1100,800,200
500,700,500
[object Front_Arm_1]
[object extra_arm]
[object extra_red_arm]

Votes

Translate

Translate

Report

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 ,
Oct 20, 2024 Oct 20, 2024

Copy link to clipboard

Copied

using the code you already showed here, show that code with the correction

Votes

Translate

Translate

Report

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
Participant ,
Oct 20, 2024 Oct 20, 2024

Copy link to clipboard

Copied

var A:Array = ["Front_Arm_1"];
var C:Class = Class(getDefinitionByName(A[0]));
var instance:*; new C();
trace (C);
var image3:Sprite = new C[0] ();
addChild(image3);
// [class Front_Arm_1]

//output window TypeError: Error #1007: Instantiation attempted on a non-constructor.
at example2_fla::MainTimeline/frame1()

 

stoped at the first one as it was on a error

Votes

Translate

Translate

Report

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 ,
Oct 20, 2024 Oct 20, 2024

Copy link to clipboard

Copied

the error is occurring after tge code i suggested. ie, check the line with the error.

Votes

Translate

Translate

Report

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
Participant ,
Oct 20, 2024 Oct 20, 2024

Copy link to clipboard

Copied

status functional, ok heres a fun question then. how is the first example that works not throwing an error with 3 paws on screen? all i really should have to do soon is put a string that grabs the petpets files and then starts loading assets. You have no idea how exciting thats gonna be to put for instnace color blue into a array and a speciess and see this thing work. i have 66 of them that i can laod and game total is 400 they prodiuced but i'm not messing with those unless they appear as a good 90% of players had the basic colors and why spend a lot of effort on them currently. so much other stuff that needs fixing when they are a add to the array and hit enter affair once this works.

 

 

--your code integrated and working one one paw, will bring the other 2 later-

 

var A:Array = ["Front_Arm_1"];
var C:Class = Class(getDefinitionByName(A[0]));
var B = [200]
var D = [300]
var instance:*; new C();
var image3:MovieClip = new C ();
addChild(image3);
image3.x=B[0];
image3.y=D[0];

 

i know this doesn't look like a huge victory, but it looks like now i gotta pull the x, y coordinates off the pets body pieces and match that to the symbols or it becomes modern art from previous experience.

terryw30405050_0-1729463974925.png

 

 

Votes

Translate

Translate

Report

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 ,
Oct 20, 2024 Oct 20, 2024

Copy link to clipboard

Copied

what isn't triggering an error that you want to ask about?

Votes

Translate

Translate

Report

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
Participant ,
Oct 20, 2024 Oct 20, 2024

Copy link to clipboard

Copied

the first example i posted that the arms loadef thats uising the class in the array(no quotes)

.THis one looks nearly ready to loop if you look at the code.

var A: = [Front_Arm_1,extra_arm,extra_red_arm];
var B = [1100,800,200];
var C = [500,700,500];
var D = 0;
var image :MovieClip = new A[D] ();
addChild(image);
image.x=B[D];
image.y=C[D];
D++;
var image2:MovieClip = new A[D] ();
addChild(image2);
image2.x=B[D];
image2.y=C[D];
D++;
var image3:MovieClip = new A[D] ();
addChild(image3);
image2.x=B[D];
image2.y=C[D];

 

just wondering why  its functioning since you mentioned its not the corect way, but normally when you do that, the thing dies at teh compiler error screen. I'm getting all 3 things i'm trying to load with no errors even at teh correct x and y locations. is their something i'm missing?

I love all the help you have been on this problem but as you can tell, the programming is a new skill to me and i'd like to not get bad habits getting it going. i also attached a outfit piece here thats using the arms and has similar of a layout.

also noticing something  in the original code now i know what it BUT have no clue what its doing

each symbol of the wireframe for a body or clothing piece has this attached to it "id = "Front_Pants_1";" and this goes for every item with a as3 name thats worn. or part of the body. its not presnet in the actions of moving tghe pieces around in the wireframe to make animations.

note: their not named id(enter number here), every single one is id=i"item name")

 

it looks like an array but i suspect i need to look in the public code for a program called id since its not starting with var....

 

note: not done much yet with functions yet so if i seem a bit blind to this....don't be shocked

 

 

Votes

Translate

Translate

Report

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 ,
Oct 20, 2024 Oct 20, 2024

Copy link to clipboard

Copied

that code has to be in the fla that contains those classes.  it can't be in a fla loading swfs that contains those classes.

Votes

Translate

Translate

Report

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
Participant ,
Oct 21, 2024 Oct 21, 2024

Copy link to clipboard

Copied

its really ok actually, as i think it took care of a long standing headache i was having with the other petpet park group(using unity) claiming much of the technical work that i did to even get these thigns past a pile of dead files. 

They admitted in their discord doing it, and weridly once i stopped posting files, man did their progress fall fast or i would post what i call "animation errors " (aka stuff i was still working on) and watch them comment what a crappy job i was doing on restoring them. with a huge rant how hard animate cc is to use.  Always credit your sources 🙂

 

Either  way  this solves that problem by CODE anything i put out there publiclly either by the addchild method  and leave them a nice gift of a keyframe with code attached to it. 

It also looks faster  too as to make a animation sheet i could just drop the list of movements in a array and a if /then loop, type a few numbers  in the x y boxes and its done, plus that limits it use to video work for them unless they learn some timeline skills in animate cc to even make use of the asset. It works out in the end  Uniswf and the gaf converter both tell you go go back and put the stuff on the timeline so now i guess they will be learning how to use animate cc or the party is largely over.

Votes

Translate

Translate

Report

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 ,
Oct 21, 2024 Oct 21, 2024

Copy link to clipboard

Copied

ok

Votes

Translate

Translate

Report

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
Participant ,
Oct 21, 2024 Oct 21, 2024

Copy link to clipboard

Copied

**the file loader is working**

(from your previous solution, had to move some variables as i need B and C for x and y values  )
var ldr:Loader = new Loader();
var url:URLRequest=new URLRequest("s278.swf");
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,LoadCompleteF);

ldr.load(url,new LoaderContext(false,ApplicationDomain.currentDomain));
function LoadCompleteF(e:Event):void{
var A = ["Front_Glasses","Back_Glasses"];
var E : Class = Class(getDefinitionByName (A[1]));
var F : Class = Class(getDefinitionByName (A[0]));

var obj:Object= new E();
addChild(DisplayObject(obj));
obj.x=100
obj.y=500
var obj2:Object= new F();
addChild(DisplayObject(obj2));
//F.x=-100 these are marked out to find this piece on the stage
//F.y=800 ""
}

note: make sure to save s278.swf and the file you save in the same folder *looks at desk* yeah...

it was a bit tricky figuring out how to get that second symbol to load but it looks like i got it so far.

 

thanks for helping on this as oddly even the mistake one for stuff in the fla is useful when i want to make a bunch of

animation sheets, thats gonna be exp handy.. drop the list of tricks, drop a list of x and y coordinates that match the array numbers and  a if/then and its done. if i get this thing to color swap the pets out, man thats gonna be a cake worthy day and the unity to swf converters are like "sorry we do not convert as3 code...please put the content on the timeline....". can i put that error ON the cake 🙂

 

 

 

Votes

Translate

Translate

Report

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 ,
Oct 21, 2024 Oct 21, 2024

Copy link to clipboard

Copied

you're welcome.

Votes

Translate

Translate

Report

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
Participant ,
Oct 21, 2024 Oct 21, 2024

Copy link to clipboard

Copied

where did you find the GetDefinitionbyName  solution at  by chance? i  have not seen this in the as3 books i've looked so far is this a command thats not used a lot or it more of a "when once you have an application that needs it".....you won't forget it thing?

 

 

Votes

Translate

Translate

Report

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 ,
Oct 21, 2024 Oct 21, 2024

Copy link to clipboard

Copied

it's not used a lot (afaik), but it's part of the as3 api.

Votes

Translate

Translate

Report

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
Participant ,
Oct 23, 2024 Oct 23, 2024

Copy link to clipboard

Copied

LATEST

noticing a problem in the actual laoding here thats causing a issue. When the addchild command is in the {} set were fine, but that portion has to go in the wireframe under the petpet piece, and the variable is ONLY in the () section....how do i fix that 🙂

 

basciually the loader  itself needs to be on the main timeline, and then the actual adding it to the displaylist needs to happen in whatever that piece is for proper placement.

 

for instance Front_Arm_1(colored piece)  needs to be IN the parked in the wirefRAME (Front_arm_1__) symbol for Front_arm_1's code. 

 

 

Votes

Translate

Translate

Report

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