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

how to get variables IN a loop to post their results outside the loop for use by addchild commands.

Participant ,
Oct 24, 2024 Oct 24, 2024

Copy link to clipboard

Copied

wondering how you do this as i'm not having good luck figuring this out.

 

 

ok i have a loader that grabs the contents of a swf and on its own, will load just fine to the stage as all of the addchild etc commands are IN the loop), problem is  as soon as separatea the two, they don't see the commands anymore. i know that stuff in a {} set is like this...and wonder how you get it out without a battle. i need to be able to access them outside the loop so the addchild commands can place them in the correct symbol with as3 name etc attached already.

 

 

 

 

 

 

TOPICS
ActionScript

Views

582

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

Copy link to clipboard

Copied

add the loop variables as properties of objects.

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

Copy link to clipboard

Copied

this is where i'm having the problem spliting this at.

 

main timeline :

function LoadCompleteF(e:Event):void{
var A = ["Front_Leg_6","Back_Leg_6","Back_Leg_6"];
var E : Class = Class(getDefinitionByName (A[0]));
var F : Class = Class(getDefinitionByName (A[1]));
var G :Class = Class(getDefinitionByName(A[2]));

var obj:Object= new E();

 

 

on the symbol i'm trying to update (1 of 3)

 

addChild(DisplayObject(obj));
obj.x=100;
obj.y=500;

 

the next 2 are obj2, and 3 and no major changes.

 

it works together, but isn't letting me separate it, i know why as its all in the brackets so they only work in that section.

 

 

 

 

 

repeats for 2 and 3....

 

 

says possible undfined obj....

 

can't win for trying some days. did figure out how to store the clothing,pet profile and etc using a empty array and push command to update the array to what was selected by the user.  i win one and lose one it seems on this 🙂

 

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

Copy link to clipboard

Copied

declare obj outside that function. define it inside that function.

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

Copy link to clipboard

Copied

code example for this how to declare it. So far this looks to be the last item keeping the artwork from being restored hopefully.

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

Copy link to clipboard

Copied

var obj:Object;


function LoadCompleteF(e:Event):void{
var A = ["Front_Leg_6","Back_Leg_6","Back_Leg_6"];
var E : Class = Class(getDefinitionByName (A[0]));
var F : Class = Class(getDefinitionByName (A[1]));
var G :Class = Class(getDefinitionByName(A[2]));

obj= new E();
}

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

Copy link to clipboard

Copied

i am not getting anywhere or missing something obvious to a more trained person:

i've tried moving it, to wherre you had it.etc putting where you had it at...clearly im doing something wrong here to get this thing to move into its correct places.

 

 

 

main script

 

var obj:Object;
var ldr:Loader = new Loader();
var url:URLRequest=new URLRequest("BLUE_Kassegat_v2.swf");
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,LoadCompleteF);
ldr.load(url,new LoaderContext(false,ApplicationDomain.currentDomain));
function LoadCompleteF(e:Event):void{
//also trried here and did not get a successful result

var A = ["Front_Leg_1","Back_Leg_6","Back_Leg_6"];
var E : Class = Class(getDefinitionByName (A[0]));
obj= new E();
}
trace (obj);

 

 

front_leg_1 scripting....

 

addChild(obj):

obj.x=-29.90

obj.y=--17.50

 

 

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

Copy link to clipboard

Copied

you can't reference obj until loadCompleteF executes.

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

Copy link to clipboard

Copied

ok ive tried putting the outside one at the top, fail, butting it between the two, fail  putting it after...fail ...

clearly i need an example of what needs to be done her so the obj statement can pass to the symbol loading part. i'm getting null when it doesn't hit the compiler error first. did i mention that the second part of the code is going into symbol "front_arm_1" which has its own code block which is where the problem is. the class "front arm _1' has default coding attached to it when you assign it for actionscript use.

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

Copy link to clipboard

Copied

you don't understand.  loading is asynchronous.

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

Copy link to clipboard

Copied

the problem is that for the animations to load correctly i need to get the loaded symbol from the sw loader  to its  to its correct as3 symbol as the animations are built on them(anything _1  has over 1800 uses per the library) . and theirs too many symbols in the wireframe to give each one its own loader.i was going to make one for each section(shirt,pante,etc)  and put a variable for the parts that goes to the symbols to be placed.

 

.what im going to do to allow user selection of the color is have empty arrays for the color, species, etc and PUSH the selection to the array which is empty by  default if the user selects "Green" and "*species of choice* " it will pass that to the file laoder for the pet. i'd be happy to see one go at this point so i can see what mess i'im in for. Once the stuff loads into the wireframe, i only need to call the animations out of it and they are assembled thank goodness.

 

 

 

 

 

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

Copy link to clipboard

Copied

if a user is selecting something , that will occur (or you'll insure it will occur) after loading completes.

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

Copy link to clipboard

Copied

actually they need to select it FIRST as guess whats giving the loader its filename to load. Color blue and species kaassegat for instnace literally make up the file name that starts the process. this how the oriignal game operated it. so it will need a catch for "empty" spots and send the user back "please select a color and species to continue" etc. i sense fun ahead. any ideaas why im getting issues  passing from the loader to the symbols i need though. one way or another the loader needs to pass its symbol out so i can get it into the symbol of that name. There was a strange item that was origianly there im not sure of its a clue or not  id= "name of symbol" was on the timeline of each as3 ready symbol, they all have classes etc .....all started with the same thing " id"  too. i could not trace any of the ID commands from the main part so i sense something is missing...(always came back as not defined or etc) .

i

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

Copy link to clipboard

Copied

well, have they already chosen the obj properties?

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

Copy link to clipboard

Copied

the names yes, the actual objects no as that file loader being given the color and species is what tells it what file to grab that contains the art. this esentuially is the same process we did in animate cc using the script to rename the symbol xx, etc to the as3 names and dropping them into the wireframe and telling it "yes please replace these objects. if you think thats an easier option how is that done using as3 code to replace the contents of something IN the library with something your loading.

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

Copy link to clipboard

Copied

have they chosen the x and and y properties?

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

Copy link to clipboard

Copied

x and y are fixed to the piece,so they are established.

var body = ["front_arm_1"];
var xbody= [-14.90];
var ybody=[-1.20];

this is a exmaple of what im going to load off of. i have on the desk here a piece of paper with all the nuumbers but been wiating to do that until it loads one first. 

 

thinking this is whaT I need to establish but keep getting interputed at teh house while trying to figure it out so im gonna try later 😞

https://stackoverflow.com/questions/24347052/passing-variables-between-classes-in-actionscript-3

 

how do you get to main.as to start that code as that looks like it goes in the class code and not something i've had to do yet on the main timeline.

 

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

Copy link to clipboard

Copied

then assign x,y in your load complete function.

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

Copy link to clipboard

Copied

going to visually draw out the problem here first to make sure what i understand is correct.

 

terryw30405050_0-1729979616843.png

terryw30405050_2-1729980321123.png

theirs a reason that im trying to keep that id = "symbol " part...its already coded IN the wireframe(i suspect its missing soemthing from jpexs  and i see a huge um...explosive problem coming up, theirs later files that also have a later wireframe and hoping to not have to do this twice other than the connecting code for classes. Also some of the minigames do load the avatars and if i can make my avatar system work as their did, it should be 1000x simpler to make it think its still in its happy place on a flash preservation sites tool that also makes it think its still on its original domain. likely just going to code a hard coded standin for that purpose so they run, someone else actually converts games not me thank goodness for that effort

thats been the biggest  of peoples inquirys and i'd love to be the one who solved it. can't be far off,once it gets those pet pieces into the front_leg, front_arm, etc spots the avatar is assembled automatically for all 55x9 varients. this offers multiple paths to try, precanned wireframe file, doesn't go, give it the vars is needs to assemble one and see if it does it on its own.....its one path or the other if you think about it.

 

 

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

Copy link to clipboard

Copied

id is defined in what class?

id is needed in what other class?.

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

Copy link to clipboard

Copied

in each of the symbols was a this id="name of part"

 

look what happens when i renamed them var id ="nane of part'

 

https://www.youtube.com/watch?v=tcBkCKAlk68

 

some ad was running audio while i recorded it, since its unlisted youtube video i'm not too worried....

 

this looks almost like id is a LOADER on its own am i correct going "hey give me whatever x's color and etc is? and send it HERE. i thought this was wrong as generally variables don't all have the same name, but apparently in different classes, its fine 🙂

 

this is as far as i got, but thought mabe you could highliight a path on this discovery. all i did to "load" this was use a existing video i animated using a prebuilt wireframe. figured the video would show more whats going on than a screenshot. mabe jpexs didn't manage it correctly as thats how i'm looking at the code and looking at code you wrote and code jpexs wrote is ...scary sometimes esp if the code isn't running to speak all the way. 

 

 

 

 

 

 

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

Copy link to clipboard

Copied

you're very difficult to follow.

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

Copy link to clipboard

Copied

ok what i'm getting back on animations is the following when i put in the traces (this+id)

 

[object Front_head_Beard]Front_head_Beard
[object Front_head_Mask]Front_head_Mask
[object Front_head_FX]Front_head_FX
[object Front_Wand]Front_Wand

 

now that the symbols are tracing their code in animation, how would i push art into those classes seeing what you have so far? recall the one in the video was a precanned wireframe file, but it still had all its code attached so i figurd i would see what both ends are doing to speak as normally it has NO art and is blank, making it hard to tell waht is or isn't loading. the only code i put on the main stage is the actual motion symbols used on the game. this is also how i intend to make the viewer work as well.

 

getting the pieces to trace is very exciting as well, that means i at least got a idea whats doing what now.

what tripped me up the first time was i swore that you cannot reuse a variable...well hello classes that don't talk to each other doing so. i think its sitll obvious that i've not fully gripped the object oriented coding setup yet.

 

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

Copy link to clipboard

Copied

 can you answer 

 

id is defined in what class?

id is needed in what other class?.

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

Copy link to clipboard

Copied

i'd like to get a loader in the main or wherever is most handy  that brings the art into the symbols that have the trace commands on them. keep in mind that this 24kb list is TEXT this file created from a 1 minute animation lacking half of them so it seems really odd they got all of these classes connected to main per the stackoverflow example as this is mabe 1/2 of the animation pieces.

 

for instance Front_Torso should be looking for a a BODY identifier and say loading blue_ and a species and shoving that piece of art into object front_Torso (repeats) per this trace command whuch was "THis+ID" . ALL of the symbols commands were named ID whuch makes me nervous opening ID to the main when 270 estimated symbols are named it?(this animnion file did NOT contain all the tricks for the pets. there is no code in my main timeline other than what the animation was currently, which is why i'm a bit shocked its giving me all these traces this easily.

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